查找相似图像的算法
我需要一种算法来确定两个图像是否“相似”并识别相似的颜色、亮度、形状等模式。我可能需要一些关于人脑使用哪些参数来“分类”图像的指示。 ..
我研究过基于 hausdorff 的匹配,但这似乎主要用于匹配变换后的对象和形状模式。
I need an algorithm that can determine whether two images are 'similar' and recognizes similar patterns of color, brightness, shape etc.. I might need some pointers as to what parameters the human brain uses to 'categorize' images. ..
I have looked at hausdorff based matching but that seems mainly for matching transformed objects and patterns of shape.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(15)
我做了类似的事情,通过使用 小波变换 将图像分解为签名。
我的方法是从每个变换通道中选取最重要的 n 系数,并记录它们的位置。 这是通过根据 abs(power) 对 (power,location) 元组列表进行排序来完成的。 相似的图像将具有相似之处,因为它们在相同的位置具有显着的系数。
我发现最好将图像转换为 YUV 格式,这可以有效地允许您对形状(Y 通道)和颜色(UV 通道)的相似性进行加权。
您可以在 mactorii 中找到我对上述内容的实现,不幸的是我还没有一直在研究它我应该有的:-)
另一种方法,我的一些朋友使用过,效果出奇的好,就是简单地调整你的图像大小,比如 4x4 像素,并将其存储为你的签名。 可以通过计算两幅图像之间的曼哈顿距离来对两幅图像的相似程度进行评分,使用相应的像素。 我不知道他们如何执行调整大小的详细信息,因此您可能必须使用可用于该任务的各种算法才能找到合适的算法。
I have done something similar, by decomposing images into signatures using wavelet transform.
My approach was to pick the most significant n coefficients from each transformed channel, and recording their location. This was done by sorting the list of (power,location) tuples according to abs(power). Similar images will share similarities in that they will have significant coefficients in the same places.
I found it was best to transform in the image into YUV format, which effectively allows you weight similarity in shape (Y channel) and colour (UV channels).
You can in find my implementation of the above in mactorii, which unfortunately I haven't been working on as much as I should have :-)
Another method, which some friends of mine have used with surprisingly good results, is to simply resize your image down to say, a 4x4 pixel and store that as your signature. How similar 2 images are can be scored by say, computing the Manhattan distance between the 2 images, using corresponding pixels. I don't have the details of how they performed the resizing, so you may have to play with the various algorithms available for that task to find one which is suitable.
pHash 您可能感兴趣。
pHash might interest you.
我使用 SIFT 重新检测不同图像中的同一对象。 它确实很强大,但相当复杂,而且可能有点矫枉过正。 如果图像应该非常相似,那么基于两个图像之间差异的一些简单参数可以告诉您很多信息。 一些提示:
I've used SIFT to re-detect te same object in different images. It is really powerfull but rather complex, and might be overkill. If the images are supposed to be pretty similar some simple parameters based on the difference between the two images can tell you quite a bit. Some pointers:
我的实验室也需要解决这个问题,我们使用了 Tensorflow。 这是一个用于可视化图像相似性的完整应用实现。
有关矢量化图像以进行相似性计算的教程,请查看此页面。 这是 Python(再次,请参阅帖子以了解完整的工作流程):
My lab needed to solve this problem as well, and we used Tensorflow. Here's a full app implementation for visualizing image similarity.
For a tutorial on vectorizing images for similarity computation, check out this page. Here's the Python (again, see the post for full workflow):
您可以使用 Perceptual Image Diff
它是一个命令行实用程序,使用感知指标比较两个图像。 也就是说,它使用人类视觉系统的计算模型来确定两个图像在视觉上是否不同,因此忽略像素的微小变化。 此外,它还大大减少了因随机数生成、操作系统或机器架构差异而导致的误报数量。
You could use Perceptual Image Diff
It's a command line utility that compares two images using a perceptual metric. That is, it uses a computational model of the human visual system to determine if two images are visually different, so minor changes in pixels are ignored. Plus, it drastically reduces the number of false positives caused by differences in random number generation, OS or machine architecture differences.
这是一个难题! 这取决于您需要的准确度,也取决于您正在处理的图像类型。 您可以使用直方图来比较颜色,但这显然没有考虑这些颜色在图像(即形状)内的空间分布。 边缘检测后进行某种分割(即挑选形状)可以提供用于与另一图像匹配的模式。 您可以使用共生矩阵来比较纹理,方法是将图像视为像素值矩阵,然后比较这些矩阵。 有一些关于图像匹配和机器视觉的好书——在亚马逊上搜索就能找到一些。
希望这可以帮助!
It's a difficult problem! It depends on how accurate you need to be, and it depends on what kind of images you are working with. You can use histograms to compare colours, but that obviously doesn't take into account the spatial distribution of those colours within the images (i.e. the shapes). Edge detection followed by some kind of segmentation (i.e. picking out the shapes) can provide a pattern for matching against another image. You can use coocurence matrices to compare textures, by considering the images as matrices of pixel values, and comparing those matrices. There are some good books out there on image matching and machine vision -- A search on Amazon will find some.
Hope this helps!
一些图像识别软件解决方案实际上并不是纯粹基于算法,而是利用神经网络概念。 查看 http://en.wikipedia.org/wiki/Artificial_neural_network 以及 NeuronDotNet,它也包括有趣的示例:http://neurondotnet.freehostia.com/index.html
Some image recognition software solutions are actually not purely algorithm-based, but make use of the neural network concept instead. Check out http://en.wikipedia.org/wiki/Artificial_neural_network and namely NeuronDotNet which also includes interesting samples: http://neurondotnet.freehostia.com/index.html
有使用 Kohonen 神经网络/自组织映射的相关研究
要么更具学术性系统(Google for PicSOM),要么更少学术性
( http://www. Generation5.org/content/2004/aiSomPic.asp ,(可能不适合
适用于所有工作环境))存在演示。
There is related research using Kohonen neural networks/self organizing maps
Both more academic systems (Google for PicSOM ) or less academic
( http://www.generation5.org/content/2004/aiSomPic.asp , (possibly not suitable
for all work enviroments)) presentations exist.
计算大幅缩小版本(例如:6x6 像素)的像素颜色值差异的平方和,效果很好。 相同的图像产生 0,相似的图像产生较小的数字,不同的图像产生较大的数字。
上面其他人首先闯入 YUV 的想法听起来很有趣 - 虽然我的想法很有效,但我希望我的图像被计算为“不同”,以便它产生正确的结果 - 即使从色盲观察者的角度来看也是如此。
Calculating the sum of the squares of the differences of the pixel colour values of a drastically scaled-down version (eg: 6x6 pixels) works nicely. Identical images yield 0, similar images yield small numbers, different images yield big ones.
The other guys above's idea to break into YUV first sounds intriguing - while my idea works great, I want my images to be calculated as "different" so that it yields a correct result - even from the perspective of a colourblind observer.
这听起来像是视力问题。 您可能想研究自适应增强以及 Burns 线提取算法。 这两个概念应该有助于解决这个问题。 如果您是视觉算法的新手,边缘检测是一个更简单的起点,因为它解释了基础知识。
至于分类参数:
This sounds like a vision problem. You might want to look into Adaptive Boosting as well as the Burns Line Extraction algorithm. The concepts in these two should help with approaching this problem. Edge detection is an even simpler place to start if you're new to vision algorithms, as it explains the basics.
As far as parameters for categorization:
根据您需要多少准确结果,您可以简单地将图像分解为 nxn 像素块并进行分析。 如果在第一个块中得到不同的结果,则无法停止处理,从而导致一些性能改进。
例如,为了分析方块,您可以获取颜色值的总和。
Depending on how much accurate results you need, you can simply break the images in n x n pixels blocks and analyze them. If you get different results in the first block you can't stop processing, resulting in some performance improvements.
For analyzing the squares you can for example get the sum of the color values.
您可以在两个图像之间执行某种块匹配运动估计,并测量残差和运动矢量成本的总和(就像在视频编码器中所做的那样)。 这将补偿运动; 对于奖励积分,进行仿射变换运动估计(补偿缩放和拉伸等)。 您还可以进行重叠块或光流。
You could perform some sort of block-matching motion estimation between the two images and measure the overall sum of residuals and motion vector costs (much like one would do in a video encoder). This would compensate for motion; for bonus points, do affine-transformation motion estimation (compensates for zooms and stretching and similar). You could also do overlapped blocks or optical flow.
作为第一步,您可以尝试使用颜色直方图。 但是,您确实需要缩小问题范围。 通用图像匹配是一个非常困难的问题。
As a first pass, you can try using color histograms. However, you really need to narrow down your problem domain. Generic image matching is a very hard problem.
很抱歉迟到才加入讨论。
我们甚至可以使用 ORB 方法来检测两幅图像之间的相似特征点。
以下链接给出了在 python 中直接实现 ORB
http://scikit-image.org/ docs/dev/auto_examples/plot_orb.html
甚至 openCV 也直接实现了 ORB。 如果您想了解更多信息,请关注下面给出的研究文章。
https://www.researchgate.net/publication/292157133_Image_Matching_Using_SIFT_SURF_BRIEF_and_OR B_Performance_Comparison_for_Distorted_Images
Apologies for joining late in the discussion.
We can even use ORB methodology to detect similar features points between two images.
Following link gives direct implementation of ORB in python
http://scikit-image.org/docs/dev/auto_examples/plot_orb.html
Even openCV has got direct implementation of ORB. If you more info follow the research article given below.
https://www.researchgate.net/publication/292157133_Image_Matching_Using_SIFT_SURF_BRIEF_and_ORB_Performance_Comparison_for_Distorted_Images
在其他线程中对此有一些很好的答案,但我想知道涉及光谱分析的东西是否有效? 即,将图像分解为相位和幅度信息并进行比较。 这可以避免一些裁剪、变换和强度差异的问题。 不管怎样,这只是我的猜测,因为这似乎是一个有趣的问题。 如果您搜索http://scholar.google.com,我相信您可以找到几篇关于这。
There are some good answers in the other thread on this, but I wonder if something involving a spectral analysis would work? I.e., break the image down to it's phase and amplitude information and compare those. This may avoid some of the issues with cropping, transformation and intensity differences. Anyway, that's just me speculating since this seems like an interesting problem. If you searched http://scholar.google.com I'm sure you could come up with several papers on this.