Ask Your Question

Revision history [back]

In principle matchTemplate does not incorporate scale invariance. But you can introduce it yourself.

  • Start from your original image
  • Apply a couple of pyrUp and a couple of pyrDown, creating a scale pyramid
  • Now run matchTemplate with a fixed template on all images, be sure to use TM_SQDIFF_NORM <-- the normalized is important here
  • Now for each scale take best match, store it in vector.
  • Then over all best matches in vector take strongest one (so with the smallest difference).

Good luck!

In principle matchTemplate does not incorporate scale invariance. But you can introduce it yourself.

  • Start from your original image
  • Apply a couple of pyrUp and a couple of pyrDown, creating a scale pyramid
  • Now run matchTemplate with a fixed template on all images, be sure to use TM_SQDIFF_NORM <-- the normalized is important here
  • Now for each scale take best match, store it in vector.
  • Then over all best matches in vector take strongest one (so with the smallest difference).

Also about being an exact part of original image: NO it does not. The sample is made that way and confuses people, but in general, in an application the template is NOT related to the image where you apply it.

Good luck!