Main Content

fitgeotform3d

Fit 3-D geometric transformation to control point pairs

Since R2024a

    Description

    example

    tform = fitgeotform3d(movingPoints,fixedPoints,tformType) fits a 3-D linear transformation of type tformType to the control point pairs movingPoints and fixedPoints. The returned transformation maps control point locations from the moving image to the fixed image in the forward direction.

    Examples

    collapse all

    Calculate the affine transformation that describes the spatial relationship between four pairs of control points.

    Specify the xyz-coordinates of the moving points and fixed points.

    movingPoints = [0.29 0.79 0.04
        0.53 0.66 0.36
        0.19 0.64 0.95
        0.07 0.58 0.06];
    
    fixedPoints = [2.60 4.13 2.53
        3.59 4.46 2.49
        4.40 4.33 2.97
        2.75 3.41 2.78];

    Fit the affine transformation that maps movingPoints to fixedPoints.

    tform = fitgeotform3d(movingPoints,fixedPoints,"affine")
    tform = 
      affinetform3d with properties:
    
        Dimensionality: 3
    
                     A: [ 0.8856   -1.4674    1.8335    3.4291
                          1.4875    1.9371    0.7025    2.1402
                         -0.7980   -0.3218    0.3428    3.0019
                               0         0         0    1.0000]
    
    

    Check the results by applying the transformation to the moving points in the forward direction. Display the fixed point coordinates for comparison. As expected, the transformed coordinates match the fixed points.

    transformedPoints = transformPointsForward(tform,movingPoints)
    transformedPoints = 4×3
    
        2.6000    4.1300    2.5300
        3.5900    4.4600    2.4900
        4.4000    4.3300    2.9700
        2.7500    3.4100    2.7800
    
    
    fixedPoints
    fixedPoints = 4×3
    
        2.6000    4.1300    2.5300
        3.5900    4.4600    2.4900
        4.4000    4.3300    2.9700
        2.7500    3.4100    2.7800
    
    

    Input Arguments

    collapse all

    Control point locations in the moving image, specified as an m-by-3 matrix. Each row specifies the xyz-coordinates of a control point.

    Example: movingPoints = [11 11 5; 41 71 50];

    Data Types: single | double

    Control point locations in the fixed image, specified as an m-by-3 matrix. Each row specifies the xyz-coordinates of a control point.

    Example: fixedPoints = [11 11 5; 41 71 50];

    Data Types: single | double

    Type of linear transformation, specified as one of the values in the table.

    ValueDescriptionMinimum Number of Control Point Pairs
    "translation"Output describes a translation transformation.1
    "rigid"Output describes a rigid transformation, which can include translation and rotation.3
    "affine"Output describes an affine transformation, which can include translation, rotation, anisotropic scaling, reflection, and shearing.4

    Output Arguments

    collapse all

    Geometric transformation, returned as a geometric transformation object as defined in the table.

    Transformation TypeGeometric Transformation Object
    "translation"transltform3d
    "rigid"rigidtform3d
    "affine"affinetform3d

    References

    [1] Eggert, D.W., A. Lorusso, and R.B. Fisher. “Estimating 3-D Rigid Body Transformations: A Comparison of Four Major Algorithms.” Machine Vision and Applications 9, no. 5–6 (March 1, 1997): 272–90. https://doi.org/10.1007/s001380050048.

    Version History

    Introduced in R2024a