MATLAB File Help: cv.matchTemplate Index
cv.matchTemplate

Compares a template against overlapped image regions

result = cv.matchTemplate(image, tmpl)
result = cv.matchTemplate(image, tmpl, 'OptionName', optionValue, ...)

Input

Output

Options

The function slides through image, compares the overlapped patches of size w x h against templ using the specified method and stores the comparison results in result.

Here are the formulae for the available comparison methods (I denotes image, T template, R result). The summation is done over template and/or the image patch: x'=0..w-1, y'=0..h-1:

After the function finishes the comparison, the best matches can be found as global minimums (when 'SqDiff' was used) or maximums (when 'CCorr' or 'CCoeff' was used) using the min and max functions. 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.

See also