From: Lavanya A on
I am trying to find the correlation between images. So i get the image convert to greyscale value and then i calculate correlation using function. I am struck up with how to pass the greyscale value matrix into another matrix. Finally i need the correlation matrix of 3*3
here is the code

cartman =imread('rose.jpg');
k1=rgb2gray(cartman);
cartman1 =imread('rose1.jpg');
k2=rgb2gray(cartman1);
cartman2=imread('glowing.jpg');
k3=rgb2gray(cartman2);
%a= [k1,k2,k3;k1,k2,k3;k1,k2,k3];
% b= [k1,k2,k3];
for i = 1: 3
for j = 1: 3
d(i,j) = Correlation(abs(a(i,j)),abs(a(i,j)));
end
end
d

please help
Thanks

-
Lavanya
From: Joseph on
I'm taking it "Correlation" is not defined.

Check out the file exchange. One example
http://www.mathworks.com/matlabcentral/fileexchange/12413


Also, I don't think a(i,j) does what you want.

....and you shouldn't need abs()

"Lavanya A" <lavanya3k(a)gmail.com> wrote in message <i3e8fh$lj4$1(a)fred.mathworks.com>...
> I am trying to find the correlation between images. So i get the image convert to greyscale value and then i calculate correlation using function. I am struck up with how to pass the greyscale value matrix into another matrix. Finally i need the correlation matrix of 3*3
> here is the code
>
> cartman =imread('rose.jpg');
> k1=rgb2gray(cartman);
> cartman1 =imread('rose1.jpg');
> k2=rgb2gray(cartman1);
> cartman2=imread('glowing.jpg');
> k3=rgb2gray(cartman2);
> %a= [k1,k2,k3;k1,k2,k3;k1,k2,k3];
> % b= [k1,k2,k3];
> for i = 1: 3
> for j = 1: 3
> d(i,j) = Correlation(abs(a(i,j)),abs(a(i,j)));
> end
> end
> d
>
> please help
> Thanks
>
> -
> Lavanya
From: Lavanya on
Thanks for the response...After doing some correction to my existing code..i arrive at this.. here i get 'r'(correlation value) after every loop..
I write a seperate function 'Correlation' and call back to my program
tifFiles = dir('E*.tif');
for k = 1:length(tifFiles)
filename = tifFiles(k).name;
data1 = imread(filename);
filename2 = tifFiles(k+1).name;
data2 = imread(filename2);
r=Correlation(data1,data2);
filename,filename2,r
end

now i need to get the output as matrix...let say there is 3 files from where i extract. So my output should be of format 1 0.888 0.994
0.888 1 0.97
0.994 0.97 1