The following functions, when used in combination, provide a vast array of options for defining and working with 2-D, N-D, and mixed-D spatial transformations:
tformarray functions use the
internally to encapsulate the forward transformations needed to determine
the extent of an output image or array and/or to map the output pixels/array
locations back to input locations. You can use
explore the geometric effects of a transformation by applying them
to points and lines and plotting the results. They support a consistent
handling of both image and pointwise data.
The following example, Perform the Geometric Transformation, uses the
with a standard interpolation method. You can also use it to obtain
special effects or custom processing. For example, you could specify
your own separable filtering/interpolation kernel, build a custom
resampler around the MATLAB®
or even implement an advanced antialiasing technique.
And, as noted, you can use
work with arbitrary-dimensional array transformations. The arrays
do not even need to have the same dimensions. The output can have
either a lower or higher number of dimensions than the input.
For example, if you are sampling 3-D data on a 2-D slice or manifold, the input array might have a lower dimensionality. The output dimensionality might be higher, for example, if you combine multiple 2-D transformations into a single 2-D to 3-D operation.
For example, this code uses
perform a projective transformation of a checkerboard image.
I = checkerboard(20,1,1); figure; imshow(I) T = maketform('projective',[1 1; 41 1; 41 41; 1 41],... [5 5; 40 5; 35 30; -10 30]); R = makeresampler('cubic','circular'); K = imtransform(I,T,R,'Size',[100 100],'XYScale',1); figure, imshow(K)
imtransform function options let you
control many aspects of the transformation. For example, note how
the transformed image appears to contain multiple copies of the original
image. This is accomplished by using the
to make the output image larger than the input image, and then specifying
a padding method that extends the input image by repeating the pixels
in a circular pattern. The Image Processing Toolbox™ Image Transformation
demos provide more examples of using the
and related functions to perform different types of spatial transformations.