Compare images and find the most similar

9 ビュー (過去 30 日間)
Alberto
Alberto 2014 年 1 月 14 日
コメント済み: Alberto 2014 年 1 月 15 日
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.

採用された回答

Alex Taylor
Alex Taylor 2014 年 1 月 14 日
編集済み: Alex Taylor 2014 年 1 月 14 日
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 件のコメント
Alex Taylor
Alex Taylor 2014 年 1 月 15 日
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.
Alberto
Alberto 2014 年 1 月 15 日
Thank you very much for your time and support. Your solution has helped me a lot. I think that by this way I can continue with my project. One more time thank you for your support.

サインインしてコメントする。

その他の回答 (1 件)

Image Analyst
Image Analyst 2014 年 1 月 14 日
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 件のコメント
Alberto
Alberto 2014 年 1 月 15 日
Firstly, thank you very much for your answer, but as Alex Taylor has said below, notes will pass for different process like rotation and they will be deteriored... So I think that this method didn´t work.
Even so thank you very much for your answer, I noted
Image Analyst
Image Analyst 2014 年 1 月 15 日
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.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by