# Signal Correlation (2D Cross Correlation) (G Dataflow)

Version:

Computes the two-dimensional cross correlation of two sequences.

## X

The first input sequence.

This input can be a 2D array of double-precision, floating-point numbers or a 2D array of complex double-precision, floating-point numbers.

## Y

The second input sequence.

This input can be a 2D array of double-precision, floating-point numbers or a 2D array of complex double-precision, floating-point numbers.

## algorithm

The correlation method to use.

If x and y are small, the direct method typically is faster. If x and y are large, the frequency domain method typically is faster. Additionally, slight numerical differences can exist between the two methods.

Name Description
direct

Computes the cross correlation using the direct method of linear correlation.

frequency domain

Computes the cross correlation using an FFT-based technique.

Default: frequency domain

## error in

Error conditions that occur before this node runs. The node responds to this input according to standard error behavior.

Default: No error

## RXY

The cross correlation of the two input sequences.

## error out

Error information. The node produces this output according to standard error behavior.

## Algorithm for Calculating the 2D Cross Correlation

This node computes two-dimensional cross correlation as follows:

$h\left(i,j\right)=\underset{m=0}{\overset{{M}_{1}-1}{\sum }}\underset{n=0}{\overset{{N}_{1}-1}{\sum }}{x}^{*}\left(m,n\right)\cdot y\left(m-i,n-j\right)$

for i = -(M1-1), ..., -1, 0, 1, ... , (M2-1) and j = -(N1-1), ..., -1, 0, 1, ... , (N2-1)

where

• M1 is the number of rows of matrix X
• N1 is the number of columns of matrix X
• M2 is the number of rows of matrix Y
• N2 is the number of columns of matrix Y

The indexed elements outside the ranges of X and Y are equal to zero, as shown in the following relationships:

$x\left(m,n\right)=0,\text{\hspace{0.17em}}m<0\text{\hspace{0.17em}}\mathrm{or}\text{\hspace{0.17em}}m\ge {M}_{1}\text{\hspace{0.17em}}\mathrm{or}\text{\hspace{0.17em}}n<0\text{\hspace{0.17em}}\mathrm{or}\text{\hspace{0.17em}}n\ge {N}_{1}$

and

$y\left(m,n\right)=0,\text{\hspace{0.17em}}m<0\text{\hspace{0.17em}}\mathrm{or}\text{\hspace{0.17em}}m\ge {M}_{2}\text{\hspace{0.17em}}\mathrm{or}\text{\hspace{0.17em}}n<0\text{\hspace{0.17em}}\mathrm{or}\text{\hspace{0.17em}}n\ge {N}_{2}$

The elements of the output matrix RXY are related to the elements in h as follows:

${R}_{xy}\left(i,j\right)=h\left(i-\left({M}_{1}-1\right),j-\left({N}_{1}-1\right)\right)\text{\hspace{0.17em}}\text{\hspace{0.17em}}\mathrm{for}\text{\hspace{0.17em}}i=0,\text{\hspace{0.17em}}1,\text{\hspace{0.17em}}2,\text{\hspace{0.17em}}...,\text{\hspace{0.17em}}{M}_{1}+{M}_{2}-2\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\mathrm{and}\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{\hspace{0.17em}}j=0,\text{\hspace{0.17em}}1,\text{\hspace{0.17em}}2,\text{\hspace{0.17em}}...,\text{\hspace{0.17em}}{N}_{1}+{N}_{2}-2$

Where This Node Can Run:

Desktop OS: Windows

FPGA: Not supported