Template matching based on normalized-cross-correlation (NCC) algorithm uses the minimization of squared Euclidean distance at position
to find best matching between a reference object (with dimension
)
and a region in an image at position
.
The Euclidean distance is minimized, when the linear cross correlation coefficient
between the reference object and image region
is maximized. To account for intensity
variations in the image and make the correlation coefficient invariant to pixel intensities, the correlation between the
difference of object
to the mean value
and
image region
to the mean value
is calculated.
According to [Bur06] the so called normalized-cross correlation coefficient can then be expressed as:
with
The result of is between -1 and 1. The higher the accordance between reference image and image region is, the higher is result of . The position in image with highest value of , is the location where the reference object is found.