tforminv

Apply inverse N-D spatial transformation

The tforminv function is not recommended for 2-D and 3-D geometric transformations. Use the transformPointsInverse function instead. For more information, see Compatibility Considerations.

Description

example

[U1,U2,...,U_ndims_in] = tforminv(T,X1,X2,...,X_ndims_out) applies the ndims_out-to-ndims_in inverse transformation defined in T to the coordinate arrays X1,X2,...,X_ndims_out. The transformation maps the point [X1(k) X2(k) ... X_ndims_out(k)] to the point [U1(k) U2(k) ... U_ndims_in(k)].

The number of input coordinate arrays, ndims_out, must equal T.ndims_out. The number of output coordinate arrays, ndims_in, must equal T.ndims_in. The arrays X1,X2,...,X_ndims_out can have any dimensionality, but must be the same size. The output arrays U1,U2,...,U_ndims_in must be this size also.

U = tforminv(T,X) applies the ndims_out-to-ndims_in inverse transformation defined in T to array X.

• When X is a 2-D matrix with dimensions m-by-ndims_out matrix, U is a 2-D matrix with dimensions m-by-ndims_in. tforminv applies the transformation to each row of X. tforminv maps the point X(k, : ) to the point U(k, : ).

• When X is an (N+1)-dimensional array, tforminv maps the point X(k1, k2, … ,kN, : ) to the point U(k1, k2, … ,kN, : ).

size(X,N+1) must equal ndims_out. U is an (N+1)-dimensional array, with size(U,I) equal to size(X,I) for I = 1, … ,N, and size(U,N+1) equal to ndims_in.

The syntax U = tforminv(X,T) is an older form of this syntax that remains supported for backward compatibility.

[U1,U2,...,U_ndims_in] = tforminv(T,X) maps one (N+1)-dimensional array to ndims_in equally sized N-dimensional arrays.

U = tforminv(T,X1,X2,...,X_ndims_out) maps ndims_out N-dimensional arrays to one (N+1)-dimensional array.

Examples

collapse all

Create an affine transformation that maps the triangle with vertices (0,0), (6,3), (-2,5) to the triangle with vertices (-1,-1), (0,-10), (4,4).

u = [ 0   6  -2]';
v = [ 0   3   5]';
x = [-1   0   4]';
y = [-1 -10   4]';
tform = maketform('affine',[u v],[x y]);

Validate the mapping by applying tforminv. The results should equal u and v.

[um, vm] = tforminv(tform, x, y)
um = 3×1

0
6.0000
-2.0000

vm = 3×1

0
3.0000
5.0000

Input Arguments

collapse all

Spatial transformation, specified as a TFORM spatial transformation structure. Create T using the maketform function.

Data Types: struct

Input coordinate points, specified as a numeric array. The size and dimensionality of X can have additional limitations depending on the syntax used.

Data Types: double

Input coordinate points, specified as multiple numeric arrays. The size and dimensionality of X1,X2,...,X_ndims_out can have additional limitations depending on the syntax used.

Data Types: double

Output Arguments

collapse all

Coordinate array of output points, returned as a numeric array. The size and dimensionality of U can have additional limitations depending on the syntax used.

Coordinates of output points, returned as multiple arrays. The size and dimensionality of U1,U2,...,U_ndims_in can have additional limitations depending on the syntax used.

Compatibility Considerations

expand all

Not recommended starting in R2018b