2.11.6 corr2(Pro)

Menu Information

Analysis: Signal Processing: 2D Correlation

Brief Information

Compute correlation of two matrices

Additional Information

This feature is for OriginPro only.

Command Line Usage

1. corr2 im1:=Mat(1) im2:=Mat(2);

2. corr2 im1:=Mat(1) im2:=Mat(2) norm:=1;

3. corr2 im1:=Mat(1) im2:=Mat(2) algorithm:=circular;

4. corr2 im1:=Mat(1) im2:=Mat(2) method:=shift;

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Input Matrix im1

Input

MatrixObject

<unassigned>

Specifies the matrix that has the first input 2D signal.

Input Matrix im2

Input

MatrixObject

<unassigned>

Specifies the matrix that has the second input 2D signal. To calculate autocorrelation, use the same matrix as the first input signal (im1).

Method method

Input

int

fft

Specifies the method for calculating 2D correlation.

Option list

  • fft:FFT
    This method is faster but less accurate than Shift accumulation method. It is usually used for large data.
  • shift:Shift Accumulate
    This method computes the correlation using its mathematic definition. It is more accurate, but could be much slower for large data.
Algorithm algorithm

Input

int

linear

Specifies whether compute linear correlation or circular correlation.

Option list

  • linear:Linear
    Linear correlation will be performed. Data points outside the input range will be viewed as zero.
  • circular:Circular
    Circular correlation will be performed. Data points outside the input range will be viewed as repetition of the input data points.
Normalize Result norm

Input

int

0

Specifies whether or not the result should be normalized.

Correlation Result om

Output

MatrixObject

[<new>]<new>!

Specifies the output matrix.

See the syntax here.

Description

2D Correlation is usually used to detect similarities between two 2D signals, which are often saved in matrices. The 2D correlation of two matrices, a and b, can be defined as follows:
Corr2 help English files image002.gif

The 2D Correlation can be linear or circular. For linear correlation, any indexed elements that lie outside the original range are treated as zeros. Correspondingly, for circular correlation, they are viewed as the repetition of elements within the original range. The size of the linear correlation result matrix is as follows:
Corr2 help English files image004.jpg
where M and N are the greater width and height of the two matrices respectively. Conversely, if computing a circular correlation, the size of the matrix should be
Corr2 help English files image006.jpg
Conventionally, the linear correlation should be used when the input signals contain impulses, while the circular correlation should be used when the signals can be viewed as periodic.

The magnitude of the correlation shows how similar the signals are. If the correlation is large, the two signals are considered to be very similar. Alternatively, if correlation is zero, the two signals are considered to be independent.

Examples

1. To compute the linear correlation of signals in the 1st sheet and the 2nd sheet of a matrix named MBookSignals, use the following script command:

corr2 im1:=[MBookSignals]1!1 im2:= [MBookSignals]2!1

2. To change the method of 2D correlation, open the corr2 dialog and select the option by typing:

corr2 -d

3. To perform a 2D correlation to data using a pre-saved smoothing theme file, save your preferences in the corr2 dialog, and then execute it by typing the following script command, using your own saved-theme title:

corr2 -t "my two-d corelation theme.oth"

Algorithm

For more information, please refer to our User Guide.

Related X-Functions

conv, fft1, ifft1


Keywords:fourier, fft, linear, circular