【图像配准】基于SIFT实现图像配准拼接含Matlab源码

 1 简介

图像拼接技术是数字图像处理邻域的一个研究热点.近年来,随着技术的成熟,图像拼接技术被很好的应用到了机器人导航,无人平台战场监控,航拍图像处理等多个领域.基于特征的图像配准与拼接技术配准结果准确拼接效果良好且不易受光照,旋转等因素的影响是当前图像配准与拼接领域研究的热点.

2 部分代码

function varargout = ImageRegistration(varargin)
% IMAGEREGISTRATION MATLAB code for ImageRegistration.fig
%      IMAGEREGISTRATION, by itself, creates a new IMAGEREGISTRATION or raises the existing
%      singleton*.
%
%      H = IMAGEREGISTRATION returns the handle to a new IMAGEREGISTRATION or the handle to
%      the existing singleton*.
%
%      IMAGEREGISTRATION('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in IMAGEREGISTRATION.M with the given input arguments.
%
%      IMAGEREGISTRATION('Property','Value',...) creates a new IMAGEREGISTRATION or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before ImageRegistration_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to ImageRegistration_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
%  

% Edit the above text to modify the response to help ImageRegistration

%  

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @ImageRegistration_OpeningFcn, ...
                   'gui_OutputFcn',  @ImageRegistration_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

addpath(pwd);
% --- Executes just before ImageRegistration is made visible.
function ImageRegistration_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to ImageRegistration (see VARARGIN)5

% Choose default command line output for ImageRegistration
handles.output = hObject;

% 消除axes坐标轴
set(handles.axes1,'Xtick',[],'Ytick',[]);
set(handles.axes1,'Xcolor',[1 1 1],'Ycolor',[1 1 1]);
set(handles.axes2,'Xtick',[],'Ytick',[]);
set(handles.axes2,'Xcolor',[1 1 1],'Ycolor',[1 1 1]);
set(handles.axes3,'Xtick',[],'Ytick',[]);
set(handles.axes3,'Xcolor',[1 1 1],'Ycolor',[1 1 1]);
set(handles.axes4,'Xtick',[],'Ytick',[]);
set(handles.axes4,'Xcolor',[1 1 1],'Ycolor',[1 1 1]);
set(handles.axes5,'Xtick',[],'Ytick',[]);
set(handles.axes5,'Xcolor',[1 1 1],'Ycolor',[1 1 1]);

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes ImageRegistration wait for user response (see UIRESUME)
% uiwait(handles.figure1);



end
diff1 = im2bw(diff1,graythresh(diff1));
figure,imshow(diff1)
% 标出变化区域
axes(handles.axes5)
imshow(BaseImage)
hold on;
[L,num] = bwlabel(diff1,4);
for i=1:num
    [m{i},n{i}] = find(L == i);
    if length(m{i})*length(n{i}) > 20 % 判断变化区域面积
        height = max(m{i}) - min(m{i});
        width = max(n{i}) - min(n{i});
        if height <= 0 || width <= 0 % 变化区域宽或高太小都舍弃
            continue;
        end
        rectangle('position',[min(n{i}) min(m{i}) width height],'curvature',[1,1],'edgecolor','r');
        hold on;
    end
end
hold off;
%   % 显示阈值处理过后的差分结果
%   axes(handles.axes5)
%   imshow(diff1);
  
  
global matchTable;
% global img3;
% global loc1;
% global loc2;
% global des1;
  % Show a figure with lines joining the accepted matches.
%展示一张用线连接两图
% axes(handles.axes4)
% % figure('Position', [100 100 size(img3,2) size(img3,1)]);
% colormap('gray');
% imagesc(img3);
% hold on;
% cols1 = size(BaseImage,2);
% for i = 1: size(des1,1)
%   if (matchTable(i) > 0)
%     line([loc1(i,2) loc2(matchTable(i),2)+cols1], ...
%          [loc1(i,1) loc2(matchTable(i),1)], 'Color', 'c');
%   end
% end
% hold off;
% set(handles.axes4,'Xtick',[],'Ytick',[]);
% set(handles.axes4,'Xcolor',[1 1 1],'Ycolor',[1 1 1]);
num = sum(matchTable > 0);

% 显示配准参数
Matchkey=sprintf('Match Keypoints=[%d]',num);
set(handles.text6,'string',Matchkey);
set(handles.text7,'string',ElapsedTime);
  

% --------------------------------------------------------------------
function uipushtool1_ClickedCallback(hObject, eventdata, handles)
% hObject    handle to uipushtool1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[filename,pathname] = uiputfile({'*.jpg','JPEG(*.jpg)';...
    '*.bmp','Bitmap(*.bmp)';...
    '*.gif','GIF(*.gif)';...
    '*.*',  'All Files (*.*)'},...
    '保存图片','Untitled');
if filename==0
    return;
else
    imname = fullfile(pathname,filename);
    pix=getframe(handles.axes5);
    imwrite(pix.cdata,imname);
end

 


3 仿真结果

4 参考文献

[1]袁杰. 基于SIFT的图像配准与拼接技术研究[D]. 南京理工大学.​

博主简介:擅长智能优化算法神经网络预测信号处理元胞自动机图像处理路径规划无人机雷达通信无线传感器等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

matlab科研助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值