识别相似图像的好方法?

识别相似图像的好方法?

问题描述:

I've developed a simple and fast algorithm in PHP to compare images for similarity.

Its fast (~40 per second for 800x600 images) to hash and a unoptimised search algorithm can go through 3,000 images in 22 mins comparing each one against the others (3/sec).

The basic overview is you get a image, rescale it to 8x8 and then convert those pixels for HSV. The Hue, Saturation and Value are then truncated to 4 bits and it becomes one big hex string.

Comparing images basically walks along two strings, and then adds the differences it finds. If the total number is below 64 then its the same image. Different images are usually around 600 - 800. Below 20 and extremely similar.

Are there any improvements upon this model I can use? I havent looked at how relevant the different components (hue, saturation and value) are to the comparison. Hue is probably quite important but the others?

To speed up searches I could probably split the 4 bits from each part in half, and put the most significant bits first so if they fail the check then the lsb doesnt need to be checked at all. I dont know a efficient way to store bits like that yet still allow them to be searched and compared easily.

I've been using a dataset of 3,000 photos (mostly unique) and there havent been any false positives. Its completely immune to resizes and fairly resistant to brightness and contrast changes.

我在PHP中开发了一种简单快速的算法来比较图像的相似性。 p> \ n

快速(800x600图像每秒约40个)散列和未经优化的搜索算法可以在22分钟内完成3,000张图像,将每张图像与其他图像进行比较(3 /秒)。 p>

基本概述是获取图像,将其重新缩放至8x8,然后将这些像素转换为HSV。 然后,色调,饱和度和值被截断为4位,它变成一个大的十六进制字符串。 p>

比较图像基本上沿着两个字符串走,然后添加它找到的差异。 如果总数低于64,那么它的图像相同。 不同的图像通常在600 - 800左右。低于20且非常相似。 p>

我可以使用这个模型有什么改进吗? 我没看过不同组件的相关性(色调, 饱和度和值)是比较。 Hue可能非常重要,但其他人呢? p>

为了加快搜索速度,我可能会将每个部分的4位分成两半,并将最重要的位放在首位,这样如果它们检查失败了 那么lsb根本不需要检查。 我不知道一种有效的方法来存储这样的位,但仍然允许它们被轻松搜索和比较。 p>

我一直在使用3,000张照片的数据集(大多数是唯一的)而且还没有 有任何误报。 它完全不受调整大小和相当的亮度和对比度变化的影响。 p> div>

What you want to use is:

  1. Feature extraction
  2. Hashing
  3. Locally aware bloom hashing.

  1. Most people use SIFT features, although I've had better experiences with not scale-invariant ones. Basically you use an edge detector to find interesting points and then center your image patches around those points. That way you can also detect sub-images.

  2. What you implemented is a hash method. There's tons to try from, but yours should work fine :)

  3. The crucial step to making it fast is to hash your hashes. You convert your values into unary representation and then take a random subset of the bits as the new hash. Do that with 20-50 random samples and you get 20-50 hash tables. If any feature matches 2 or more out of those 50 hash tables, the feature will be very similar to one you already stored. This allows you to convert the abs(x-y)

Hope it helps, if you'd like to try out my self-developed image similarity search, drop me a mail at hajo at spratpix

You'll find huge amounts of literature on the subject. Just go over to Google Scholar or IEEE Xplore to search for articles. I had some contact with field when I did a project on shape recognition (largely insensitive to noise, rotations and resizes) in college -- here is the article.