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]:

$$\gamma (u,v)=\frac{{\displaystyle {\sum}_{x,y}\left[f\left(x,y\right)-{\overline{f}}_{u,v}\right]\left[t\left(x-u,y-v\right)-\overline{t}\right]}}{{\left\{{{\displaystyle {\sum}_{x,y}\left[f\left(x,y\right)-{\overline{f}}_{u,v}\right]}}^{2}{\displaystyle {\sum}_{x,y}{\left[t(x-u,y-v)-\overline{t}\right]}^{2}}\right\}}^{0.5}}$$

where

$$f$$ is the image.

$$\overline{t}$$ is the mean of the template

$${\overline{f}}_{u,v}$$ is the mean of $$f(x,y)$$ 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.