2D subimage detection in Open CV

谁说我不能喝 提交于 2019-12-30 02:16:05

问题


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.


回答1:


  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.



回答2:


What you need is something like SIFT or SURF.



来源:https://stackoverflow.com/questions/4569993/2d-subimage-detection-in-open-cv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!