检测较大图像中图像的位置 [英] Detect the location of an image within a larger image

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

问题描述

如何在较大的图像中检测图像的位置?我有一个未经修改的图像副本。然后将该图像改变为任意分辨率并随机放置在任意大小的更大图像内。没有对结果图像进行其他变换。 Python代码是理想的,它可能需要 libgd 。如果您知道解决此问题的好方法,您将获得+1。

How do you detect the location of an image within a larger image? I have an unmodified copy of the image. This image is then changed to an arbitrary resolution and placed randomly within a much larger image which is of an arbitrary size. No other transformations are conducted on the resulting image. Python code would be ideal, and it would probably require libgd. If you know of a good approach to this problem you'll get a +1.

推荐答案

有一个快速而肮脏的解决方案,只需在目标图像上滑动窗口并计算一些相似度即可每个位置,然后选择具有最高相似性的位置。然后将相似度与阈值进行比较,如果得分高于阈值,则得出结果图像在那里,那就是位置;如果分数低于阈值,则图像不存在。

There is a quick and dirty solution, and that's simply sliding a window over the target image and computing some measure of similarity at each location, then picking the location with the highest similarity. Then you compare the similarity to a threshold, if the score is above the threshold, you conclude the image is there and that's the location; if the score is below the threshold, then the image isn't there.

作为相似性度量,您可以使用归一化相关或平方差的和(也就是L2范数) )。正如人们所提到的,这不会涉及规模变化。因此,您还要多次重新缩放原始图像,并使用每个缩放版本重复上述过程。根据输入图像的大小和可能的比例范围,这可能已经足够好了,并且很容易实现。

As a similarity measure, you can use normalized correlation or sum of squared differences (aka L2 norm). As people mentioned, this will not deal with scale changes. So you also rescale your original image multiple times and repeat the process above with each scaled version. Depending on the size of your input image and the range of possible scales, this may be good enough, and it's easy to implement.

正确的解决方案是使用仿射不变量。尝试查找宽基线立体匹配,人们在该背景下查看了该问题。使用的方法通常是这样的:

A proper solution is to use affine invariants. Try looking up "wide-baseline stereo matching", people looked at that problem in that context. The methods that are used are generally something like this:


  • 运行兴趣点检测器。这将在图像中找到易于定位的几个点,例如,角落。有许多探测器,一个名为harris-affine的探测器运行良好并且非常受欢迎(因此可能存在实现)。另一个选择是使用高斯差分(DoG)检测器,它是为SIFT开发的,也可以很好地工作。

  • 在每个兴趣点,提取一个小的子图像(例如30x30像素)

  • 对于每个子图像,计算描述符,即该窗口中图像内容的一些表示。同样,存在许多描述符。要查看的内容是描述符描述图像内容的程度(您希望两个描述符仅在它们相似时才匹配)以及它是多么不变(您希望它在缩放后仍然相同)。在您的情况下,我建议使用SIFT。它不像其他描述符那样不变,但可以很好地应对规模,在你的情况下,规模是唯一改变的。

在这个阶段结束时,你将拥有一组描述符。

At the end of this stage, you will have a set of descriptors.


  • 首先,您运行与步骤1中相同的兴趣点检测器,并获得一组兴趣点。如上所述,您为每个点计算相同的描述符。现在,您还有一组目标图像的描述符。

  • 接下来,您将查找匹配项。理想情况下,对于原始图像中的每个描述符,目标图像中将存在一些非常相似的描述符。 (由于目标图像较大,也会有剩余描述符,即与原始图像中的任何内容都不对应的点。)因此,如果足够的原始描述符与足够的相似性匹配,那么您就知道目标是那里。此外,由于描述符是特定于位置的,因此您还将知道原始图像在目标图像中的位置。

这篇关于检测较大图像中图像的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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