IMTRANSFORM Output Grid 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')

This time, though, we are going to call imtransform and ask for two additional output arguments, xdata and ydata.
[I2,xdata,ydata] = imtransform(I,tform,'FillValue',255);
xdata tells us the x-coordinates of left and right image columns.
xdata
xdata = 1.0e+03 * 2.0026 3.3526
ydata tells us the y-coordinates of the upper and lower image rows.
ydata
ydata = 1.0e+03 * -1.1704 -0.3014
We can pass this coordinate information to imshow.
imshow(I2,'XData',xdata,'YData',ydata) axis on
Warning: Image is too big to fit on screen; displaying at 67%

Now we have enough information to display the input and output image on a common coordinate system.
imshow(I) hold on imshow(I2,'XData',xdata,'YData',ydata) axis auto axis on
