<< wrev | FOSSEE_Signal_Processing_Toolbox | yulewalker >>

FOSSEE_Signal_Processing_Toolbox >> FOSSEE_Signal_Processing_Toolbox > xcorr2

# xcorr2

Compute the 2D cross-correlation of matrices.

### Syntax

    c = xcorr2(a)
    c = xcorr2(a, b)
    c = xcorr2(a, b, scale)

### Parameters

a:

  Input matrix (2D array).

b:

  (optional) Input matrix (2D array). If not specified, computes the autocorrelation of `a`.

scale:

  (optional) String specifying the type of scaling applied to the cross-correlation matrix. Possible values are:

- "none" (default):

  No scaling.

- "biased":

  Scales the raw cross-correlation by the maximum number of elements of `a` and `b` involved in the generation of any element of `c`.

- "unbiased":

  Scales the raw correlation by dividing each element in the cross-correlation matrix by the number of products `a` and `b` used to generate that element.

- "coeff":

  Scales the normalized cross-correlation on the range of [0, 1] so that a value of 1 corresponds to a correlation coefficient of 1.

c:

  Cross-correlation matrix.

### Description

The `xcorr2` function computes the 2D cross-correlation of matrices `a` and `b`. If `b` is not specified, it computes the autocorrelation of `a`. The optional `scale` parameter allows for different types of scaling to be applied to the cross-correlation matrix.

### Examples

    // Compute the 2D cross-correlation of two matrices:
    a = [1, 2; 3, 4]
    b = [0, 1; 1, 0]
    c = xcorr2(a, b)

Report an issue
<< wrev | FOSSEE_Signal_Processing_Toolbox | yulewalker >>