簡體   English   中英

在Matlab中可以繪制不匹配的SURFPoints嗎?

[英]Is it possible in Matlab to plot not matching SURFPoints?

我正在嘗試使用Matlab查找兩個圖像之間的差異。 Matlab為此提供的經典內置函數是因為兩個圖像的尺寸不同(圖像中的對象相同,但是在第二個圖像中引入了其他對象)。

而且我認為我可以使用SURF功能來完成此任務。 這是代碼:

source = imread('source.png');
target = imread('target.png');
source = rgb2gray(source);
target = rgb2gray(target);

sourcePoints=detectSURFFeatures(source,'MetricThreshold',100.0,'NumOctaves',1,'NumScaleLevels',6);
targetPoints=detectSURFFeatures(target,'MetricThreshold',100.0,'NumOctaves',1,'NumScaleLevels',6);

%figure; imshow(source);
%hold on;
%plot(sourcePoints.selectStrongest(10000));


[sourceFeatures, sourcePoints]=extractFeatures(source,sourcePoints,'SURFSize',64);
[targetFeatures,targetPoints]=extractFeatures(target,targetPoints,'SURFSize',64);

boxPairs = matchFeatures(sourceFeatures, targetFeatures);

matchedSourcePoints = sourcePoints(boxPairs(:, 1), :);
matchedTargetPoints = targetPoints(boxPairs(:, 2), :);

figure;
showMatchedFeatures(source, target, matchedSourcePoints, matchedTargetPoints, 'montage');

display(matchedSourcePoints);
display(matchedTargetPoints);

問題是,據我所知,您具有僅顯示匹配的SURF點的功能,並且我需要在目標圖像上僅繪制與源圖像中的點不匹配的點。

結果得到的“ matchedTargetPoints”和“ targetPoints”變量是SURFPoints對象的數組,因此find函數不起作用,對其進行減法或對其進行數組操作不起作用。 我還嘗試遍歷“ targetPoints”,並檢查每個點是否存在,但是腳本花費了很多時間,因此這也不起作用。

有誰知道如何實現這一目標? 任何答復表示贊賞。

謝謝。

您可以使用SURFPoints對象的Location屬性來獲取存儲在M×2矩陣中的點的(x,y)位置。 然后,您可以使用邏輯索引獲取不匹配的點:

targetPointsLoc = targetPoints.Location;
unmatchedIdx = true(size(targetPoitnsLoc, 1), 1);
unmatchedIdx(boxPairs(:, 2)) = false;
unmatchedTargetPoints = targetPointsLoc(unmatchedIdx, :);

現在,您可以使用plot顯示不匹配的點。

出於好奇,您為什么要關心無與倫比的問題?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM