意见箱
恒创运营部门将仔细参阅您的意见和建议,必要时将通过预留邮箱与您保持联络。感谢您的支持!
意见/建议
提交建议

【图像配准】基于surf算法实现图像配准附Matlab代码

来源:恒创科技 编辑:恒创科技编辑部
2024-01-01 18:45:59
1 内容介绍

传统的全景图像配准多采用基于SIFT的方法,该方法数据量大,时间效率低.提出了一种基于SURF的全景图像快速配准方法.运用SU RF提取特征点,计算特征描述符;运用低时间复杂度的K-D树最近邻搜索法实现特征点快速匹配;利用RANSAC算法剔除误匹配点;最后估计出两幅全景图像的变换矩阵.测试表明:算法具有较高的时间效率和良好的鲁棒性.

2 部分代码

% Example 3, Affine registration

% Load images


【图像配准】基于surf算法实现图像配准附Matlab代码

clc

clear all

close all

tic

I1=im2double(imread('TestImages/lena1.png'));

I2=im2double(imread('TestImages/lena2.png'));


% Get the Key Points

Options.upright=true;

Options.tresh=0.0001;

Ipts1=OpenSurf(I1,Options);

Ipts2=OpenSurf(I2,Options);


% Put the landmark descriptors in a matrix

D1 = reshape([Ipts1.descriptor],64,[]);

D2 = reshape([Ipts2.descriptor],64,[]);


% Find the best matches

err=zeros(1,length(Ipts1));

cor1=1:length(Ipts1);

cor2=zeros(1,length(Ipts1));

for i=1:length(Ipts1),

distance=sum((D2-repmat(D1(:,i),[1 length(Ipts2)])).^2,1);

[err(i),cor2(i)]=min(distance);

end


% Sort matches on vector distance

[err, ind]=sort(err);

cor1=cor1(ind);

cor2=cor2(ind);


% Make vectors with the coordinates of the best matches

Pos1=[[Ipts1(cor1).y]',[Ipts1(cor1).x]'];

Pos2=[[Ipts2(cor2).y]',[Ipts2(cor2).x]'];

Pos1=Pos1(1:30,:);

Pos2=Pos2(1:30,:);


% Show both images

I = zeros([size(I1,1) size(I1,2)*2 size(I1,3)]);

I(:,1:size(I1,2),:)=I1; I(:,size(I1,2)+1:size(I1,2)+size(I2,2),:)=I2;

figure, imshow(I); hold on;


% Show the best matches

plot([Pos1(:,2) Pos2(:,2)+size(I1,2)]',[Pos1(:,1) Pos2(:,1)]','-');

plot([Pos1(:,2) Pos2(:,2)+size(I1,2)]',[Pos1(:,1) Pos2(:,1)]','o');


% Calculate affine matrix

Pos1(:,3)=1; Pos2(:,3)=1;

M=Pos1'/Pos2';


% Add subfunctions to Matlab Search path

functionname='OpenSurf.m';

functiondir=which(functionname);

functiondir=functiondir(1:end-length(functionname));

addpath([functiondir '/WarpFunctions'])


% Warp the image

I1_warped=affine_warp(I1,M,'bicubic');


% Show the result

figure,

subplot(1,3,1), imshow(I1);title('Figure 1');

subplot(1,3,2), imshow(I2);title('Figure 2');

subplot(1,3,3), imshow(I1_warped);title('Warped Figure 1');


toc


fprintf('Found %d matches.\n', size(Pos1,1)) ;

fprintf('Matched in %.3f s\n', toc) ;


3 运行结果

【图像配准】基于surf算法实现图像配准附Matlab代码_2d

【图像配准】基于surf算法实现图像配准附Matlab代码_图像配准_02

4 参考文献

[1]阳吉斌, 胡访宇, 朱高. 基于改进SURF算法的遥感图像配准[J]. 电子测量技术, 2012, 35(3):5.

博主简介:擅长​​智能优化算法​​、​​神经网络预测​​、​​信号处理​​、​​元胞自动机​​、​​图像处理​​、​​路径规划​​、​​无人机​​、​​雷达通信​​、​​无线传感器​​等多种领域的Matlab仿真,相关matlab代码问题可私信交流。部分理论引用网络文献,若有侵权联系博主删除。


上一篇: 【图像检测】基于计算机视觉实现教室人数统计附matlab代码 下一篇: 【光学】基于matlab模拟双孔干涉附matlab代码