Function File: T = maketform (ttype, tmat)
Function File: T = maketform (ttype, inc, outc)
Function File: T = maketform ("custom", ndims_in, ndims_out, forward_fcn, inverse_fcn, tdata)

Create a transform structure T to be used for spatial transformations between an input space and an output space.

The fields of the transform structure are:

"ndims_in", "ndims_out": the number of

dimensions of the input and output space.

"forward_fcn", "inverse_fcn": the callback

functions that are called for forward (input to output) and inverse transform.

"tdata": an inverse transform matrix or a structure

containing forward and inverse transform matrices.

The content of each field depends on the requested transform type ttype:

"projective"

A ndims_in = ndims_out = N projective transform structure is returned. If a second input argument tmat is provided, it must be a (N+1)-by-(N+1) inverse transformation matrix. The (N+1)th column must contain projection coefficients. As an example a two dimensional inverse transform from [x y] coordinates to [u v] coordinates is represented by an inverse transformation matrix defined so that:

[xx yy zz] = [u v 1] * [a d g;
                        b e h;
                        c f i]
[x y] =  [xx./zz yy./zz];

Alternatively the transform can be specified using the coordinates of a quadrilateral (typically the 4 corners of the image) in the input space (inc, 4-by-ndims_in matrix) and in the output space (outc, 4-by-ndims_out matrix). This is equivalent to building the transform using T = cp2tform (inc, outc, "projective").

"affine"

Affine is a subset of projective transform (see above). A ndims_in = ndims_out = N affine transformation structure is returned. If a second input argument tmat is provided, it must be a (N+1)-by-(N+1) or (N+1)-by-(N) transformation matrix. If present, the (N+1)th column must contain [zeros(N,1); 1] so that projection is suppressed.

Alternatively the transform can be specified using the coordinates of a triangle (typically 3 corners of the image) in the input space (inc, 3-by-ndims_in matrix) and in the output space (outc, 3-by-ndims_out matrix). This is equivalent to building the transform using T = cp2tform (inc, outc, "affine").

"custom"

For user defined transforms every field of the transform structure must be supplied. The prototype of the transform functions, forward_fcn and inverse_fcn, should be X’ = transform_fcn (X, T). X and X’ are respectively p-by-ndims_in and p-by-ndims_out arrays for forward_fcn and reversed for inverse_fcn. The argument T is the transformation structure which will contain the user supplied transformation matrix tdata.

See also: tformfwd, tforminv, cp2tform.

Package: image