原文:http://blogs.mathworks.com/steve/2006/06/13/spatial-transformations-findbounds/
To avoid these problems (and to avoid the tech support calls!), the function imtransform uses the function findbounds to determine automatically where to place the output grid and how big it should be.
findbounds first creates a grid of points. These points are located in input space at each corner of the image, as well as in between each corner and in the middle. It looks like this:
I = imread('rice.png');
h = imshow(I);
set(h,'AlphaData',0.3);
axis on, grid on
in_points = [ ...
0.5000 0.5000
0.5000 256.5000
256.5000 0.5000
256.5000 256.5000
0.5000 128.5000
128.5000 0.5000
128.5000 128.5000
128.5000 256.5000
256.5000 128.5000];
hold on
plot(in_points(:,1), in_points(:,2), '.', 'MarkerSize', 18)
hold off
findbounds then calls tformfwd to transform these points into output space. (For this example I'm going to construct an affine tform struct that combines scaling, rotation, shear, and a large translation.)
tform = maketform('affine', ...
[1.1067 -0.2341 0; 0.5872 1.1769 0; 1000 -300 1]);
out_points = tformfwd(tform, in_points)
plot(out_points(:,1), out_points(:,2), '.', 'MarkerSize', 18)
axis ij, axis image
grid on
The bounding box of the points in output space tells us where to put the output space grid.
When you call imtransform, you can use optional output arguments to determine where the image is located in output space.
[J,XData,YData] = imtransform(I, tform);
XData
You can use this information together with
imshow to place the image in the right place on an axes that contains other X-Y data.
h = imshow(J,'XData',XData,'YData',YData);
set(h,'AlphaData',0.3)
hold on
plot(out_points(:,1), out_points(:,2), '.', 'MarkerSize', 18)
axis on
grid on
hold off
axis ij, axis image
So that's the method
imtransform uses to determine where the output image should be in output space.