Why matchFeatures gives two different answers?

7 Ansichten (letzte 30 Tage)
Zainor
Zainor am 7 Apr. 2013
Kommentiert: Morten Beier am 20 Aug. 2017
I tried to run this code:
I1 = rgb2gray(imread('viprectification_deskLeft.png'));
I2 = rgb2gray(imread('viprectification_deskRight.png'));
points1 = detectSURFFeatures(I1);
points2 = detectSURFFeatures(I2);
[features1, valid_points1] = extractFeatures(I1, points1);
[features2, valid_points2] = extractFeatures(I2, points2);
indexPairs1 = matchFeatures(features1, features2);
indexPairs2 = matchFeatures(features2, features1);
My Question: Why indexPairs1 and indexPairs2 have different length? I suppose it share the same length rite?

Akzeptierte Antwort

Anand
Anand am 9 Apr. 2013
They are not expected to share the same length. The first tries to find the best matches for features1 in features2 and the second tries to find the best matches for features2 in features1.
For the nearest neighbor ratio matching method (the default), this plays out as follows:
Assume features1 has 100 features and features2 has 200.
In the case of matchFeatures(features1,features2), for each of the 100 features in features1, the top 2 matches (2 nearest neighbors) from the 200 features in features2 are found. This gives us 100 pairs of 2 features each. These are then accepted or rejected by seeing whether the distance ratio between the nearest neighbor and the second nearest neighbor.
The process I described above is not symmetric. So, you can expect that matchFeatures(features2,features1) maybe slightly different.
You can look at this paper for details about this: K. Mikolajczyk and C. Shmid, "A Performance Evaluation of Local Descriptors," IEEE PAMI, 27, 10 (2005)
If you would like symmetric matches, try the 'NearestNeighborSymmetric' method:
indexPairs1 = matchFeatures(features1,features2,'Method','NearestNeighborSymmetric');
indexPairs2 = matchFeatures(features2,features1,'Method','NearestNeighborSymmetric');
>> isequal(fliplr(sort(indexPairs2)),sort(indexPairs1))
ans =
1
  2 Kommentare
Elena Ranguelova
Elena Ranguelova am 4 Nov. 2016
Unfortunately this method is not available anymore in the current (latest) version (MATLAB 2016b). Now the options for 'Method' are only Exhaustive' or 'Approximate'.
How can one perform symmetric matching?
Morten Beier
Morten Beier am 20 Aug. 2017
It's long time ago Elena posted, but maybe someone else needs an answer :-) To make the sets match so indexPairs1 and indexPairs2 are of equal length you can use 'unique' meaning that each match is unique - also known as the 'marriage problem' (A needs to match B, but B also needs to match A). For example:
indexPairs = matchFeatures(features1,features2,'Unique',true);
matchedPoints1 = valid_corners1(indexPairs(:,1),:);
matchedPoints2 = valid_corners2(indexPairs(:,2),:);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Zainor
Zainor am 9 Apr. 2013
Thank you Anand for the answer

Community Treasure Hunt

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

Start Hunting!

Translated by