Basic IMTRANSFORM Example

From MATLAB Techniques for Image Processing by Steve Eddins.

Use imtransform to apply a spatial transform to an image.

Example: Affine transform combining various effects.

Scale in x and y:

A1 = [0.6 0   0
      0   1.7 0
      0   0   1];

Shear:

A2 = [1   0   0
      1.2 1   0
      0   0   1];

Vertical reflection:

A3 = [1  0  0
      0 -1  0
      0  0  1];

Translation:

A4 = [   1    0    0
         0    1    0
      2000 -300    1];

Combine them:

A = A1 * A2 * A3 * A4
A =

   1.0e+03 *

    0.0006         0         0
    0.0020   -0.0017         0
    2.0000   -0.3000    0.0010

Make tform:

tform = maketform('affine',A);

Apply to image using imtransform:

I = imread('liftingbody.png');
imshow(I)
xlabel('Image courtesy of NASA')
I2 = imtransform(I,tform);
imshow(I2)
Warning: Image is too big to fit on screen; displaying at 67% 

Side note: You can control the fill-value color:

I3 = imtransform(I,tform,'FillValue',255);
imshow(I3)
Warning: Image is too big to fit on screen; displaying at 67% 

We can see the effects of the scale, shear, and vertical reflection.

But ...

What about the translation?