how to match two imaes

sir i want to matchtwo iamgesin if statement me usee the code is given below:
h=subImage;
h1=imread('14.jpg');
A=rgb2gray(h);
A1=rgb2gray(h1);
% axes(handles.axes10);
% imshow(I);
% figure, imshow(A);
J=imhist(A);
J1=imhist(A1);
figure, imshow(J1);
E_distance= sqrt(sum((J-J1).^2));
if E_distance == 0
figure, imshow('14.jpg');
else E_distance == 1
figure, imshow('dar.jpg');
% w=imread('6.jpg');
% figure;
% imshow(w);
end
guidata(hObject, handles);
axis equal;
axis tight;
axis off;
the ans in cammand window is 0, but show the the pic which is in else block.. check my codee plzz

Réponses (2)

SRI
SRI le 26 Juil 2014

0 votes

Hi Reema Just try this Code you can Find How many times does the image will be displayed, after running the program keep the mouse cursor on Flag and Count of the program it will show the number that much times your output will be displapayed..
clc; warning off;
A = imread('cameraman.tif');
B = imread('circles.png');
c = im2bw(A);
d = im2bw(B);
E = sqrt(sum(c-d).^2);
count = 1;
flag = 1;
for i = 1:length(E)
if E(i) > 100
imshow(c);
count = count+1;
else E(i) <= 100;
imshow(d)
flag = flag + 1;
end
end
Image Analyst
Image Analyst le 26 Juil 2014

0 votes

When you say
if E_distance == 0
figure, imshow('14.jpg');
else E_distance == 1
figure, imshow('dar.jpg');
% w=imread('6.jpg');
% figure;
% imshow(w);
end
You're really doing
if E_distance == 0
figure
imshow('14.jpg');
else
E_distance == 1
figure
imshow('dar.jpg');
end
And since E_distance is not 1, and there is no semicolon, it will spit out an "ans = 0" to the command window.

12 commentaires

reema
reema le 7 Août 2014
But its not show the 14.jpg I.mage...its show dar.jpg...why if and is 0the
0 then why?
Image Analyst
Image Analyst le 7 Août 2014
reema
reema le 8 Août 2014
i didn't understand how can its hel me? in my problem
reema
reema le 8 Août 2014
see my code again and give me the solution please
Adam
Adam le 8 Août 2014
You should never test the result of such maths against 0 with equality unless you are 100% sure that is exactly what you want (which it rarely is). You should test it is within a sensible tolerance of 0.
Image Analyst
Image Analyst le 8 Août 2014
Please attach a script and two images so we can actually run your code.
reema
reema le 9 Août 2014
my project is "face detection and recognition" so i want when detected face is obtain then mee match this detected face with same sizee imagee and display the profile of that person: now i want this resize image is match with "me.jpg" and show the image "me1.jpg"(just for tecting later i design the profile pic) now code for matching is behind the Detected image button for matching..
now i hopee you help meee ...
Image Analyst
Image Analyst le 9 Août 2014
To resize, you can use imresize(). I can't really be a free consultant for you to develop this project along with you. I generally don't spend more than about 5 minutes per question. I'm not even a face recognition expert. I've never written such a program, so I would be a lousy partner in your company. If you have a short, very specific question then I might be able to answer it but I can't really spend hours or days developing a major application with you. I hope you understand.
reema
reema le 9 Août 2014
ok then simply teell mee how to match two images in matlab?
reema
reema le 9 Août 2014
how to match two RGB images and as aresult want to display another image.
Image Analyst
Image Analyst le 9 Août 2014
Depends on what you mean. You can match histograms using this method or using the built-in imhistmatch(). You can find templates in a larger image using normxcorr2(). You can use SIFT or SURF (patented techniques) to do CBIR. You can use CBIR methods (Google it). Or you can just look at how everyone else does face recognition and copy their method.
reema
reema le 12 Août 2014
i got the ans of my Question that is:
i1=SelectedImage;i1=i1(:,:,1);
[c1,n]=imhist(i1);
c1=c1/size(i1,1)/size(i1,2);
% C1=scalar(c1);
i2=imread('C:\Users\Reema shaheen\Documents\MATLAB\PCA WALA\static\7.bmp');i2=i2(:,:,1);
[c2,n2]=imhist(i2);
c2=c2/size(i2,1)/size(i2,2);
% C2=scalar(c2);
d = pdist2(c1',c2');
if (d == 0)
figure, imshow('1.bmp');
else
figure, imshow('3.jpg');
end

Connectez-vous pour commenter.

Question posée :

le 26 Juil 2014

Commenté :

le 12 Août 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by