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函数,更改其中的图片路径即可
运行结果: