当前位置 : 主页 > 编程语言 > python >

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

来源:互联网 收集:自由互联 发布时间:2022-09-29
1 内容介绍 图像配准(imageregistration)是将不同时相(获取时间)、不同传感器(成像设备)或不同条件(天候、照度、摄像位置和角度)下获取的2景或多景图像进行几何匹配的过程。随着信息技

1 内容介绍

图像配准(imageregistration)是将不同时相(获取时间)、不同传感器(成像设备)或不同条件(天候、照度、摄像位置和角度)下获取的2景或多景图像进行几何匹配的过程。随着信息技术的迅猛发展,传统的基于灰度值和变换域的图像配准技术已难以满足需要,基于影像特征的高精度图像配准方法已经成为当前图像配准技术的研究趋势。近年来,国内外涌现出了大量基于影像特征的图像配准方法研究,包括特征点、边缘、区域和轮廓等。特征点的提取相对容易,且不易受空间分辨率、光照条件等图像变化的影响而被广泛应用。SURF算法是在SIFT算法的基础上提出的一种快速鲁棒特征提取的配准算法。基于SURF算法的图像配准主要包括图像特征点提取、特征点匹配、去除误匹配点、确定匹配模型和图像重采样4个方面。而在利用传统SURF算法进行图像配准时,提取的特征点分布不均,会导致匹配的特征点出现局部集中现象,使图像配准误差较大而影响整体配准的精度。

2 部分代码

function ipts=OpenSurf(img,Options)

% This function OPENSURF, is an implementation of SURF (Speeded Up Robust 

% Features). SURF will detect landmark points in an image, and describe

% the points by a vector which is robust against (a little bit) rotation 

% ,scaling and noise. It can be used in the same way as SIFT (Scale-invariant 

% feature transform) which is patented. Thus to align (register) two 

% or more images based on corresponding points, or make 3D reconstructions.

%

% This Matlab implementation of Surf is a direct translation of the 

% OpenSurf C# code of Chris Evans, and gives exactly the same answer. 

% Chris Evans wrote one of the best, well structured all inclusive SURF 

% implementations. On his site you can find Evaluations of OpenSURF 

% and the C# and C++ code. http://www.chrisevansdev.com/opensurf/

% Chris Evans gave me permisson to publish this code under the (Mathworks)

% BSD license.

%

% Ipts = OpenSurf(I, Options)

%

% inputs,

%   I : The 2D input image color or greyscale

%   (optional)

%   Options : A struct with options (see below)

%

% outputs,

%   Ipts : A structure with the information about all detected Landmark points

%     Ipts.x , ipts.y : The landmark position

%     Ipts.scale : The scale of the detected landmark

%     Ipts.laplacian : The laplacian of the landmark neighborhood

%     Ipts.orientation : Orientation in radians

%     Ipts.descriptor : The descriptor for corresponding point matching

%

% options,

%   Options.verbose : If set to true then useful information is 

%                     displayed (default false)

%   Options.upright : Boolean which determines if we want a non-rotation

%                       invariant result (default false)

%   Options.extended : Add extra landmark point information to the

%                   descriptor (default false)

%   Options.tresh : Hessian response treshold (default 0.0002)

%   Options.octaves : Number of octaves to analyse(default 5)

%   Options.init_sample : Initial sampling step in the image (default 2)

%   

% Example 1, Basic Surf Point Detection

% % Load image

%   I=imread('TestImages/test.png');

% % Set this option to true if you want to see more information

%   Options.verbose=false; 

% % Get the Key Points

%   Ipts=OpenSurf(I,Options);

% % Draw points on the image

%   PaintSURF(I, Ipts);

%

% Add subfunctions to Matlab Search path

functionname='OpenSurf.m';  %函数名字

functiondir=which(functionname);%which()找出函数与文件所在的目录名

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

addpath([functiondir '/SubFunctions'])

       

% Process inputs

defaultoptions=struct('tresh',0.0002,'octaves',5,'init_sample',2,'upright',false,'extended',false,'verbose',false);

if(~exist('Options','var')),   

    Options=defaultoptions; 

else

    tags = fieldnames(defaultoptions);

    for i=1:length(tags)

         if(~isfield(Options,tags{i})),  Options.(tags{i})=defaultoptions.(tags{i}); end

    end

    if(length(tags)~=length(fieldnames(Options))), 

        warning('register_volumes:unknownoption','unknown options found');

    end

end


% Create Integral Image创建积分图像

img=IntegralImage_IntegralImage(img);


% Extract the interest points提取兴趣点

FastHessianData.thresh = Options.tresh;

FastHessianData.octaves = Options.octaves;

FastHessianData.init_sample = Options.init_sample;

FastHessianData.img = img;

ipts = FastHessian_getIpoints(FastHessianData,Options.verbose);


% Describe the interest points描述兴趣点

if(~isempty(ipts))

    ipts = SurfDescriptor_DecribeInterestPoints(ipts,Options.upright, Options.extended, img, Options.verbose);%调用描述特征点子程序SurfDescriptor_DecribeInterestPoints

end

3 运行结果

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

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

4 参考文献

[1]杨海燕, 罗文超, and 刘国栋. "基于SURF算法和SC-RANSAC算法的图像配准." 计算机应用研究 30.5(2013):3.

[2]高素青, 谭勋军, 黄承夏. 一种基于SURF的图像配准改进算法[J]. 解放军理工大学学报:自然科学版, 2013, 14(4):5.

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


网友评论