Why matchFeatures gives two different answers?

조회 수: 3 (최근 30일)
Zainor
Zainor 2013년 4월 7일
댓글: Morten Beier 2017년 8월 20일
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?

채택된 답변

Anand
Anand 2013년 4월 9일
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
Elena Ranguelova
Elena Ranguelova 2016년 11월 4일
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 2017년 8월 20일
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),:);

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Zainor
Zainor 2013년 4월 9일
Thank you Anand for the answer

카테고리

Help CenterFile Exchange에서 Feature Detection and Extraction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by