SURF算法matlab实现

detectSURFFeatures

用法:

points = detectSURFFeatures(I) %I是输入的灰度图像,返回值是一个 SURFPoints类,这个SURFPoints类包含了一些从这个灰度图像中提取的一些特征
points = detectSURFFeatures(I,Name,Value)

SURFPoints 这个类型
属性

  • cout : 计算这个物体所拥有点的数量
  • Location:定位这个点
  • scale:确定这个兴趣点的取值范围
  • length:长度
    这里写图片描述
    在这个地方我特有一些疑问,属性和方法事有区别的,方法中可以限制一些参数
    属性和方法的区别:
    如果非要说一些区别的话:我尝试了一下:就是说属性和方法一个,属性是有默认值的,方法是不能加任何默认值的。

extractFeatures

用法:

[features,validPoints] = extractFeatures(I,points);%这里的points就是刚刚detectSURFFeatures函数的返回值, I 就是输入的灰度图像

feature作为匹配函数的输入值
[features,validPoints] = extractFeatures(I,points,Name,Value)

用这个函数来提取刚刚选中的特征点:
这里的特征点只能是用这几种方法提取出的特征点:
这里写图片描述
这里point只能由下面的值来弄
这里写图片描述

matchFeatures

用法:

indexPairs = matchFeatures(features1,features2);
[indexPairs,matchmetric] = matchFeatures(features1,features2);
[indexPairs,matchmetric] = matchFeatures(features1,features2,Name,Value);
indexPairs 是返回的两幅图像匹配的指标%这个地方可以将他的返回值进行截图
features1就是上面extractFeatures函数的返回值中validpoints,然后只用输入想要配对的两张图片就可以了

showMatchedFeatures

用法:

showMatchedFeatures(I1,I2,matchedPoints1,matchedPoints2)
showMatchedFeatures(I1,I2,matchedPoints1,matchedPoints2,method)
% I1I2就是需要匹配的两个函数

这里写图片描述
这里有三种方法,第一种,假彩图像,混合图像和拼接图

最后整体拼接后的图像:

clc
%读取图像
I1= imread('D:\matlab 2015b\workspace\source\1.jpg');  
I1=imresize(I1,0.6);  %imresize 将原来的图像缩小原来的一般
I1=rgb2gray(I1);  %把RGB图像变成灰度图像
figure
imshow(I1)
I2= imread('D:\matlab 2015b\workspace\source\2.jpg');  
I2=imresize(I2,0.6);  
I2=rgb2gray(I2);
figure
imshow(I2)

%寻找特征点  
points1 = detectSURFFeatures(I1);  %读取特征点
points2 = detectSURFFeatures(I2);   

%Extract the features.计算描述向量  
[f1, vpts1] = extractFeatures(I1, points1);  
[f2, vpts2] = extractFeatures(I2, points2);  

%Retrieve the locations of matched points. The SURF feature vectors are already normalized.  
%进行匹配  
indexPairs = matchFeatures(f1, f2, 'Prenormalized', true) ;  
matched_pts1 = vpts1(indexPairs(:, 1)); %这个地方应该是对他进行取值吧 这个应该是啊吧他们做成一个数组
matched_pts2 = vpts2(indexPairs(:, 2));  
%显示匹配
figure('name','匹配后的图像'); showMatchedFeatures(I1,I2,matched_pts1,matched_pts2,'montage');  %总共找了39个特征点
legend('matched points 1','matched points 2'); 

这里写图片描述
这个程序基本就是把MATLAB中示例程序跑了一遍

示例图片:
这里写图片描述
这里写图片描述

  • 19
    点赞
  • 202
    收藏
    觉得还不错? 一键收藏
  • 27
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 27
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值