Compute 2D correlation of two input matrices
Computer Vision Toolbox / Statistics
The 2D Correlation block computes the twodimensional crosscorrelation between two input matrices.
Data Types 

Multidimensional Signals 

VariableSize Signals 

Given two input matrices, I1 and I2, that are size
MbyN and
PbyQ, the 2D crosscorrelation value at the point
(k,l)
is given by
$$C\left(k,l\right)=\text{\hspace{0.17em}}{\displaystyle \sum _{m=0}^{M1}{\displaystyle \sum _{n=0}^{N1}I1\left(m,n\right)\overline{I2}}\left(m+k,n+l\right).}$$
The normalized crosscorrelation value at the point
(k,l)
is calculated as
$$\begin{array}{l}{C}_{N}\left(k,l\right)=\text{\hspace{0.17em}}\frac{{\displaystyle \sum _{m=0}^{M1}{\displaystyle \sum _{n=0}^{N1}I1\left(m,n\right)\overline{I2}}\left(m+k,n+l\right)}}{\sqrt{{\displaystyle \sum _{m=0}^{M1}{\displaystyle \sum _{n=0}^{N1}I1{\left(m,n\right)}^{2}}}}\sqrt{{\displaystyle \sum _{m=0}^{M1}{\displaystyle \sum _{n=0}^{N1}\overline{I2}{\left(m+k,n+l\right)}^{2}}}}}\text{\hspace{0.17em}}\text{\hspace{0.17em}},\text{\hspace{0.17em}}\\ \text{where,}\text{\hspace{0.17em}}\\ 0\le k<M+P1\text{\hspace{0.17em}}\\ 0\le l<N+Q1\end{array}$$
Suppose I1 and I2 are matrices with dimensions (4,3)
and (2,2). The following figure shows how the block computes crosscorrelation value for the
point I1(1,3)
, which refers to the second column and
fourth row in zerobased indexing.
The crosscorrelation value for the point I1(1,3)
is computed using these steps:
Slide the center element of I2 so that it lies on top of the (0,2) element of I1.
Multiply each weight in I2 by the element of I1 underneath.
Sum the individual products from step 2.
The crosscorrelation value for the point I1(1,3)
is $$1\cdot 8+8\cdot 1+15\cdot 6+7\cdot 3+14\cdot 5+16\cdot 7+13\cdot 4+20\cdot 9+22\cdot 2=585$$.
The normalized crosscorrelation value for the point
I1(1,3)
is
$$\frac{585}{\sqrt{{\displaystyle \sum I{1}_{p}^{2}}}\sqrt{{\displaystyle \sum I{2}^{2}}}}\text{\hspace{0.17em}}=\text{\hspace{0.17em}}\mathrm{0.8070.}$$
2D Autocorrelation  2D Histogram  2D Maximum  2D Mean  2D Median  2D Minimum  2D Standard Deviation  2D Variance