corr2
2-D correlation coefficient
Syntax
Description
Examples
Compute the correlation coefficient
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
A
— First input array
numeric array | logical array
First input array, specified as a numeric or logical array.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
B
— Second input array
numeric array | logical array
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
R
— Correlation coefficient
numeric scalar
Correlation coefficient, returned as a numeric scalar.
Data Types: double
Algorithms
corr2
computes the correlation coefficient using
where
=
mean2(A)
, and
=
mean2(B)
.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
corr2
supports the generation of C
code (requires MATLAB®
Coder™). For more information, see Code Generation for Image Processing.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see Image Processing on a GPU.
Version History
Introduced before R2006aR2023a: Support for C code generation
corr2
now supports the generation of
C code (requires MATLAB
Coder).
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)