Compare images and find the most similar
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello, I am new in this web site, but I am finding a good support and help by the community, so firstly, I want to say thank you in advance for your time and support.
My problem is that I want to compare one image with several models with differences each one, with the intention to clasify this image, for example the following music notes would be our data base:
and the image to clasify would be the following:
Then I am trying to compare my image with all the previous masks one by one, and find the most similar to my main image. I tried with the detectSURFFeatures, but the image doesn´t have sufficient details to this technique... so I am looking for other idea to do this.
Maybe comparing the Histograms between every image and finding the most similar? Please if someone have another idea, he/she is welcome. Thank you very much.
0 commentaires
Réponse acceptée
Alex Taylor
le 14 Jan 2014
Modifié(e) : Alex Taylor
le 14 Jan 2014
Image Analyst's answer is extremely computationally efficient and a good solution to the problem. If it happened that you had additional notes in your database with similar numbers black pixels, another approach that you could use that would take into account the actual geometric similarity between the notes would be normalized cross correlation.
For example:
noteOfInterest = imread('http://www.mathworks.com/matlabcentral/answers/uploaded_files/6835/corchea.jpg');
noteOfInterest = rgb2gray(noteOfInterest);
C1 = normxcorr2(noteOfInterest,noteOfInterest);
max(C1(:))
Now compare this peak normalized correlation to a note from the database which is dissimilar:
aDifferentNoteFromLibrary = imread('http://www.mathworks.com/matlabcentral/answers/uploaded_files/6833/fusa.jpg');
aDifferentNoteFromLibrary = rgb2gray(aDifferentNoteFromLibrary);
C2 = normxcorr2(noteOfInterest,aDifferentNoteFromLibrary);
max(C2(:))
We see that C1 has a peak normalized cross correlation of 1.0 when the same image is correlated with itself, and a lower peak normalized cross correlation when two dissimilar images are correlated in C2.
In this approach, you would have to correlate the note being classified with each note in the database, then choose the one with the largest peak normalized cross correlation. This will certainly be slower than Image Analyst's approach, so I'd use the proposed lookup table approach if that provides an accurate classification.
3 commentaires
Alex Taylor
le 15 Jan 2014
Yeah, I'm glad you mentioned that. It's worth clarifying with anyone else reading this post that my suggestion to use normxcorr2 assumes that there is not rotation, scale, or any other more complicated form of geometric distortion present when matching notes from the database.
Plus de réponses (1)
Image Analyst
le 14 Jan 2014
The simplest way is to count the number of black pixels. That's assuming all your notes are perfect ones like this. As they get more corrupted and noisy, this method deteriorates. The number of black pixels for each note is unique so you can just use a lookup table to find out which note it is. For example
lookupTable = [1000, 850, 1100, 1200];
Then let's say your 'test" note has 870 black pixels, then just
blackInMyNote = 870;
[~, noteNumber] = min(abs(blackInMyNote - lookupTable))
noteNumber is your answer.
2 commentaires
Image Analyst
le 15 Jan 2014
Rotation with my method with high quality notes should be fine - it will still find the proper note and will work. With scaling, it won't, and you'll have to look into more sophisticated pattern recognition methods, or else try to scale the test image to be the proper size. Of course if you have a lot of clutter/garbage/noise then it gets more and more difficult to identify the proper note.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!