【发布时间】:2019-12-18 07:59:15
【问题描述】:
我正在处理一些公路照片,我必须转换捕捉到的视角。我的目标是将道路变成一个广场。我的照片看起来和这张类似:
但是,我需要将道路做成正方形,而不是三角形或梯形,这样我才能在上面工作。
我有我照片中的俯仰角、偏航角和滚动角。
我正在尝试这个:
roll_x = 178.517332325424462;
pitch_y = -0.829084891331837937;
pan_z = -0.668910403057581759;
%% Transform perspective
img = imread('imageLoaded.png');
R_rot = R_z(pan_z)*R_y(pitch_y)*R_x(roll_x);
R_2d = [ R_rot(1,1) R_rot(1,2) 0;
R_rot(2,1) R_rot(2,2) 0;
0 0 1 ];
tform = affine2d(R_2d);
outputImage = imwarp(img,tform);
figure(1);
imshow(outputImage);
%% Matrix for Yaw-rotation about the Z-axis
function [R] = R_z(psi)
R = [cosd(psi) -sind(psi) 0;
sind(psi) cosd(psi) 0;
0 0 1];
end
%% Matrix for Pitch-rotation about the Y-axis
function [R] = R_y(theta)
R = [cosd(theta) 0 sind(theta);
0 1 0 ;
-sind(theta) 0 cosd(theta) ];
end
%% Matrix for Roll-rotation about the X-axis
function [R] = R_x(phi)
R = [1 0 0;
0 cosd(phi) -sind(phi);
0 sind(phi) cosd(phi)];
end
但我正在旋转图像,而不是转换它。我怎样才能实现我的目标?
【问题讨论】:
标签: matlab image-processing toolbox