Main Content

affine3d

(Not recommended) 3-D affine geometric transformation using postmultiply convention

affine3d is not recommended. Use the affinetform3d object instead. For more information, see Version History.

Description

An affine3d object stores information about a 3-D affine geometric transformation and enables forward and inverse transformations.

Creation

Description

tform = affine3d creates an affine3d object with default property settings that correspond to the identity transformation.

tform = affine3d(t) sets the property T as the specified 3-D affine transformation matrix t.

example

Properties

expand all

Forward 3-D affine transformation, specified as a nonsingular 4-by-4 numeric matrix.

The matrix T uses the convention:

[x y z 1] = [u v w 1] * T

where T has the form:

 [a b c 0;
  d e f 0;
  g h i 0;
  j k l 1];

The default of T is the identity transformation.

Data Types: double | single

Describes the dimensionality of the geometric transformation for both input and output points, specified as the value 3.

Object Functions

invertInvert geometric transformation
isRigidDetermine if geometric transformation is rigid transformation
isSimilarityDetermine if geometric transformation is similarity transformation
isTranslationDetermine if geometric transformation is pure translation
outputLimitsFind output spatial limits given input spatial limits
transformPointsForwardApply forward geometric transformation
transformPointsInverseApply inverse geometric transformation

Examples

collapse all

Create an affine3d object that scales a 3-D image by a different factor in each dimension.

Sx = 1.2;
Sy = 1.6;
Sz = 2.4;
T = [Sx 0 0 0; 0 Sy 0 0; 0 0 Sz 0; 0 0 0 1];
tform = affine3d(T)
tform = 
  affine3d with properties:

                 T: [4x4 double]
    Dimensionality: 3

Examine the value of the T property.

tform.T
ans = 4×4

    1.2000         0         0         0
         0    1.6000         0         0
         0         0    2.4000         0
         0         0         0    1.0000

Extended Capabilities

Version History

Introduced in R2013a

expand all

R2022b: Not recommended

Starting in R2022b, most Image Processing Toolbox™ functions create and perform geometric transformations using the premultiply convention. Accordingly, the affine3d object is not recommended because it uses the postmultiply convention. Although there are no plans to remove the affine3d object at this time, you can streamline your geometric transformation workflows by switching to the affinetform3d object, which supports the premultiply convention. For more information, see Migrate Geometric Transformations to Premultiply Convention.

To update your code:

  • Change instances of the function name affine3d to affinetform3d.

  • Specify the transformation matrix as the transpose of the matrix T, where T is either the value of the T property of the affine3d object or the transformation matrix used to create the affine3d object.

Discouraged UsageRecommended Replacement

This example creates an affine3d object from transformation matrix T in the postmultiply convention.

T = [2 0 0 0; 0 2 0 0; 0 0 4 0; 5 10 -5 1];
tformPost = affine3d(T);

This example creates an affinetform3d object from the transpose of the transformation matrix T.

T = [2 0 0 0; 0 2 0 0; 0 0 4 0; 5 10 -5 1];
A = T';
tform = affinetform3d(A);

This example starts with an affine3d object called tformPost and creates an affinetform3d object from the transpose of the T property of tformPost.

T = tformPost.T;
tform = affinetform3d(T');