0

As i understand template matching finds areas of an image that match (are similar) to a template image (patch) according to this

So i have two images of different dimension. And when i am trying to match my template image with the source image it usually marks the wrong area in the image.

Source Image

enter image description here

Template image

enter image description here

Output image

enter image description here

It works fine with threshold value if the images are of same dimension. What needs to be done to overcome this problem?? Or can i use template matching in this scenario??

Fay007
  • 2,707
  • 3
  • 28
  • 58
  • Exactly because they have different dimensions. Template matching is **not** scale (nor rotation) invariant. Try features matching in this case. – Miki Nov 27 '15 at 09:00
  • try http://www.pyimagesearch.com/2015/01/26/multi-scale-template-matching-using-python-opencv/ and in addition just for the future: template matching isn't rotation invariant either. – Micka Nov 27 '15 at 11:10
  • do u know any example of feature matching in java?? and also any theory on basis of what this algorithm works @Miki – Fay007 Nov 27 '15 at 12:50
  • @Fay007 check for example [this](http://stackoverflow.com/questions/17898480/object-detection-with-opencv-feature-matching-with-a-threshold-similarity-score). Or [here](http://docs.opencv.org/2.4/doc/tutorials/features2d/feature_homography/feature_homography.html). [Here](http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_feature2d/py_features_meaning/py_features_meaning.html#features-meaning) some basic concepts. Google for more :D – Miki Nov 27 '15 at 12:57
  • i have already gone through them :P @Miki – Fay007 Nov 27 '15 at 12:59
  • Then you're on the right path. Just follow it :D – Miki Nov 27 '15 at 13:01
  • @Micka i am gonna look into it!! but how thats gonna help me?? just explain to me is that blog is related to my problem ?? – Fay007 Nov 27 '15 at 13:04
  • it shows how to make the matchTemplate function scale invariant by calling it iteratively for multiple scales. – Micka Nov 27 '15 at 13:07
  • so u are suggesting me to change the scale of the captured image into the template image scale ?? @Micka – Fay007 Nov 27 '15 at 13:10
  • basically yes. This could be a possible solution. But might be very slow because you have to resize the image many times because you don't know the final scale. – Micka Nov 27 '15 at 14:04

0 Answers0