Clear Filters
Clear Filters

How to match two images in matlab?

82 views (last 30 days)
I have two different photos of lips but they are from the same person and I have created a mask for each of them, how can I match them and get the percentage of matching?

Accepted Answer

Image Analyst
Image Analyst on 27 Nov 2018
Edited: Image Analyst on 27 Nov 2018
Try the Sørensen–Dice coefficient or similar metrics.
See my attached demo.
  2 Comments
Evelynn Tan
Evelynn Tan on 5 Dec 2018
Edited: Evelynn Tan on 5 Dec 2018
I would like to ask,
% AND these together
andImage = binaryImage1 & binaryImage2;
is this code only available for the case when both images are the same?
When I used the same images it does not have any problem, but I need to compare and calculate matching percentage of two different images, so I tried it on but I got an error:
"Matrix dimensions must agree."
What does this means? Is it only applicable for two exactly same images?
Im so sorry because im not good in coding and this is the first time im doing image processing. Thanks for your patience.
Image Analyst
Image Analyst on 5 Dec 2018
The do not have to be the same image content, but of course the sizes/dimensions need to match. How could it possibly work otherwise? How could you AND images pixel-for-pixel if one image is 30 by 60 and another is 640 by 480? Think it through. If you resize one, is that OK? Why are they different in the first place? Were they not both acquired by the same camera or process?

Sign in to comment.

More Answers (2)

KALYAN ACHARJYA
KALYAN ACHARJYA on 26 Nov 2018
Edited: KALYAN ACHARJYA on 26 Nov 2018
You can do it number of ways
  1. matchFeatures
2. compare the two gray images, just subtract one image from other, see the difference if
image1-imag2=0
then 100% match, otherwise if image1-image2=not zero matrix just add them and find the percentage.
3. Anotherway you can check the custom function here
  1 Comment
Evelynn Tan
Evelynn Tan on 27 Nov 2018
Edited: Evelynn Tan on 27 Nov 2018
Thank you!
But what I need to match are not the same pictures, they are diffferent pictures but lips from the same person, so I need to match to determine is it the same lips. It is kind of the concept of a security system.
Lets say if I found the distances from the centre to certain points, or using the area, is there anyway?

Sign in to comment.


Martin H. Trauth
Martin H. Trauth on 27 Nov 2018
First you need to perform an image registration, i.e. matching them first before you compare them pixel by pixel remembering that matching never yields a perfect result/match. There is a number of functions available in the Image Processing Toolbox, such as imregister.

Community Treasure Hunt

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

Start Hunting!