检查图像与 OpenCV 的相似性 [英] Checking images for similarity with OpenCV

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

问题描述

OpenCV 是否支持比较两个图像,返回一些值(可能是一个百分比)来表明这些图像的相似程度?例如.同一张图片经过两次返回100%,完全不同图片返回0%.

Does OpenCV support the comparison of two images, returning some value (maybe a percentage) that indicates how similar these images are? E.g. 100% would be returned if the same image was passed twice, 0% would be returned if the images were totally different.

我已经在 StackOverflow 上阅读了很多类似的主题.我也做了一些谷歌搜索.遗憾的是,我无法想出一个令人满意的答案.

I already read a lot of similar topics here on StackOverflow. I also did quite some Googling. Sadly I couldn't come up with a satisfying answer.

推荐答案

这是一个巨大的话题,从 3 行代码到整个研究杂志都有答案.

This is a huge topic, with answers from 3 lines of code to entire research magazines.

我将概述最常见的此类技术及其结果.

I will outline the most common such techniques and their results.

最简单的 & 之一最快的方法.几十年前提出作为寻找图片相似性的一种手段.这个想法是森林会有很多绿色,人脸会有很多粉红色,或者其他什么.因此,如果您将两张图片与森林进行比较,您会发现直方图之间有一些相似之处,因为两者都有很多绿色.

One of the simplest & fastest methods. Proposed decades ago as a means to find picture simmilarities. The idea is that a forest will have a lot of green, and a human face a lot of pink, or whatever. So, if you compare two pictures with forests, you'll get some simmilarity between histograms, because you have a lot of green in both.

缺点:太简单了.香蕉和海滩看起来一样,因为两者都是黄色的.

Downside: it is too simplistic. A banana and a beach will look the same, as both are yellow.

OpenCV 方法:compareHist()

OpenCV method: compareHist()

模板匹配

这里有一个很好的例子matchTemplate 找到好的匹配.它将搜索图像与被搜索的图像进行卷积.它通常用于在较大的图像中找到较小的图像部分.

Template matching

A good example here matchTemplate finding good match. It convolves the search image with the one being search into. It is usually used to find smaller image parts in a bigger one.

缺点:它只会在相同的图像、相同的大小和相同的情况下返回良好的结果.方向.

Downsides: It only returns good results with identical images, same size & orientation.

OpenCV 方法:matchTemplate()

OpenCV method: matchTemplate()

特征匹配

认为是进行图像搜索的最有效方法之一.从图像中提取了许多特征,以确保即使在旋转、缩放或倾斜时也能再次识别相同的特征.以这种方式提取的特征可以与其他图像特征集进行匹配.与第一个特征匹配的特征比例高的另一个图像被认为描绘了相同的场景.

Feature matching

Considered one of the most efficient ways to do image search. A number of features are extracted from an image, in a way that guarantees the same features will be recognized again even when rotated, scaled or skewed. The features extracted this way can be matched against other image feature sets. Another image that has a high proportion of the features matching the first one is considered to be depicting the same scene.

找到两组点之间的单应性,还可以找到原始图片之间拍摄角度或重叠量的相对差异.

Finding the homography between the two sets of points will allow you to also find the relative difference in shooting angle between the original pictures or the amount of overlapping.

有许多关于此的 OpenCV 教程/示例,还有一个不错的视频这里.一个完整的 OpenCV 模块(features2d)专门用于它.

There are a number of OpenCV tutorials/samples on this, and a nice video here. A whole OpenCV module (features2d) is dedicated to it.

缺点:它可能很慢.它并不完美.

Downsides: It may be slow. It is not perfect.


关于 OpenCV Q&A 网站我说的是特征描述符之间的区别,这在比较整个图像和纹理描述符时非常有用,纹理描述符用于识别图像中的人脸或汽车等对象.


Over on the OpenCV Q&A site I am talking about the difference between feature descriptors, which are great when comparing whole images and texture descriptors, which are used to identify objects like human faces or cars in an image.

这篇关于检查图像与 OpenCV 的相似性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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