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

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);

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值