Computes the cross correlation of the input sequences X and Y. Wire data to the X and Y inputs to determine the polymorphic instance to use or manually select the instance.


icon

1D Cross Correlation

The cross correlation Rxy(t) of the sequences x(t) and y(t) is defined by the following equation:

where the symbol ⊗ denotes correlation.

The discrete implementation of the CrossCorrelation VI is as follows. Let h represent a sequence whose indexing can be negative, let N be the number of elements in the input sequence X, let M be the number of elements in the sequence Y, and assume that the indexed elements of X and Y that lie outside their range are equal to zero, as shown by the following equations:

xj = 0, j < 0 or jN

and

yj = 0, j < 0 or jM.

Then the CrossCorrelation VI obtains the elements of h using the following equation:

for j = –(N–1), –(N–2), … , –1, 0, 1, … , (M–2), (M–1)

The elements of the output sequence Rxy are related to the elements in the sequence h by

Rxyi = hi – (N–1)

for i = 0, 1, 2, … , N+M–2.

Because you cannot index LabVIEW arrays with negative numbers, the corresponding cross correlation value at t = 0 is the Nth element of the output sequence Rxy. Therefore, Rxy represents the correlation values that the CrossCorrelation VI shifts N times in indexing.

The following block diagram shows one way to index the CrossCorrelation VI.

The following graph is the result of the preceding block diagram.

In order to make the cross correlation calculation more accurate, normalization is required in some situations. This VI provides biased and unbiased normalization.

  1. Biased normalization

    If the normalization is biased, LabVIEW applies biased normalization as follows:

    Rxy(biased)j =

    for j = 0, 1, 2, … , M+N–2

    where Rxy is the cross correlation between x and y with no normalization.

  2. Unbiased normalization

    If the normalization is unbiased, LabVIEW applies unbiased normalization as follows:

    Rxy(unbiased)j =

    for j = 0, 1, 2, … , M+N–2

    where Rxy is the cross correlation between x and y with no normalization. f(j) is:

2D Cross Correlation

The CrossCorrelation VI computes two-dimensional cross correlation as follows:

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(m,n) = 0, m < 0 or mM1 or n < 0 or nN1

and

y(m,n) = 0, m < 0 or mM2 or n < 0 or nN2.

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

Rxy(I,j) = h(i–(M1–1), j–(N1–1)) for i = 0, 1, 2, … , M1+M2–2 and j = 0, 1, 2, … , N1+N2–2.