Comparing two images/pictures
Show older comments
I am trying to write a code to compare 2 images/pictures to ensure they match. This is to be used as part as a face recognition system. So i would have to compare the new image that will be taken against a set of images that i have already saved.
Would appreciate some help as im very new to using this system.
2 Comments
Anon
on 22 Mar 2011
What does this question have to do with Matlab? What about searching the literature for suitable measures for comparing images? If you find a measure that fits your needs, come back to this forum and ask for advice on its implementation in Matlab.
Anon
d-va
on 22 Mar 2011
Answers (2)
Matt Fig
on 22 Mar 2011
1 vote
You will have to quantify what you mean when you want to know if images match. Do you mean that they should be identical? Or that each pixel should differ by only a small amount?
7 Comments
d-va
on 22 Mar 2011
Matt Fig
on 22 Mar 2011
Again, what does it mean to "match with a certain threshold?" Does it mean, for example given two images I1 and I2 and threshold thresh:
max(abs(I1(:)-I2(:)))<thresh
This will return true if every value in I1 is within thresh of the same value in I2.
d-va
on 23 Mar 2011
Sean de Wolski
on 23 Mar 2011
Yes. But what do you mean by match?!?!?!
Exact copy?
isequal(I1,I2);
close: as Matt suggested or a normalized x-correlation.
Matt Fig
on 23 Mar 2011
I don't know how to get through to you, d-va. I asked you what you meant by the images matching within a certain threshold. You told me what you would do if the images match. That does not answer the question. You see, MATLAB is a programming language and, as such, its use in solving a problem for you will depend entirely on your ability to specify the problem. Computers are strictly obedient - that is, they do only what you tell them to do, and nothing more. So to get MATLAB to tell you if two images match, you MUST define _exactly_ what you mean by "match within a certain threshold."
You can try if you want to write a program in MATLAB with the line, "If the images match, accept it," but I don't think you will get anywhere.
Sean de Wolski
on 23 Mar 2011
Matt, that won't work:
%%
if the images match,
accept it
end
??? Undefined function or variable 'the'.
>> the = 2; images = 3; match = 4; accept = 5;it=6;
>> if the images match,
accept it
end
??? Error: "images" was previously used as a variable,
conflicting with its use here as the name of a function or command.
See MATLAB Programming, "How MATLAB Recognizes Function Calls That Use Command Syntax" for
details.
>> :)
Matt Fig
on 23 Mar 2011
I thought that would be the case! Thanks for taking the time to investigate this, Sean de. It was worth a try anyway, you never know just how clever these MathWorkers are getting.
I guess MATLAB does have room for improvement indeed!
VINAY DEVANIDI REDDY
on 28 Mar 2017
0 votes
hi, this is vinay.
I am doing a project regarding eye detection system . The concept is that eye tracking will be done on a subject1 and the images are compared with one general image of an eye of another subject2 . subject 2 image is constant . When the image matches then it means that the subject is looking at me . When the new image sometime later doesnt match which means that the subject 1 is not looking at me , then the image wont be similar to the subject 2 image . This should trigger a signal to an audio device on subject 1 telling it to " look at me "..
1 Comment
Rajat Mehta
on 22 Aug 2020
did you figure it out?
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!