Search code examples
matlabtransformationinterpolationaffinetransform

transformed image should always visible


I am trying to transform an image using Bi-linear interpolation, my input image is I, I have my affine matrix [A], which will give me transformed image I', according to bi-linear interpolation I am taking inverse of affine matrix inv([A]) and applying that to every point of output image(which is all zero at initial level), as we cant guarantee that output image size can be of any size, so first I found the bounds so I can get the size of the output image,

Now I have input image, Affine matrix, and output image which have atleast that size in which transformed image can be saved easily, But If I apply backward backward method of warping, according to that I have to iterate through every pixel of output image(which is zero right now), I want my transformed image at the center so my transformed image should always be visible, any idea how can I do that ?

Note I don't want to use matlab's built in function.

EDIT enter image description here

If I transformed my A Image I got B, but You see corner of the image got cropped, I want those to be shown as well.


Solution

  • When rotating a rectangle from the upright position to a diagonal one, the vertical distance between the highest and lowest point will increase.

    Now there are two approaches you can take:

    • Put the new picture in a bigger environment

    OR

    • Rescale the rotated picture to make it fit in the original sized environment.