SURF特征提取(MSAC算法剔除误匹配)

    xiaoxiao2021-12-14  22

    clc; clear; close all; load colorImage201; load colorImage202; % extractFeatures 函数输入为灰度图像,因此要将RGB图像用函数 rgb2gray 进行转换 image1= rgb2gray(colorImage201); image2= rgb2gray(colorImage202); % Surf 特征检测 ptsImage1 = detectSURFFeatures(image1); ptsImage2 = detectSURFFeatures(image2); % Surf 特征提取 [featuresOriginal,validptsImage1] = extractFeatures(image1,ptsImage1); [featuresDistorted,validptsImage2] = extractFeatures(image2,ptsImage2); % Surf 特征匹配 index_pairs = matchFeatures(featuresOriginal,featuresDistorted); matchedptsImage1 = validptsImage1(index_pairs(:,1)); matchedptsImage2 = validptsImage2(index_pairs(:,2)); % 显示有误匹配的情况 figure; subplot(1,2,1) showMatchedFeatures(image1,image2,matchedptsImage1,matchedptsImage2); str=sprintf('Matched inlier points\n(including outliers)'); title(str,'fontname','Times New Roman','FontSize',12); % estimateGeometricTransform 函数 剔除误匹配 (MSAC算法) [tform,inlierptsImage2,inlierptsImage1] =estimateGeometricTransform(matchedptsImage2,matchedptsImage1,'similarity'); % 显示没有误匹配的情况 subplot(1,2,2) showMatchedFeatures(image1,image2,inlierptsImage1,inlierptsImage2); str=sprintf('Matched inlier points\n(excluding outliers)'); title(str,'fontname','Times New Roman','FontSize',12);
    转载请注明原文地址: https://ju.6miu.com/read-968309.html

    最新回复(0)