【圖像配準】基于surf算法實現(xiàn)圖像配準附Matlab代碼
【圖像配準】基于surf算法實現(xiàn)圖像配準附Matlab代碼
TT_Matlab
博主簡介:擅長智能優(yōu)化算法、神經(jīng)網(wǎng)絡預測、信號處理、元胞自動機、圖像處理、路徑規(guī)劃、無人機等多種領域的Matlab仿真,完整matlab代碼或者程序定制加qq1575304183。
1 內(nèi)容介紹
傳統(tǒng)的全景圖像配準多采用基于SIFT的方法,該方法數(shù)據(jù)量大,時間效率低.提出了一種基于SURF的全景圖像快速配準方法.運用SU RF提取特征點,計算特征描述符;運用低時間復雜度的K-D樹最近鄰搜索法實現(xiàn)特征點快速匹配;利用RANSAC算法剔除誤匹配點;最后估計出兩幅全景圖像的變換矩陣.測試表明:算法具有較高的時間效率和良好的魯棒性.
2 部分代碼
% Example 3, Affine registration
% Load images
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. ’, size(Pos1,1)) ;
fprintf(’Matched in %.3f s ’, toc) ;
3 運行結果
4 參考文獻
[1]陽吉斌, 胡訪宇, 朱高. 基于改進SURF算法的遙感圖像配準[J]. 電子測量技術, 2012, 35(3):5.
博主簡介:擅長 智能優(yōu)化算法 、 神經(jīng)網(wǎng)絡預測 、 信號處理 、 元胞自動機 、 圖像處理 、 路徑規(guī)劃 、 無人機 、 雷達通信 、 無線傳感器 等多種領域的Matlab仿真,相關matlab代碼問題可私信交流。
部分理論引用網(wǎng)絡文獻,若有侵權聯(lián)系博主刪除。
-
2023年血糖新標準公布,不是3.9-6.1,快來看看你的血糖正常嗎? 2023-02-07
-
2023年各省最新電價一覽!8省中午執(zhí)行谷段電價! 2023-01-03
-
PPT導出高分辨率圖片的四種方法 2022-09-22
-
2023年最新!國家電網(wǎng)27家省級電力公司負責人大盤點 2023-03-14
-
全國消防救援總隊主官及簡歷(2023.2) 2023-02-10
-
盤點 l 中國石油大慶油田現(xiàn)任領導班子 2023-02-28
-
我們的前輩!歷屆全國工程勘察設計大師完整名單! 2022-11-18
-
關于某送變電公司“4·22”人身死亡事故的快報 2022-04-26
