我需要在 matlab 中实现 RANSAC 算法以实现图像拼接。我在 bestMatches 矩阵 (2 x 500) 中有两个图像的最佳匹配点现在我需要实现 RANSAC,这是我到目前为止所做的。我已经对需要做的事情发表了评论,任何人都可以帮我实现它作为一个整体。我已经努力了好几天来做到这一点,但没有成功。请帮忙。
% ---- run RANSAC ----
% define RANSAC parameters
threshDistBetPoints = 0.1;
numOfIteration = 50;
numOfRandomPoints = 3;
inlierRatio = 0.6;
% output parameters of RANSAC
best_transform = [];
best_num_inliers = 0;
% Plot the data points
for i=1:numOfIteration
% 1) select 3 random points
idx = randperm(size(bestMatches,2),numOfRandomPoints);
sample = bestMatches(:,idx);
% 2) compute affine transform T'
% 3) take all 500 matching points
% map all Q(right image) to P'(left image) (transformation)
% Compute distances between P' and P point (Left Image)
% compute no. of inliers
% 4) store the currently best affine transform
% output of first iteration - T' and no. of inliers
if inlierNum >= best_num_inliers
best_num_inliers = inlierNum
if end
for end
% End of algorithm best transform = T' with largest numbers of inliers
% stitch function - already implemented
Additional information
sample =
3677 6527 2759
3413 6343 2485