Main Content

simtform2d

2-D similarity geometric transformation

Since R2022b

    Description

    A simtform2d object stores information about a 2-D similarity geometric transformation and enables forward and inverse transformations.

    Creation

    You can create a simtform2d object in these ways:

    • fitgeotform2d — Estimate a geometric transformation that maps pairs of control points between two images.

    • The simtform2d function described here.

    Description

    tform = simtform2d creates a simtform2d object that performs the identity transformation.

    tform = simtform2d(s,rotAngle,t) creates a simtform2d object that performs a similarity transformation based on the specified scale factor s, angle of rotation rotAngle, and amount of translation t.

    tform = simtform2d(s,rotMat,t) creates a simtform2d object that performs a similarity transformation based on the specified scale factor s, rotation matrix rotMat, and amount of translation t.

    example

    tform = simtform2d(simMat) creates a simtform2d object from the specified 2-D similarity transformation matrix, simMat.

    tform = simtform2d(tformIn) creates a simtform2d object from another geometric transformation object, tformIn, that represents a valid 2-D similarity geometric transformation.

    Input Arguments

    expand all

    Scale factor, specified as a positive number. The scale factor corresponds to the value s in the similarity transformation matrix defined by property A.

    This argument sets the Scale property.

    Data Types: double | single

    Rotation angle about the origin in degrees, specified as a numeric scalar in the range [-180, 180). If you specify a rotation angle outside of this range, then the simtform2d object automatically brings the value to the range [-180, 180) by adding positive or negative multiples of 360.

    The rotation angle corresponds to the value r in the transformation matrix defined by property A and in the rotation matrix defined by property R.

    This argument sets the RotationAngle property.

    Data Types: double | single

    Rotation matrix, specified as a 2-by-2 numeric matrix. The matrix must have the form

     R = [cosd(r) -sind(r); sind(r)  cosd(r)]
    where r is the value of the rotation angle about the origin.

    This argument sets the R property.

    Amount of translation, specified as a 2-element numeric vector of the form [tx ty]. These amounts of translation correspond to the values tx and ty in the similarity transformation matrix defined by A.

    This argument sets the Translation property.

    Data Types: double | single

    Forward 2-D similarity transformation, specified as a 3-by-3 numeric matrix. You can also specify simMat as a 2-by-3 numeric matrix. In this case, the object concatenates the row vector [0 0 1] to the end of the matrix, forming a 3-by-3 matrix.

    A valid 2-D similarity transformation A has the form:

    Α=[s×cosd(r)s×sind(r)txs×sind(r)s×cosd(r)ty001]

    s is the scale factor and sets the Scale property. r is the rotation angle and sets the RotationAngle property. tx and ty are the amount of translation in the x- and y-directions, respectively, and set the Translation property.

    This argument sets the A property.

    Data Types: double | single

    Similarity 2-D geometric transformation, specified as an affinetform2d object, rigidtform2d object, simtform2d object, transltform2d object, or projtform2d object.

    Output Arguments

    expand all

    Similarity 2-D geometric transformation, returned as a simtform2d object.

    Properties

    expand all

    Forward 2-D similarity transformation, specified as a 3-by-3 numeric matrix. The default of A is the identity matrix.

    The matrix A transforms the point (u, v) in the input coordinate space to the point (x, y) in the output coordinate space using the convention:

    [xy1]=Α×[uv1]

    For a similarity transformation, A has the form:

    Α=[s×cosd(r)s×sind(r)txs×sind(r)s×cosd(r)ty001]

    where s is the scale factor and corresponds to the Scale property. r is the rotation angle and corresponds to the RotationAngle property. tx and ty are the amount of translation in the x- and y-directions, respectively, and correspond to the Translation property.

    Data Types: double | single

    Scale factor, specified as a positive number. The scale factor corresponds to the value s in the similarity transformation matrix defined by property A.

    Data Types: double | single

    Rotation matrix, specified as a 2-by-2 numeric matrix. The matrix must have the form

     R = [cosd(r) -sind(r); sind(r)  cosd(r)]
    where r is the value of the RotationAngle property.

    Rotation angle about the origin in degrees, specified as a numeric scalar in the range [-180, 180). If you specify a rotation angle outside of this range, then the simtform2d object automatically brings the value to the range [-180, 180) by adding positive or negative multiples of 360.

    The rotation angle corresponds to the value r in the transformation matrix defined by A and in the rotation matrix defined by R.

    Data Types: double | single

    Amount of translation, specified as a 2-element numeric vector of the form [tx ty]. These amounts of translation correspond to the values tx and ty in the similarity transformation matrix defined by A.

    Data Types: double | single

    This property is read-only.

    Dimensionality of the geometric transformation for both input and output points, returned as the value 2.

    Data Types: double

    Object Functions

    invertInvert geometric transformation
    outputLimitsFind output spatial limits given input spatial limits
    transformPointsForwardApply forward geometric transformation
    transformPointsInverseApply inverse geometric transformation

    Examples

    collapse all

    Specify the scale factor, rotation angle, and the amount of translation.

    scaleFactor = 3;
    theta = 30;
    translation = [10 20.5];

    Create a simtform2d object that performs the specified scaling, rotation, and translation.

    tform = simtform2d(scaleFactor,theta,translation)
    tform = 
      simtform2d with properties:
    
        Dimensionality: 2
                 Scale: 3
         RotationAngle: 30
           Translation: [10 20.5000]
                     R: [2×2 double]
    
                     A: [2.5981   -1.5000   10.0000
                         1.5000    2.5981   20.5000
                              0         0    1.0000]
    
    

    Examine the value of the A property.

    tform.A
    ans = 3×3
    
        2.5981   -1.5000   10.0000
        1.5000    2.5981   20.5000
             0         0    1.0000
    
    

    Extended Capabilities

    expand all

    Version History

    Introduced in R2022b

    expand all