I want to compare two images using MATLAB and display a message, 'It is the same image.' or 'Sorry , it's not the same image.'. My program always displays 'It is the same image.'.
My code is:
i1 = imread('001_1_1.fig');
i2 = imread('001_1_1.fig');
x1 = edge(i1,'canny');
j1 = imcrop(x1,[135 90 100 95]);
x2 = edge(i2,'canny');
g = 0;
xxx = 1;
yyy = 1;
for n = 1:1:2
g1 = imrotate(j1,n,'bilinear','crop');
r1 = corr2(j1,g1);
if(xxx<r1)
else
xxx = r1;
end;
end;
for n = 180:-1:178
g1 = imrotate(j1,n,'bilinear','crop');
r1 = corr2(j1,g1);
if(yyy<r1)
else
yyy = r1;
end;
end;
if(xxx <= yyy)
r_corr = xxx;
else
r_corr = yyy;
end;
j2 = imcrop(x2,[135 90 100 95]);
r = corr2(j1,j2);
开发者_如何学Cif (r==1)
disp('it is the same image')
return;
elseif (r >= r_corr)
disp('it is the same image')
return;
else
g = 1;
end;
if(g==1)
disp('sorry, it is not the same image')
end;
You're loading two images, i1
and i2
using the following command
i1=imread('001_1_1.fig');
i2=imread('001_1_1.fig');
These images are the same. Therefore, the code will tell you that the two images are the same.
x=imread('first.jpg');
y=imread('seconda.jpg');
c=isequal(x,y);
``if c==1
printf('Yes equal '); else printf('Not ');
精彩评论