Ask Your Question

template matching in multiple images

asked 2013-03-29 06:27:05 -0600

Aditya gravatar image

How can i Access result from matchTemplate(InputArray image, InputArray templ, OutputArray result, int method) ???

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-03-29 06:52:15 -0600

updated 2013-03-29 06:59:00 -0600

Looking at the description of the actual method:

void matchTemplate(InputArray image, InputArray templ, OutputArray result, int method)

It states that the results are stored in a comparison results map.

Beneath the explanation you can find this text:

After the function finishes the comparison, the best matches can be found as global minimums (when CV_TM_SQDIFF was used) or maximums (when CV_TM_CCORR or CV_TM_CCOEFF was used) using the minMaxLoc() function. In case of a color image, template summation in the numerator and each sum in the denominator is done over all of the channels and separate mean values are used for each channel. That is, the function can take a color template and a color image. The result will still be a single-channel image, which is easier to analyze.

So basically try to find global maxima in the output map. This means you need to go over your output matrix and look for maximal values.


--> go read tutorial on template matching, it is all explained there:

edit flag offensive delete link more


And how am i supposed to do that ??? Sorry for asking such question, but i am new to this :( And thanx for replying.

Aditya gravatar imageAditya ( 2013-03-29 06:55:42 -0600 )edit

Look at my addition and except answers if they serve you well :)

StevenPuttemans gravatar imageStevenPuttemans ( 2013-03-29 06:59:38 -0600 )edit

Question Tools


Asked: 2013-03-29 06:27:05 -0600

Seen: 1,225 times

Last updated: Mar 29 '13