4.0 分
其他
图像拼接
% load input images
I1 = double(imread('left.jpg'));
[h1 w1 d1] = size(I1);
I2 = double(imread('right.jpg'));
[h2 w2 d2] = size(I2);
% show input images and prompt for correspondences
figure; subplot(1,2,1); image(I1/255); axis image; hold on;
title('first input image');
[X1 Y1] = ginput2(2); % get two points from the user
subplot(1,2,2); image(I2/255); axis image; hold on;
title('second input image');
[X2 Y2] = ginput2(2); % get two points from the user
% estimate parameter vector (t)
Z = [ X2' Y2' ; Y2' -X2' ; 1 1 0 0 ; 0 0 1 1 ]';
xp = [ X1 ; Y1 ];
t = Z \ xp; % solve the linear system
a = t(1); % = s cos(alpha)
b = t(2); % = s sin(alpha)
tx = t(3);
ty = t(4);
% construct transformation matrix (T)
T = [a b tx ; -b a ty ; 0 0 1];
% warp incomi
matlab
图像
拼接
暂无评论