How can I find out Correlation between two image?
18 次查看(过去 30 天)
显示 更早的评论
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);
0 个评论
采纳的回答
Image Analyst
2019-6-23
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);
4 个评论
Image Analyst
2023-3-17
@Sampath Gamage what do you mean by the correlation matrix? If you use corr2() that basically says how much does each pixel's value move in tandem between the two images? It's a single scalar. If you use xcorr2() you will get an image that is the sum of the two image widths and it is the cross correlation of the two images.
help corr2
help xcorr2
Sampath Gamage
2023-3-17
编辑:Sampath Gamage
2023-3-17
@Image Analyst, Thanks for the reply!
I think this is not just coding anymore. :) I'm trying to understand how to find the correlation of two images and how to present the result.
If we have two images of same size, (say 50x50 px) can we create a correlation map of 50x50 that gives the correlation of each pixel?
Or is the correlation between two images simply given by a single number?
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!