简单快速的方法来比较图像的相似性 [英] Simple and fast method to compare images for similarity

查看:279
本文介绍了简单快速的方法来比较图像的相似性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个简单而快速的方法来比较两个图像的相似性。也就是说我想得到一个高价值,如果他们包含完全相同的事情,但可能有一些略有不同的背景,可以移动/调整大小几个像素。

I need a simple and fast way to compare two images for similarity. I.e. I want to get a high value if they contain exactly the same thing but may have some slightly different background and may be moved / resized by a few pixel.

,如果这是重要的:一张图片是一个图标,另一张图片是屏幕截图的子区域,我想知道该子区域是否是图标。)

(More concrete, if that matters: The one picture is an icon and the other picture is a subarea of a screenshot and I want to know if that subarea is exactly the icon or not.)

我手上有 OpenCV ,但我还是不习惯。

I have OpenCV at hand but I am still not that used to it.

我想到的一个可能性是:转换成10x10个细胞,并且对于那些100个细胞中的每一个,比较颜色直方图。然后我可以设置一些补偿阈值,如果我获得的值高于该阈值,我假设他们是类似的。

One possibility I thought about so far: Divide both pictures into 10x10 cells and for each of those 100 cells, compare the color histogram. Then I can set some made up threshold value and if the value I get is above that threshold, I assume that they are similar.

我还没有尝试它如何好,但工作,但我猜它会是好的。图像已经非常相似(在我的用例),所以我可以使用一个相当高的阈值。

I haven't tried it yet how well that works but I guess it would be good enough. The images are already pretty much similar (in my use case), so I can use a pretty high threshold value.

我想有很多其他可能的解决方案这将工作或多或少(因为任务本身很简单,因为我只想检测相似性,如果他们真的非常相似)。您会建议什么?

I guess there are dozens of other possible solutions for this which would work more or less (as the task itself is quite simple as I only want to detect similarity if they are really very similar). What would you suggest?

有一些非常相关/类似的问题, image:

There are a few very related / similar questions about obtaining a signature/fingerprint/hash from an image:

  • OpenCV / SURF How to generate a image hash / fingerprint / signature out of the descriptors?
  • Image fingerprint to compare similarity of many images
  • Near-Duplicate Image Detection
  • OpenCV: Fingerprint Image and Compare Against Database.

此外,我偶然发现这些具有这样功能的实现可以获得指纹:

Also, I stumbled upon these implementations which have such functions to obtain a fingerprint:

  • pHash
  • imgSeek (GitHub repo) (GPL) based on the paper Fast Multiresolution Image Querying
  • image-match. Very similar to what I was searching for. Similar to pHash, based on An image signature for any kind of image, Goldberg et al. Uses Python and Elasticsearch.

有一点offtopic:指纹。 MusicBrainz 是一项提供基于指纹的歌曲查找的网络服务,具有在他们的wiki 。他们现在使用 AcoustID 。这是为了找到精确(或大部分精确)匹配。要查找类似的匹配项(如果您只有一些代码段或高噪声),请查看 Echoprint 。相关的SO问题是此处。所以看来这是解决音频。所有这些解决方案都工作得相当不错。

A bit offtopic: There exists many methods to create audio fingerprints. MusicBrainz, a web-service which provides fingerprint-based lookup for songs, has a good overview in their wiki. They are using AcoustID now. This is for finding exact (or mostly exact) matches. For finding similar matches (or if you only have some snippets or high noise), take a look at Echoprint. A related SO question is here. So it seems like this is solved for audio. All these solutions work quite good.

有关模糊搜索的一个更通用的问题一般是这里。例如。有位置敏感散列最近邻搜索

A somewhat more generic question about fuzzy search in general is here. E.g. there is locality-sensitive hashing and nearest neighbor search.

推荐答案

可以对屏幕截图或图标进行转换..)?在我的头上有很多方法可以帮助你:

Can the screenshot or icon be transformed (scaled, rotated, skewed ...)? There are quite a few methods on top of my head that could possibly help you:


  • 简单欧几里德距离由@carlosdc提及(不能使用转换的图片,您需要一个阈值)。

  • (规范化)交叉相关 - 可用于比较图像区域的简单指标。

  • 直方图比较 - 如果您使用归一化直方图,这种方法工作得很好,不受仿射变换的影响。问题是确定正确的阈值。它也对颜色变化(亮度,对比度等)非常敏感。您可以将其与前两个组合。

  • 显着点/区域的检测器 - 例如 MSER(最大稳定极值区) SURF SIFT 。这些是非常鲁棒的算法,它们可能太复杂,为您的简单任务。好的事情是,你不必有一个精确的区域只有一个图标,这些探测器足够强大,找到正确的匹配。在本文中对这些方法进行了不错的评估:局部不变特征检测器:调查

  • Simple euclidean distance as mentioned by @carlosdc (doesn't work with transformed images and you need a threshold).
  • (Normalized) Cross Correlation - a simple metrics which you can use for comparison of image areas. It's more robust than the simple euclidean distance but doesn't work on transformed images and you will again need a threshold.
  • Histogram comparison - if you use normalized histograms, this method works well and is not affected by affine transforms. The problem is determining the correct threshold. It is also very sensitive to color changes (brightness, contrast etc.). You can combine it with the previous two.
  • Detectors of salient points/areas - such as MSER (Maximally Stable Extremal Regions), SURF or SIFT. These are very robust algorithms and they might be too complicated for your simple task. Good thing is that you do not have to have an exact area with only one icon, these detectors are powerful enough to find the right match. A nice evaluation of these methods is in this paper: Local invariant feature detectors: a survey.

其中大部分已在OpenCV中实现 - 请参阅cvMatchTemplate方法: http://dasl.mem.drexel.edu/~noahKuntz/openCVTut6.html 。还可以使用显着点/面积检测器 - 请参见 OpenCV功能检测

Most of these are already implemented in OpenCV - see for example the cvMatchTemplate method (uses histogram matching): http://dasl.mem.drexel.edu/~noahKuntz/openCVTut6.html. The salient point/area detectors are also available - see OpenCV Feature Detection.

这篇关于简单快速的方法来比较图像的相似性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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