资源简介
该文件中包含了Adaptive as-natural-as-possible image stitching论文以及As-Projective-As-Possible Image Stitching with Moving DLT这两种较为经典的图像拼接方法。具体包含了ransac算法、multi-GSsampling算法、求取单应性矩阵Homography的奇异矩阵算法、相似矩阵变换的求取、图像翘曲、局部单应性矩阵权重占比、图像融合等算法。具体过程为:1.利用sift算法提取特征点 2.利用ransac multi-gs算法求取单应性矩阵H 3.利用moving DLT求取reference image的翘曲 4.利用提到的线性单应性矩阵H_linear求取网格化后的局部单应性矩阵 5.图像融合及拼接
代码片段和文件信息
%**************************************************%
% An implementation of AANAP below:
%
% Lin C C Pankanti S U Ramamurthy K N et al.
% Adaptive as-natural-as-possible image stitching [C]
% 2015 IEEE Conference on Computer Vision and Pattern Recognition (CVPR).
% IEEE 2015: 1155-1163.
%
% Just for fun! For commercial purposes please contact the author.
% by YaqiLYU
% https://www.zhihu.com/question/34535199/answer/135169187
%**************************************************%
close all
run(‘vlfeat-0.9.14/toolbox/vl_setup‘);
addpath(‘modelspecific‘);
addpath(‘mexfiles‘);
addpath(‘multigs‘);
%% Global options
% 0 - Bilinear interpolation implementation by MATLAB,slower but better
% 1 - Nearest neighbor interpolationimplementation by C++ Faster but worse
fast_stitch = 1;
img_n = 2; % only support two image stitching
in_name = cell(img_n1);
in_name{1} = ‘images\images\P1010517.JPG‘;
in_name{2} = ‘images\images\P1010520.JPG‘;
img_n = size(in_name 1);
gamma = 0;
sigma = 12.5;
%% load and preprocessing
I = cell(img_n 1);
for i = 1 : img_n
I{i} = imread(in_name{i});
end
max_size = 1000 * 1000;
imgw = zeros(img_n 1);
imgh = zeros(img_n 1);
for i = 1 : img_n
if numel(I{i}(: : 1)) > max_size
I{i} = imresize(I{i} sqrt(max_size / numel(I{i}(: : 1))));
end
imgw(i) = size(I{i} 2);
imgh(i) = size(I{i} 1);
end
img1 = I{1};
img2 = I{2};
img2 = imresize(img2size(img11)/size(img21));
figure(4)
imshow(img1[]);
pause(0.3);
figure(5)
imshow(img2[]);
pause(0.3);
%% User defined parameters for APAP
clear global;
global fitfn resfn degenfn psize numpar
fitfn = ‘homography_fit‘;
resfn = ‘homography_res‘;
degenfn = ‘homography_degen‘;
psize = 4;
numpar = 9;
M = 500;
thr_g = 0.1;
if fast_stitch
C1 = 100;
C2 = 100;
else
C1 = 200;
C2 = 200;
end
%% SIFT keypoint detection and matching.
[ kp1ds1 ] = vl_sift(single(rgb2gray(img1))‘PeakThresh‘ 0‘edgethresh‘500);
[ kp2ds2 ] = vl_sift(single(rgb2gray(img2))‘PeakThresh‘ 0‘edgethresh‘500);
[match_idxs scores] = vl_ubcmatch(ds1ds2);
f1 = kp1(:match_idxs(1:));
f2 = kp2(:match_idxs(2:));
%% Normalise point distribution and Outlier removal with Multi-GS RANSAC.
% (x1;y1;1;x2;y2;1)
data_orig = [ kp1(1:2match_idxs(1:)) ; ones(1size(match_idxs2)) ;
kp2(1:2match_idxs(2:)) ; ones(1size(match_idxs2)) ];
[ dat_norm_img1T1 ] = normalise2dpts(data_orig(1:3:));
[ dat_norm_img2T2 ] = normalise2dpts(data_orig(4:6:));
data_norm = [ dat_norm_img1 ; dat_norm_img2 ];
% Multi-GS
% rng(0);
[ ~res~~ ] = multigsSampling(100data_normM10);
con = sum(res<=thr_g);
[ ~ maxinx ] = max(con);
inliers = find(res(:maxinx)<=thr_g);
%% Global homography (H) again.
[ HlAD1D2 ] = feval(fitfndata_norm(:inliers));
Hg = T2\(reshape(Hl33)*T1);
Hg = Hg / Hg(33)
%% Compute Global similarity
S = ransac_global_similarity(data_norm(:inliers)data_orig(:inliers)img1img2);
S = T2\(S*T1)
%% Obtaining size of
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-11-17 03:54 AANAP-master\
文件 7955 2017-11-17 03:54 AANAP-master\AANAP.m
文件 1065 2017-11-17 03:54 AANAP-master\LICENSE
文件 2465 2017-11-17 03:54 AANAP-master\README.md
文件 592 2017-11-17 03:54 AANAP-master\apply_mdlt_transform.m
文件 360 2017-11-17 03:54 AANAP-master\compute_weight.m
文件 1280 2017-11-17 03:54 AANAP-master\homography_linearization.m
文件 628 2017-11-17 03:54 AANAP-master\image_blending_average.m
文件 1919 2017-11-17 03:54 AANAP-master\image_blending_linear.m
文件 1894 2017-11-17 03:54 AANAP-master\mdlt_warping.m
文件 579 2017-11-17 03:54 AANAP-master\mesh_warp.m
文件 1520 2017-11-17 03:54 AANAP-master\ransac_global_similarity.m
评论
共有 条评论