Open CV 中的 2D 子图像检测

发布于 2024-10-10 07:34:18 字数 384 浏览 0 评论 0原文

对于以下问题,使用 OpenCV 的最明智的算法或算法组合是什么:

  • 我有一组小型 2D 图像。我想检测这些子图像在较大图像中的位置。
  • 子图像通常约为 32x32 像素,较大图像约为 400x400。
  • 子图像并不总是正方形,并且包含 Alpha 通道。
  • 可选 - 较大的图像可能是颗粒状的、压缩的、3D 旋转的或其他轻微扭曲的。

我尝试过 cvMatchTemplate,结果非常差(很难正确匹配,并且使用所有匹配方法都会出现大量误报)。一些问题来自 OpenCV 似乎无法处理 alpha 通道模板匹配这一事实。

我尝试过手动搜索,似乎效果更好,并且可以包含 Alpha 通道,但速度很慢。

感谢您的任何帮助。

What's the most sensible algorithm, or combination of algorithms, to be using from OpenCV for the following problem:

  • I have a set of small 2D images. I want to detect the locations of these subimages in a larger image.
  • The subimages are usually around 32x32 pixels, and the larger image is around 400x400.
  • The subimages are not always square, and such contains alpha channel.
  • Optionally - the larger image may be grainy, compressed, rotated in 3D, or otherwise slightly distorted

I have tried cvMatchTemplate, with very poor results (difficult to match correctly, and large numbers of false positives, with all match methods). Some of the problems come from the fact OpenCV can't seem to deal with alpha channel template matching.

I have tried a manual search, which seems to work better, and can include the alpha channel, but is very slow.

Thanks for any help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

〆凄凉。 2024-10-17 07:34:18
  1. cvMatchTemplate 使用 MSE (SQDIFF/SQDIFF_NORMED) 类型的度量进行匹配。这种度量将严重惩罚不同的 alpha 值(由于方程中的平方)。您尝试过标准化互相关吗?众所周知,可以更好地模拟像素强度的线性变化。
  2. 如果 NCC 不能完成这项工作,您将需要将图像转换到强度差异不会产生太大影响的空间。例如,计算边缘强度图像(canny、sobel 等)并在这些图像上运行 cvMatchTemplate。
  3. 考虑到图像比例的巨大差异(~10x)。必须采用图像金字塔来找出匹配的正确比例。建议您从一个比例开始(2^1/x:x 是正确的比例)并将估计值沿金字塔向上传播。
  1. cvMatchTemplate uses a MSE (SQDIFF/SQDIFF_NORMED) kind of metric for the matching. This kind of metric will penalize different alpha values severly (due to the square in the equation). Have you tried normalized cross-correlation? It is known to model linear variations in pixel intensities better.
  2. If NCC does not do the job, you will need to transform the images to a space where the intensity differences do not have much effect. e.g. Compute a edge-strength image (canny, sobel etc) and run cvMatchTemplate on these images.
  3. Considering the large difference in scales of the images (~10x). A image pyramid will have to be employed to figure out the correct scale for the matching. Recommend you start with a scale (2^1/x: x being the correct scale) and propagate the estimate up the pyramid.
〃安静 2024-10-17 07:34:18

您需要的是 SIFT 或 SURF 之类的东西。

What you need is something like SIFT or SURF.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文