Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So, this is what I ended up doing: I figured that unless you are actually dealing with 3D images, rectifying the perspective of a photo is a 2D operation. With this in mind, I replaced the z-axis values of the transformation matrix with zeros and ones, and applied a 2D Affine transformation to the image.</p> <p>Rotation of the initial image (see initial post) with measured Roll = -10 and Pitch = -30 was done in the following manner:</p> <pre><code>R_rotation = R_y(-60)*R_x(10); R_2d = [ R_rot(1,1) R_rot(1,2) 0; R_rot(2,1) R_rot(2,2) 0; 0 0 1 ] </code></pre> <p>This implies a rotation of the camera platform to a virtual camera orientation where the camera is placed above the scene, pointing straight downwards. Note the values used for roll and pitch in the matrix above.</p> <p>Additionally, if rotating the image so that is aligned with the platform heading, a rotation about the z-axis might be added, giving:</p> <pre><code>R_rotation = R_y(-60)*R_x(10)*R_z(some_heading); R_2d = [ R_rot(1,1) R_rot(1,2) 0; R_rot(2,1) R_rot(2,2) 0; 0 0 1 ] </code></pre> <p>Note that this does not change the actual image - it only rotates it.</p> <p>As a result, the initial image rotated about the Y- and X-axes looks like:</p> <p><img src="https://i.stack.imgur.com/FBJA7.jpg" alt="enter image description here"></p> <p>The full code for doing this transformation, as displayed above, was:</p> <pre><code>% Load image img = imread('initial_image.jpg'); % Full rotation matrix. Z-axis included, but not used. R_rot = R_y(-60)*R_x(10)*R_z(0); % Strip the values related to the Z-axis from R_rot R_2d = [ R_rot(1,1) R_rot(1,2) 0; R_rot(2,1) R_rot(2,2) 0; 0 0 1 ]; % Generate transformation matrix, and warp (matlab syntax) tform = affine2d(R_2d); outputImage = imwarp(img,tform); % Display image figure(1), imshow(outputImage); %*** Rotation Matrix Functions ***% %% 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 </code></pre> <p>Thank you for the support, I hope this helps someone! </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload