二进制转换 [英] binary conversion

查看:140
本文介绍了二进制转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我希望比较大约4000像素的2张黑白图像。所以我有2个值为0或1的4000个整数int数组。我的想法是将每个数组转换为通过将所有整数一个接一个地构建而构建的单个二进制数。然后,我可以将此数字转换为基数为10的数字。我会用这个数字作为每个图像的签名来比较它们。


问题是构建二进制数所需的操作量。将每个4000数乘以10的幂并且将所有内容相加比直接比较每个帧逐像素长。 (因为我有很多图像,我认为无论如何都值得这样做。)


那么你认为有一种方法可以更快地构建二进制数吗?实际上,可能只使用像素值整数的最后一位并将其直接存储在4000位区域中。但是我不知道该怎么做。


问候

Hi,

I wish to compare 2 black and white images of about 4000 pixels. So I have 2 arrays of 4000 integers int of value 0 or 1. My idea was to convert each array to a single binary number built by putting all the integers one after the other. I could then convert this number to a base 10 number. I would use this number as a signature of each image to compare them.

The problem is the amount of operations to make to build the binary number. Multiplying each 4000 number by a power of 10 and summing everything is longer than comparing directly each frame pixel by pixel. (As I have a lot of images, I think it''s worth doing it anyway).

So would you have a method you think would be faster to build the binary number? In fact, it might be possible to use only the last bit of the pixel value integer and store it directly in 4000 bit zone. But I don''t know how to do that.

Regards

推荐答案

你在使用C ++吗?


如果是这样,请使用bitset而不是整数:
Are you using C++??

If so, use a bitset rather than integers:
展开 | 选择 | Wrap | 行号



您使用的是C ++吗?


如果是这样,请使用bitset而不是整数:
Are you using C++??

If so, use a bitset rather than integers:
Exp和 | 选择 | Wrap | 行号


用C ++编写函数并将其编译为externC:

You write the function in C++ and compile it as extern "C":

展开 | 选择 | Wrap | 行号


这篇关于二进制转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆