Image Processing Toolbox User's Guide Previous page   Next Page

Creating TFORM Structures

After defining the transformation data (Defining the Transformation Data), you must create a TFORM structure to specify the spatial transformation. You use the maketform function to create a TFORM structure. You pass the TFORM structure to the imtransform to perform the transformation. (You can also create a TFORM using the cp2tform function. For more information, see Image Registration.)

The example creates a TFORM structure that specifies the parameters necessary for the translation operation.

To create a TFORM you must specify the type of transformation you want to perform and pass in the transformation data. The example specifies 'affine' as the transformation type because translation is an affine transformation but maketform also supports projective transformations. In addition, by using the custom and composite options you can specify a virtually limitless variety of spatial transformations to be used with imtransform. The following table lists the transformation types supported by maketform.

Transformation Type
Transformation that can include translation, rotation, scaling, and shearing. Straight lines remain straight, and parallel lines remain parallel, but rectangles might become parallelograms.
Transformation in which straight lines remain straight but parallel lines converge toward vanishing points. (The vanishing points can fall inside or outside the image -- even at infinity.)
Special case of an affine transformation where each dimension is shifted and scaled independently.
User-defined transformation, providing the forward and/or inverse functions that are called by imtransform.
Composition of two or more transformations.

Contents of a TFORM Structure

The TFORM structure created by the maketform function is a MATLAB data structure that contains the parameters needed to perform the requested transformation. (These are actually the parameters required by the low-level transformation function tformarray, which imtransform calls to perform the transformation -- see Performing N-Dimensional Spatial Transformations.)

The following table describes each of these fields. Note that you do not have to specify the value of these fields; maketform creates this structure.

Specifies the number of dimensions in the input space. When used with imtransform, this is always be 2.
Specifies the number of dimensions in the output space. When used with imtransform, this is always be 2.
Function handle to the function that performs the forward transformation.
Function handle to the function that performs the inverse transformation.
Structure containing two fields:

The matrix that defines or the forward transformation.

The matrix that defines or the forward transformation.

The tdata field contains the actual transformation matrix that you passed in as an argument or that maketform inferred from the sets of points you specified. For example, the following is the transformation matrix for the forward transformation for the translation in Example: Performing a Translation.

Previous page  Defining the Transformation Data Performing the Spatial Transformation Next page

© 1994-2005 The MathWorks, Inc.