我们可以检查列表中是否存在重复的图像? [英] Can we check whether a duplicate image exists in a list?

查看:106
本文介绍了我们可以检查列表中是否存在重复的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很新的图像处理。我的SO问题是...


我使用相机拍摄图像,然后我使用这个图像,并对列表容器进行检查。如果列表容器包含一个看起来像这个图像的图像,那么做一个操作,否则不要。


示例...


  1. 我有一个图像img_one

  2. 我的列表包含image_one,image_two,image_three / li>
  3. 显示列表有image_one(即看起来像这个图像)

那么如何检查这张图片是针对列表容器中的项目,并显示哪个图像看起来像这个图像?



提前感谢朋友。所有的想法都不胜感激。

解决方案

这取决于你通过重复定义的内容。
$ b

如果您正在寻找绝对相同的副本(复制粘贴),游戏很简单。 Safir提出的方法只有几个性能改进,好的。



如果您想查找几乎完全相同的重复项,突然变得难以置信。查看这个检查图像与OpenCV的相似性了解更多信息



现在,回到简单的方法,这取决于你需要比较多少张照片。因为将每个图像与1000张图像的文件夹中的所有其他图像进行比较,您可以获得1.000.000图像读取和比较。 (因为你不能一次将它们全部存储在RAM中,所以你必须加载和卸载它们一百万次)对于即使是强大的台式机处理器也是如此。



一个简单的方法是使用散列函数(如sha2)为每个图像,然后比较只是哈希。图像的一个很好的特殊的散列可能是直方图(虽然对于积极的你可能想要用memcmp进行双重检查)。



即使你尝试强力方法(将每个图像像素与另一个图像进行比较),更快的方法是使用memcmp()而不是逐像素访问图像。


I am new to image processing. My SO question is...

I take an image using a camera, then I use this image and check it against a list container. If the list container contains an image that looks like this image then do an operation, otherwise don't.

Example...

  1. I have one image "img_one"
  2. My list contains "image_one,image_two,image_three"
  3. Show list has image_one (i.e. it looks like this image)

So how do I check this image against the items in the list container and show which image looks like this image?

Thanks in advance friends. All ideas are appreciated.

解决方案

It depends a lot on what do you define by "duplicate".

If you are looking for absolutely identical copies (copy-paste), the game is simple. The approach proposed by Safir, with just a few performance improvements, is Ok.

If you want to find almost-exact duplicates, the job suddenly becomes incredibly difficult. Check out this Checking images for similarity with OpenCV for more info.

Now, back to the "simple" approach, it depends on how many pictures you have to compare. Because comparing each image against all the others in a folder with 1000 images gives you 1.000.000 image reads and comparisons. (Because you cannot store them all in RAM at once, you will have to load and unload them a million times) That way is too much for even a powerful desktop processor.

A simple way would be to use a hashing function (as sha2) for each image, and then compare just the hashes. A good ad-hoc "hashing" for images may be the histogram (although for positives you may want to double-check with memcmp).

And even if you try the brute-force approach (comparing each image pixel with the other), a faster way is to use memcmp() instead of accessing images pixel by pixel.

这篇关于我们可以检查列表中是否存在重复的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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