MATLAB: How to find out Correlation between two image

digital image processingImage Processing ToolboxMATLAB

clc;
clear all;
close all;
a=imread('1.jpg');
b=imread('2.jpg');
corr2(a,b);
____________::Error Occured::_____________
Error using corr2
Error using corr2
Expected input number 1, A, to be two-dimensional.
Error in corr2>ParseInputs (line 35)
validateattributes(A, {'logical' 'numeric'}, {'real','2d'}, mfilename, 'A', 1);
Error in corr2 (line 21)
[a,b] = ParseInputs(varargin{:});
Error in featureExt (line 9)
corr2(a,b);

Best Answer

They're probably color. Do it on one color channel at a time, or use rgb2gray() to convert them to grayscale. Untested code:
grayImage1 = rgb2gray(a);
grayImage2 = rgb2gray(b);
out = corr2(grayImage1, grayImage2);
Related Question