Compute the normalized cross-correlation of template and img.
Both template and img must be real, grayscale 2-D images (row and column vectors are accepted as 2-D), and template must not be larger than img in any dimension. The template mean is subtracted before correlation, so a constant (zero-variance) template is rejected.
The result is the same size as a "full" 2-D convolution, that is
size (img) + size (template) - 1. Each value is the
correlation coefficient for the corresponding alignment, normalized to
the range [-1, 1]; locations where the local window is (near) flat
are set to 0. Values in the border region, where template only
partially overlaps img, are defined but not physically meaningful.
The optional logical argument use_fft selects the implementation.
When true, the correlation and local sums are computed via the FFT; when
false, they are computed in the spatial domain with conv2. Both
paths produce equivalent results. If omitted, an FFT is used when the
template has more than 500 elements.
See also: conv2, xcorr2, fft2.
Package: image