查找较大图像内的图像位置
基本上我想找到大图像内小图像的像素位置。 我已经搜索过与此类似的东西,但没有运气。
Basically I want to find the pixel location of a small image inside a large image.
I have searched for something similar to this but have had no luck.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这取决于您希望结果与查询图像匹配的相似程度。如果您尝试匹配不同真实感图像的相应部分,请查看特征检测维基百科页面。您想要使用什么取决于您期望一张图像经历成为另一张图像的转换。
也就是说,如果您正在寻找精确的逐像素匹配,那么暴力搜索可能会很糟糕。对于用于在
n*n
图像中搜索的m*m
图像,这可能是O(m^2*n^2)
。使用更好的算法,可以将其改进为O(n^2)
,与像素数量呈线性关系。对图像进行下采样并进行分层搜索可能是一个好方法。It depends on how similar you want the result to match your query image. If you're trying to match corresponding parts of different photorealistic images, take a look at the Feature detection Wikipedia page. What you want to use depends on the transformation you expect one image to undergo to become the other.
That said, if you are looking for an exact pixel-by-pixel match, a brute-force search is probably bad. That can be
O(m^2*n^2)
for anm*m
image used to search within ann*n
image. Using better algorithms, it can be improved toO(n^2)
, linear in the number of pixels. Downsampling both images and doing a hierarchical kind of search might be a good approach.您可能可以使用 AForge Framework 来执行类似的操作。它提供了多种图像处理工具。也许您可以使用它们的斑点提取来提取斑点,然后将这些斑点与您存储的图像进行比较,看看它们是否匹配。
You could probably use the AForge Framework to do something like this. It offers a variety of image processing tools. Possibly you could use their blob extraction to extracts blobs then compare those blobs to a stored image you have and see if they match.
如果图像逐像素相等,则可以首先搜索与小图像中的像素 (0,0) 颜色相同的一个像素。找到后,比较小图像将覆盖的区域中的每个像素。如果没有差异,您就找到了自己的位置。否则,通过搜索下一个像素匹配 (0,0) 重新开始。
If the images are pixel-by-pixel equal, you could start by searching for one pixel that has the same color as pixel (0,0) in the small image. Once found, compare each pixel in the area that would be covered by the small image. If there are no differences you found your position. Else start over by searching for the next pixel matching (0,0).
如果您处理像素,Booyer-Moore 搜索听起来像是一个解决方案作为字符并且正在寻找完全匹配。也比每像素搜索快得多。
Booyer-Moore search sounds like a solution here if you treat your pixels as characters and are looking for an exact match. Much faster than per pixel searching as well.