1 基于sift算法实现图像配准算法
模型参考这里。
2 部分代码
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%close all;clear all;%% image pathfile_image='F:\class_file\图像配准\图像配准';%% read images[filename,pathname]=uigetfile({'*.*','All Files(*.*)'},'Reference image',...file_image);image_1=imread(strcat(pathname,filename));[filename,pathname]=uigetfile({'*.*','All Files(*.*)'},'Image to be registered',...file_image);image_2=imread(strcat(pathname,filename));figure;subplot(1,2,1);imshow(image_1);title('Reference image');subplot(1,2,2);imshow(image_2);title('Image to be registered');%% make file for save imagesif (exist('save_image','dir')==0)%如果文件夹不存在mkdir('save_image');endt1=clock;%Start time%% Convert input image format[~,~,num1]=size(image_1);[~,~,num2]=size(image_2);if(num1==3)image_11=rgb2gray(image_1);elseimage_11=image_1;endif(num2==3)image_22=rgb2gray(image_2);elseimage_22=image_2;end%Converted to floating point dataimage_11=im2double(image_11);image_22=im2double(image_22); %% Define the constants usedsigma=1.6;%最底层高斯金字塔的尺度dog_center_layer=3;%定义了DOG金字塔每组中间层数,默认是3contrast_threshold_1=0.03;%Contrast thresholdcontrast_threshold_2=0.03;%Contrast thresholdedge_threshold=10;%Edge thresholdis_double_size=false;%expand image or notchange_form='affine';%change mode,'perspective','affine','similarity'is_sift_or_log='GLOH-like';%Type of descriptor,it can be 'GLOH-like','SIFT'%% The number of groups in Gauss PyramidnOctaves_1=num_octaves(image_11,is_double_size);nOctaves_2=num_octaves(image_22,is_double_size);%% Pyramid first layer imageimage_11=create_initial_image(image_11,is_double_size,sigma);image_22=create_initial_image(image_22,is_double_size,sigma);%% Gauss Pyramid of Reference imagetic;[gaussian_pyramid_1,gaussian_gradient_1,gaussian_angle_1]=...build_gaussian_pyramid(image_11,nOctaves_1,dog_center_layer,sigma); disp(['参考图像创建Gauss Pyramid花费时间是:',num2str(toc),'s']);%% DOG Pyramid of Reference imagetic;dog_pyramid_1=build_dog_pyramid(gaussian_pyramid_1,nOctaves_1,dog_center_layer);disp(['参考图像创建DOG Pyramid花费时间是:',num2str(toc),'s']);%% display the Gauss Pyramid,DOG Pyramid,gradient of Reference imagedisplay_product_image(gaussian_pyramid_1,dog_pyramid_1,gaussian_gradient_1,...gaussian_angle_1,nOctaves_1,dog_center_layer,'Reference image');clear gaussian_pyramid_1;%% Reference image DOG Pyramid extreme point detectiontic;[key_point_array_1]=find_scale_space_extream...(dog_pyramid_1,nOctaves_1,dog_center_layer,contrast_threshold_1,sigma,...edge_threshold,gaussian_gradient_1,gaussian_angle_1);disp(['参考图像关键点定位花费时间是:',num2str(toc),'s']);clear dog_pyramid_1;%% descriptor generation of the reference image tic;[descriptors_1,locs_1]=calc_descriptors(gaussian_gradient_1,gaussian_angle_1,...key_point_array_1,is_double_size,is_sift_or_log);disp(['参考图像描述符生成花费时间是:',num2str(toc),'s']); clear gaussian_gradient_1;clear gaussian_angle_1;%% Gauss Pyramid of the image to be registeredtic;[gaussian_pyramid_2,gaussian_gradient_2,gaussian_angle_2]=...build_gaussian_pyramid(image_22,nOctaves_2,dog_center_layer,sigma); disp(['待配准图像创建Gauss Pyramid花费时间是:',num2str(toc),'s']);%% DOG of the image to be registeredtic;dog_pyramid_2=build_dog_pyramid(gaussian_pyramid_2,nOctaves_2,dog_center_layer);disp(['待配准图像创建DOG Pyramid花费时间是:',num2str(toc),'s']);display_product_image(gaussian_pyramid_2,dog_pyramid_2,gaussian_gradient_2,...gaussian_angle_2,nOctaves_2,dog_center_layer,'Image to be registered');clear gaussian_pyramid_2;%% Image to be registered DOG Pyramid extreme point detectiontic;[key_point_array_2]=find_scale_space_extream...(dog_pyramid_2,nOctaves_2,dog_center_layer,contrast_threshold_2,sigma,....edge_threshold,gaussian_gradient_2,gaussian_angle_2);disp(['待配准图像关键点定位花费时间是:',num2str(toc),'s']);clear dog_pyramid_2;%% descriptor generation of the Image to be registeredtic;[descriptors_2,locs_2]=calc_descriptors(gaussian_gradient_2,gaussian_angle_2,...key_point_array_2,is_double_size,is_sift_or_log);disp(['待配准图像描述符生成花费时间是:',num2str(toc),'s']); clear gaussian_gradient_2;clear gaussian_angle_2;%% matchtic;[solution,rmse,cor1,cor2]=...match(image_2, image_1,descriptors_2,locs_2,descriptors_1,locs_1,change_form);disp(['特征点匹配花费时间是:',num2str(toc),'s']);
3 仿真结果
4 参考文献
[1]汪道寅. 基于SIFT图像配准算法的研究[D]. 中国科学技术大学.