How to eliminate erroneous match(es) in matchFeatures example?

2 ビュー (過去 30 日間)
Canberk Suat Gurel
Canberk Suat Gurel 2018 年 3 月 22 日
コメント済み: Image Analyst 2018 年 3 月 23 日
Hi all,
I have a set of images that are taken from the dash cam of a car. I am trying to find a set of corresponding points in two successive frames to estimate the direction of the car. (I will use this information to obtain the visual odometry of the car). I used the match features code given here: https://www.mathworks.com/help/vision/ref/matchfeatures.html
But sometimes I am getting wrong matches. For example:
My function:
function [matchedPoints1, matchedPoints2] = Corresponding_Points(Im1,Im2)
%%Find Corresponding Interest Points Between Pair of Images
% Find the corners.
points1 = detectHarrisFeatures(Im1);
points2 = detectHarrisFeatures(Im2);
% Extract the neighborhood features.
[features1,valid_points1] = extractFeatures(Im1,points1);
[features2,valid_points2] = extractFeatures(Im2,points2);
% Match the features.
indexPairs = matchFeatures(features1,features2);
% Retrieve the locations of the corresponding points for each image.
matchedPoints1 = valid_points1(indexPairs(:,1),:);
matchedPoints2 = valid_points2(indexPairs(:,2),:);
end
My code:
[matchedPoints1, matchedPoints2] = Corresponding_Points(image_1_gray,image_2_gray);
x1 = matchedPoints1.Location';
x2 = matchedPoints2.Location';
Note: the returned matchedPoints1 and matchedPoints2 belong to class cornerPoints . Using matchedPoints1.Location returns a matrix type single. (I am using Matlab 2016a.)
Thanks!

採用された回答

Image Analyst
Image Analyst 2018 年 3 月 22 日
Do you know the (x,y) coordinates of each? You could just throw out any pairs where the distance between them is more than, say 10% of the image width.
  2 件のコメント
Canberk Suat Gurel
Canberk Suat Gurel 2018 年 3 月 22 日
編集済み: Canberk Suat Gurel 2018 年 3 月 22 日
Thank you for your answer. Yes, I know their (x,y) coordinates. I can do something like this:
for i = 1:length(x1)
d = sqrt((x1(1,i)-x2(1,i))^2+(x1(2,i)-x2(2,i))^2)
if(d>100)
x1(:,i) = [];
x2(:,i) = [];
end
end
Can you think of a more efficient method? Getting rid of the for loop would be great.
Image Analyst
Image Analyst 2018 年 3 月 23 日
Not sure if shrinking the array at every iteration is efficient. Maybe try just keeping track of columns to keep and vectorize it and extract:
distances = sqrt((x1(1,:)-x2(1,:)).^2+(x1(2,:)-x2(2,:)).^2)
columnsToKeep = distances < 100;
x1 = x1(:, columnsToKeep);
x2 = x2(:, columnsToKeep);

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeComputer Vision with Simulink についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by