Normalized 2-D cross-correlation
normxcorr2
uses the following general procedure [1], [2]:
Calculate cross-correlation in the spatial or the frequency domain, depending on size of images.
Calculate local sums by precomputing running sums [1].
Use local sums to normalize the cross-correlation to get correlation coefficients.
The implementation closely follows the formula from [1]:
where
is the image.
is the mean of the template
is the mean of in the region under the template.
[2] Haralick, Robert M., and Linda G. Shapiro, Computer and Robot Vision, Volume II, Addison-Wesley, 1992, pp. 316-317.