TransformJ: Affine


General Description

This plugin enables you to apply affine transformations to images. Several types of interpolation can be chosen for this operation. Note that this is the most generic, and therefore also the most computationally demanding plugin in the TransformJ package. If you just want to rotate, or scale, or shift an image, it is better to use, respectively, the Rotate, Scale, or Shift plugin.

Affine Dialog

Description of Dialog Components

Matrix file. The transformation is determined entirely by a 4 x 4 matrix, applied to input positions expressed in homogeneous coordinates [1,2] as in the following equation:

Affine Transformation Equation

The matrix file should be a tab-delimited text file (comma- and space-delimited text files are also accepted) containing exactly four rows and four columns representing the affine transformation matrix. The full path of the file should be given, which is most easily done by pressing the F1 key on your keyboard while the cursor is in the text field. This opens a file dialog, which enables you to browse folders for matrix files. The transformation corresponding to the selected matrix file is applied to every time frame in every channel of a 5D image.

A right-handed coordinate system is assumed for transformation, where the origin is taken precisely in the center of the image or volume, and where the x-axis is taken horizontally on the screen (with increasing x-coordinate when moving from left to right), the y-axis is taken vertically on the screen (with increasing y-coordinate when moving from top to bottom), and finally the z-axis is taken perpendicular to the screen (with increasing z-coordinate when moving away from the observer, "into the screen").


Right-Handed Coordinate System

Interpolation scheme. Obviously, affine transformation can be done only by applying some form of interpolation. The currently available interpolation schemes for this operation are: nearest-neighbor interpolation, linear interpolation, cubic convolution interpolation [3], cubic B-spline interpolation [4,5,6], cubic O-MOMS interpolation [7], and quintic B-spline interpolation [4,5,6], where, in general, the quality of the interpolations should increase in this order.

Background value. Usually, parts of the transformed image are not filled, simply because the image elements (pixels/voxels) in those regions do not correspond to positions within the input image. These remaining parts of the result image are filled with the given value.

Adjust size to fit result. In most cases, the affine transformation causes parts of the input image to fall outside the result image, if its size is kept equal to that of the input image. You can choose to adjust the size of the result image so that it fits the entire transformed image.

Anti-alias borders. In order for the linear and higher-order interpolation schemes to operate properly, a bordered copy of the input image is used internally. The standard setting is that the borders of this copy are filled by mirroring the values in the image. However, the elements in the transformed image which correspond to positions outside the borders of the input image are always filled with the background value. This may cause a "stair-casing" effect (also referred to as "aliasing" by some) at the borders. By selecting the anti-alias option, the borders in the copy of the input image are not mirrored, but entirely filled with the chosen background value. This generally results in a smoother transition between the borders of the rotated image and the background. Note, however, that when using this option in the case of a 3D or higher-dimensional data set, the first and last few slices of the volume(s) in the result may have a reduced intensity. My recommendation would be, therefore, to use this option only when transforming 2D photographs (as I did with the clown image on the TransformJ front page).


Algorithmic Details

Concerning memory usage, it is important to know that the algorithm works with a bordered copy of the input image. This is done in order to solve the boundary problem, but also because some of the interpolation schemes require recursive prefiltering of the input image. Since the prefiltering operations need to be carried out with high accuracy, the bordered copy is always stored in floating-point format.


References

[1]G. Wolberg. Digital Image Warping. IEEE Computer Society Press, Washington, DC, 1990.
[2]J. Foley, A. van Dam, S. K. Feiner, J. F. Hughes. Computer Graphics: Principles and Practice. 2nd edition, Systems Programming Series, Addison-Wesley, Reading, MA, 1990.
[3]R. G. Keys. Cubic Convolution Interpolation for Digital Image Processing. IEEE Transactions on Acoustics, Speech, and Signal Processing, vol. 29, no. 6, 1981, pp. 1153-1160.
[4]M. Unser. Splines: A Perfect Fit for Signal and Image Processing. IEEE Signal Processing Magazine, vol. 16, no. 6, 1999, pp. 22-38.
[5]P. Thevenaz, T. Blu, M. Unser. Interpolation Revisited. IEEE Transactions on Medical Imaging, vol. 19, no. 7, 2000, pp. 739-758.
[6]E. H. W. Meijering, W. J. Niessen, M. A. Viergever. Quantitative Evaluation of Convolution-Based Methods for Medical Image Interpolation. Medical Image Analysis, vol. 5, no. 2, 2001, pp. 111-126.
[7]T. Blu, P. Thevenaz, M. Unser. MOMS: Maximal-Order Interpolation of Minimal Support. IEEE Transactions on Image Processing, vol. 10, no. 7, 2001, pp. 1069-1080.
Copyright © 1996 - 2010 Erik Meijering