SURF特征提取(使用matlab自带函数)、SIFT、LSD线特征提取

本文展示了如何在MATLAB中使用SURF特征提取,并与SIFT和LSD特征进行比较,通过实际例子演示了特征匹配和图像拼接。首先,我们使用SURF在两幅图像中检测关键点并提取描述符,然后使用matchFeatures进行匹配。接着,通过SIFT在vlfeat包中实现特征匹配,最后展示LSD线段检测的匹配结果。这些技术常用于图像内容理解与配准任务。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

SURF特征提取(使用matlab自带函数)

用matlab自带函数showMatchedFeatures中给的示例进行SURF特征提取匹配,显示出匹配结果图片

用points1是n×1的SURFpoints数组,f1是一个n×64的矩阵(n是特征点个数,64是SURF描述子的维度),vpts1是n×1的SURFpoints数组,indexPairs是m×2的矩阵(m是匹配对数,第一列是图1的,第二列图2的)

 I1 = imread('cameraman.tif');
 I2 = imresize(imrotate(I1,-20), 1.2);

 points1 = detectSURFFeatures(I1);
 points2 = detectSURFFeatures(I2);

 [f1, vpts1] = extractFeatures(I1, points1);
 [f2, vpts2] = extractFeatures(I2, points2);
        
 indexPairs = matchFeatures(f1, f2) ;
 matchedPoints1 = vpts1(indexPairs(:, 1));
 matchedPoints2 = vpts2(indexPairs(:, 2));

 % Visualize putative matches
 % figure; showMatchedFeatures(I1,I2,matchedPoints1,matchedPoints2);%一张图中显示
 figure; showMatchedFeatures(I1,I2,matchedPoints1,matchedPoints2,'montage');%两张图中显示

 title('Putative point matches');
 legend('matchedPts1','matchedPts2');

结果

用自己的图片替换

 I1_rgb = imread('F:\stitching\imagess\theater_01.jpg');
 I2_rgb = imread('F:\stitching\imagess\theater_02.jpg');
 I1 = rgb2gray(I1_rgb);
 I2 = rgb2gray(I2_rgb);

 points1 = detectSURFFeatures(I1);
 points2 = detectSURFFeatures(I2);

 [f1, vpts1] = extractFeatures(I1, points1);
 [f2, vpts2] = extractFeatures(I2, points2);       
 indexPairs = matchFeatures(f1, f2) ;
 
 matchedPoints1 = vpts1(indexPairs(:, 1));
 matchedPoints2 = vpts2(indexPairs(:, 2));
 % Visualize putative matches
 figure; showMatchedFeatures(I1_rgb,I2_rgb,matchedPoints1,matchedPoints2,'montage');
 title('Putative point matches');
 legend('matchedPts1','matchedPts2');

结果

SIFT特征提取匹配:

使用vlfeat包进行SIFT匹配

run('F:\load\vlfeat-0.9.18\toolbox/vl_setup');
im1 = imread('F:\enhancement\images\算法1的效果图\大论文使用图片\last\yellow_s.jpg');
im1 = imresize(im1, [420, 600]);
gray1 = im2single(rgb2gray(im1));
[ kp1,ds1 ] = vl_sift(single(gray1),'PeakThresh', 0,'edgethresh',500);
[ kp2,ds2 ] = vl_sift(single(gray2),'PeakThresh', 0,'edgethresh',500);
%figure; imshow(im1); hold on;
%plot(kp1(1,:),kp1(2,:),'b.');
matches = vl_ubcmatch(ds1,ds2);
X1 = [ kp1(1:2,matches(1,:)) ; ones(1,size(matches,2)) ];
X2 = [ kp2(1:2,matches(2,:)) ; ones(1,size(matches,2)) ];
    
figure; imshow([im1, im2]); hold on;
plot(X1(1,:),X1(2,:),'b.');
plot(X2(1,:)+size(im1,2),X2(2,:),'b.');    
line([X1(1,:);X2(1,:)+size(im1,2)],[X1(2,:);X2(2,:)]);

LSD线段特征提取:

下载地址:https://download.youkuaiyun.com/download/yanmengying/88681048

运行lsd_example和lsd2_example函数,更改其中的图片路径即可

运行结果:

 

 

 

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值