Main Content

Estimate Geometric Transformation

Estimate geometric transformation from matching point pairs

  • Estimate Geometric Transformation block

Libraries:
Computer Vision Toolbox / Geometric Transformations

Description

Use the Estimate Geometric Transformation block to find the transformation matrix which maps the greatest number of point pairs between two images. A point pair refers to a point in the input image and its related point on the image created using the transformation matrix. You can select to use the RANdom SAmple Consensus (RANSAC) or the Least Median Squares algorithm to exclude outliers and to calculate the transformation matrix. You can also use all input points to calculate the transformation matrix.

Examples

expand all

  1. Examples of input data and application of the Estimate Geometric Transformation block appear in the following figures. Figures (a) and (b) show the point pairs. The points are denoted by stars or circles, and the numbers following them show how they are paired. Some point pairs can be mapped by the same transformation matrix. Other point pairs require a different transformation matrix. One matrix exists that maps the largest number of point pairs, the block calculates and returns this matrix. The block finds the point pairs in the largest group and uses them to calculate the transformation matrix. The point pairs connected by the magenta lines are the largest group.

  2. The transformation matrix can then be used to stitch the images as shown in Figure (e).

Ports

Input

expand all

Point coordinates, specified as an M-by-2 matrix of one-based [x y] point coordinates, where M represents the number of points.

The block outputs the same data type for the transformation matrix as the Pts1 and Pts2 image points.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

Point coordinates, specified as an M-by-2 matrix of one-based [x y] point coordinates, where M represents the number of points.

The block outputs the same data type for the transformation matrix as the Pts1 and Pts2 image points.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

Number of valid points to find in Pts1 and Pts2, specified as a scalar. This port appears when you enable the Allow variable-size signal input parameter.

Data Types: int8 | int16 | int32 | uint8 | uint16 | uint32

Output

expand all

Transformation, returned as either a 3-by-2 or a 3-by-3 matrix. The block outputs the same data type for the transformation matrix as the Pts1 and Pts2 image points.

Dependencies

  • When Pts1 and Pts2 are single or double, the output transformation matrix will also have single or double data type.

  • When Pts1 and Pts2 images are built-in integers, the option is available to set the transformation matrix data type to either Single or Double.

Data Types: single | double

Points used to calculate TForm, returned as an M-by-1 vector.

Dependencies

  • The Inlier port appears when you enable the Output Boolean signal indicating which point pairs are inliers parameter.

Data Types: Boolean

Parameters

expand all

Specify the transformation type as either Nonreflective similarity, Affine, or Projective. See Transformations for a more detailed discussion.

Dependencies

You can set additional parameters depending on the transformation type:

  • For Projective transformation, you can specify a scalar algebraic distance threshold for determining inliers.

  • For Affine or Nonreflective similarity transformation, you can specify the distance threshold for determining inliers in pixels.

Enable to find and exclude outliers from the input points and use only the inlier points to calculate the transformation matrix. When you turn this parameter off, all input points are used to calculate the transformation matrix.

Select the method to find outliers as either RANdom SAmple Consensus (RANSAC) or Least Median of Squares See RANSAC and Least Median Squares Algorithms for a more detailed discussion.

Dependencies

This parameter appears when you enable the Find and exclude outliers check box.

Specify a scalar threshold value for determining inliers. The threshold controls the upper limit used to find the algebraic distance in the RANSAC algorithm.

Dependencies

This parameter appears when you set the Method parameter to Random Sample Consensus (RANSAC) and the Transformation type parameter to Projective.

Specify the upper limit distance a point can differ from the projection location of its corresponding point.

Dependencies

This parameter appears when you set the Method parameter to Random Sample Consensus (RANSAC) and you set the value of the Transformation type parameter to Nonreflective similarity or Affine.

Select Specified value to enter a positive integer value for the number of random samplings. Select Desired confidence to set the number of random samplings as a percentage and a maximum number.

Dependencies

This parameter appears when you select the Find and exclude outliers check box, and you set the value of the Method parameter to Random Sample Consensus (RANSAC).

Specify the number of random samplings for the algorithm to perform.

Dependencies

This parameter appears when you set the value of the Determine number of random samplings using parameter to Specified value.

Specify a percent desired confidence by entering a number between 0 and 100. The value represents the probability of the algorithm to find the largest group of points that can be mapped by a transformation matrix.

Dependencies

This parameter appears when you set the Determine number of random samplings using parameter to Desired confidence.

Specify an integer number for the maximum number of random samplings.

Dependencies

This parameter appears when you set the Method parameter to Random Sample Consensus (RANSAC) and you set the value of the Determine number of random samplings using parameter to Desired confidence.

Enable this parameter to stop random sampling when a percentage of input points have been found as inliers.

Dependencies

This parameter appears when you set the Method parameter to Random Sample Consensus (RANSAC).

Specify whether to perform refinement on the transformation matrix.

Dependencies

This parameter appears when you select Find and exclude outliers check box.

Enable this parameter to output the inlier point pairs that were used to calculate the transformation matrix.

Dependencies

  • This parameter appears when you select the Find and exclude outliers check box.

  • The block will not use this parameter with signed or double, data type points.

Specify transformation matrix data type as Single or Double when the input points are built-in integers.

Dependencies

The block will not use this parameter with signed or double, data type points.

Enable this parameter to allow variable-sized signal input.

Dependencies

Block Characteristics

Data Types

double | integera | single

Multidimensional Signals

no

Variable-Size Signals

yes

a Generated code will be restricted to MATLAB host computers when you set the FFT implementation parameter to FFTW, or when the transform length is not a power of two.

Tips

The success of estimating the correct geometric transformation depends heavily on the quality of the input point pairs. If you chose the RANSAC or LMS algorithm, the block will randomly select point pairs to compute the transformation matrix and will use the transformation that best fits the input points. There is a chance that all of the randomly selected point pairs may contain outliers despite repeated samplings. In this case, the output transformation matrix, TForm, is invalid, indicated by a matrix of zeros.

To improve your results, try the following:

Increase the percentage of inliers in the input points.
Increase the number for random samplings.
For the RANSAC method, increase the desired confidence.
For the LMS method, make sure the input points have 50% or more inliers.
Use features appropriate for the image contents
Be aware that repeated patterns, for example, windows in office building, will cause false matches when you match the features. This increases the number of outliers.
Do not use this function if the images have significant parallax. You can use the estimateFundamentalMatrix function instead.
Choose the minimum transformation for your problem.
If a projective transformation produces the error message, “A portion of the input image was transformed to the location at infinity. Only transformation matrices that do not transform any part of the image to infinity are supported.”, it is usually caused by a transformation matrix and an image that would result in an output distortion that does not fit physical reality. If the matrix was an output of the Estimate Geometric Transformation block, then most likely it could not find enough inliers.

Algorithms

expand all

References

[1] R. Hartley and A. Ziserman, “Multiple View Geometry in Computer Vision,” Second edition, Cambridge University Press, 2003

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Fixed-Point Conversion
Design and simulate fixed-point systems using Fixed-Point Designer™.

Version History

Introduced in R2008a