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 ofdimensions of the input and output space.
"forward_fcn"
, "inverse_fcn"
: the callbackfunctions that are called for forward (input to output) and inverse transform.
"tdata"
: an inverse transform matrix or a structurecontaining forward and inverse transform matrices.
The content of each field depends on the requested transform type ttype:
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 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")
.
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