Create spatial transformation structure (TFORM
)
maketform
is not recommended. Use fitgeotrans
, affine2d
, affine3d
,
or projective2d
instead.
T = maketform(
transformtype
,...)
T = maketform('affine',A)
T = maketform('affine',U,X)
T = maketform('projective',A)
T = maketform('projective',U,X)
T = maketform('custom', NDIMS_IN, NDIMS_OUT, FORWARD_FCN,
INVERSE_FCN, TDATA)
T = maketform('box',tsize,LOW,HIGH)
T = maketform('box',INBOUNDS, OUTBOUNDS)
T = maketform('composite',T1,T2,...,TL)
T = maketform('composite', [T1 T2 ... TL])
T = maketform(
creates
a multidimensional spatial transformation structure (called a transformtype
,...)TFORM
struct)
that can be used with the tformfwd
, tforminv
, fliptform
, imtransform
,
or tformarray
functions.
transformtype
can be any of the following
spatial transformation types. maketform
supports
a special syntax for each transformation type. See the following sections
for information about these syntax.
Transform Type  Description 

 Affine transformation in 2D or ND 
Projective transformation in 2D or ND  
 Userdefined transformation that can be ND to MD 
 Independent affine transformation (scale and shift) in each dimension 
Composition of an arbitrary number of more basic transformations 
T = maketform('affine',A)
builds a TFORM
struct T
for
an Ndimensional affine transformation. A
is a
nonsingular real (N+1)by(N+1) or (N+1)byN matrix. If A
is
(N+1)by(N+1), the last column of A
must be [zeros(N,1);1]
.
Otherwise, A
is augmented automatically, such that
its last column is [zeros(N,1);1]
. The matrix A
defines
a forward transformation such that tformfwd(U,T)
,
where U
is a 1byN vector, returns a 1byN vector X
,
such that X = U * A(1:N,1:N) + A(N+1,1:N)
. T
has
both forward and inverse transformations.
T = maketform('affine',U,X)
builds a TFORM
struct T
for
a twodimensional affine transformation that maps each row of U
to
the corresponding row of X
. The U
and X
arguments
are each 3by2 and define the corners of input and output triangles.
The corners cannot be collinear.
T = maketform('projective',A)
builds a TFORM
struct
for an Ndimensional projective transformation. A
is
a nonsingular real (N+1)by(N+1) matrix. A(N+1,N+1)
cannot
be 0. The matrix A
defines a forward transformation
such that tformfwd(U,T)
, where U
is
a 1byN vector, returns a 1byN vector X
, such
that X = W(1:N)/W(N+1)
, where W = [U 1]
* A
. The transformation structure T
has
both forward and inverse transformations.
T = maketform('projective',U,X)
builds
a TFORM
struct T
for a twodimensional
projective transformation that maps each row of U
to
the corresponding row of X
. The U
and X
arguments
are each 4by2 and define the corners of input and output quadrilaterals.
No three corners can be collinear.
Note:
An affine or projective transformation can also be expressed
like this, for a 3by2 [X Y]' = A' * [U V 1] ' Or, like this, for a 3by3 [X Y 1]' = A' * [U V 1]' 
T = maketform('custom', NDIMS_IN, NDIMS_OUT, FORWARD_FCN,
INVERSE_FCN, TDATA)
builds a custom TFORM
struct T
based
on userprovided function handles and parameters. NDIMS_IN
and NDIMS_OUT
are
the numbers of input and output dimensions. FORWARD_FCN
and INVERSE_FCN
are
function handles to forward and inverse functions. Those functions
must support the following syntax:
Forward function: 

Inverse function: 

where U
is a P
byNDIMS_IN
matrix
whose rows are points in the transformation's input space, and X
is
a P
byNDIMS_OUT
matrix whose
rows are points in the transformation's output space. The TDATA
argument
can be any MATLAB^{®} array and is typically used to store parameters
of the custom transformation. It is accessible to FORWARD_FCN
and INVERSE_FCN
via
the tdata
field of T
. Either FORWARD_FCN
or INVERSE_FCN
can
be empty, although at least INVERSE_FCN
must be
defined to use T
with tformarray
or imtransform
.
T = maketform('box',tsize,LOW,HIGH)
orT = maketform('box',INBOUNDS, OUTBOUNDS)
builds
an Ndimensional affine TFORM
struct T
.
The tsize
argument is an Nelement vector of positive
integers. LOW
and HIGH
are also
Nelement vectors. The transformation maps an input box defined by
the opposite corners ones(1,N)
and tsize
or,
alternatively, by corners INBOUNDS(1,:)
and INBOUND(2,:)
to
an output box defined by the opposite corners LOW
and HIGH
or OUTBOUNDS(1,:)
and OUTBOUNDS(2,:)
. LOW(K)
and HIGH(K)
must
be different unless tsize(K)
is 1, in which case
the affine scale factor along the Kth dimension is assumed to be 1.0.
Similarly, INBOUNDS(1,K)
and INBOUNDS(2,K)
must
be different unless OUTBOUNDS(1,K)
and OUTBOUNDS(2,K)
are
the same, and vice versa. The 'box'
TFORM
is
typically used to register the row and column subscripts of an image
or array to some world coordinate system.
T = maketform('composite',T1,T2,...,TL)
orT = maketform('composite', [T1 T2 ... TL])
builds
a TFORM
struct T
whose forward
and inverse functions are the functional compositions of the forward
and inverse functions of T1, T2, ..., TL
.
Note that the inputs T1, T2, ..., TL
are
ordered just as they would be when using the standard notation for
function composition: T = T1
$$\circ $$ T2
$$\circ $$ ... $$\circ $$ TL
and note
also that composition is associative, but not commutative. This means
that in order to apply T
to the input U
,
one must apply TL
first and T1
last.
Thus if L = 3
, for example, then tformfwd(U,T)
is
the same as tformfwd(tformfwd(tformfwd(U,T3),T2),T1)
.
The components T1
through TL
must
be compatible in terms of the numbers of input and output dimensions. T
has
a defined forward transform function only if all the component transforms
have defined forward transform functions. T
has
a defined inverse transform function only if all the component functions
have defined inverse transform functions.
Make and apply an affine transformation.
T = maketform('affine',[.5 0 0; .5 2 0; 0 0 1]); tformfwd([10 20],T) I = imread('cameraman.tif'); I2 = imtransform(I,T); imshow(I), figure, imshow(I2)
fliptform
 imtransform
 tformarray
 tformfwd
 tforminv