corr2

2-D correlation coefficient

Description

example

R = corr2(A,B) returns the 2-D correlation coefficient R between arrays A and B.

You optionally can compute the correlation coefficient using a GPU (requires Parallel Computing Toolbox™).

Examples

collapse all

Compute the correlation coefficient between an image and the same image processed with a median filter.

I = imread('pout.tif');
J = medfilt2(I);
R = corr2(I,J)
R = 0.9959

Input Arguments

collapse all

First input array, specified as a numeric or logical array.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Second input array, specified as a numeric or logical array. B has the same size as the first input array, A.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Output Arguments

collapse all

Correlation coefficient, returned as a numeric scalar.

Data Types: double

Algorithms

corr2 computes the correlation coefficient using

r=mn(AmnA¯)(BmnB¯)(mn(AmnA¯)2)(mn(BmnB¯)2)

where A¯ = mean2(A), and B¯ = mean2(B).

Extended Capabilities

See Also

|

Introduced before R2006a