Skip to content

vector_to_rigidVectorToRigidVectorToRigidvector_to_rigidT_vector_to_rigid🔗

Short description🔗

vector_to_rigidVectorToRigidVectorToRigidvector_to_rigidT_vector_to_rigid — Approximate a rigid affine transformation from point correspondences.

Signature🔗

vector_to_rigid( point.x Px, point.y Py, point.x Qx, point.y Qy, out hom_mat2d HomMat2D )void VectorToRigid( const HTuple& Px, const HTuple& Py, const HTuple& Qx, const HTuple& Qy, HTuple* HomMat2D )static void HOperatorSet.VectorToRigid( HTuple px, HTuple py, HTuple qx, HTuple qy, out HTuple homMat2D )def vector_to_rigid( px: Sequence[float], py: Sequence[float], qx: Sequence[float], qy: Sequence[float] ) -> Sequence[float]

Herror T_vector_to_rigid( const Htuple Px, const Htuple Py, const Htuple Qx, const Htuple Qy, Htuple* HomMat2D )

void HHomMat2D::VectorToRigid( const HTuple& Px, const HTuple& Py, const HTuple& Qx, const HTuple& Qy )

void HHomMat2D.VectorToRigid( HTuple px, HTuple py, HTuple qx, HTuple qy )

Description🔗

vector_to_rigidVectorToRigid approximates a rigid affine transformation, i.e., a transformation consisting of a rotation and a translation, from at least two point correspondences and returns it as the homogeneous transformation matrix HomMat2DhomMat2Dhom_mat_2d. The matrix consists of 2 components: a rotation matrix R and a translation vector t (also see hom_mat2d_rotateHomMat2dRotate and hom_mat2d_translateHomMat2dTranslate):

\[\begin{eqnarray*} \textrm{HomMat2D} = \mvHomMatrixTwoDRotTrans{\mvRotationMatrixVar{}{}} {\mvTranslationVectorVar{}{}} = \mvHomMatrixTwoDRotTrans{\mvMatrixPlain{1 & 0 \\ 0 & 1}} {\mvTranslationVectorVar{}{}} \cdot \mvHomMatrixTwoDRotTrans{\mvRotationMatrixVar{}{}} {\mvVectorTwoDPlain{0}{0}} = \mvHomTranslationMatrixVar{}{} \cdot \mvHomRotationMatrixVar{}{} \end{eqnarray*}\]

The point correspondences are passed in the tuples (Pxpxpx, Pypypy) and (Qxqxqx,Qyqyqy), where corresponding points must be at the same index positions in the tuples. The transformation is always overdetermined. Therefore, the returned transformation is the transformation that minimizes the distances between the original points (Pxpxpx,Pypypy) and the transformed points (Qxqxqx,Qyqyqy), as described in the following equation (points as homogeneous vectors):

\[\begin{eqnarray*} \sum_{i} \: \left\| \mvHomVectorTwoD{\textrm{Qx}[i]}{\textrm{Qy}[i]} - \textrm{HomMat2D} \cdot \mvHomVectorTwoD{\textrm{Px}[i]}{\textrm{Py}[i]} \right\|^{\mbox{2}} = \mbox{minimum} \end{eqnarray*}\]

HomMat2DhomMat2Dhom_mat_2d can be used directly with operators that transform data using affine transformations, e.g., affine_trans_imageAffineTransImage.

Attention🔗

It should be noted that homogeneous transformation matrices refer to a general right-handed mathematical coordinate system. If a homogeneous transformation matrix is used to transform images, regions, XLD contours, or any other data that has been extracted from images, the row coordinates of the transformation must be passed in the x coordinates, while the column coordinates must be passed in the y coordinates. Consequently, the order of passing row and column coordinates follows the usual order (Rowrowrow,Columncolumncolumn). This convention is essential to obtain a right-handed coordinate system for the transformation of iconic data, and consequently to ensure in particular that rotations are performed in the correct mathematical direction.

Furthermore, it should be noted that if a homogeneous transformation matrix is used to transform images, regions, XLD contours, or any other data that has been extracted from images, it is assumed that the origin of the coordinate system of the homogeneous transformation matrix lies in the upper left corner of a pixel. The image processing operators that return point coordinates, however, assume a coordinate system in which the origin lies in the center of a pixel. Therefore, to obtain a consistent homogeneous transformation matrix, 0.5 must be added to the point coordinates before computing the transformation.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

Parameters🔗

Pxpxpx (input_control) point.x-array → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

X coordinates of the original points.

Pypypy (input_control) point.y-array → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Y coordinates of the original points.

Qxqxqx (input_control) point.x-array → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

X coordinates of the transformed points.

Qyqyqy (input_control) point.y-array → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Y coordinates of the transformed points.

HomMat2DhomMat2Dhom_mat_2d (output_control) hom_mat2d → (real)HTuple (double)HHomMat2D, HTuple (double)Sequence[float]Htuple (double)

Output transformation matrix.

Combinations with other operators🔗

Combinations

Possible successors

affine_trans_imageAffineTransImage, affine_trans_image_sizeAffineTransImageSize, affine_trans_regionAffineTransRegion, affine_trans_contour_xldAffineTransContourXld, affine_trans_polygon_xldAffineTransPolygonXld, affine_trans_point_2dAffineTransPoint2d

Alternatives

vector_to_hom_mat2dVectorToHomMat2d, vector_to_anisoVectorToAniso, vector_to_similarityVectorToSimilarity

See also

vector_field_to_hom_mat2dVectorFieldToHomMat2d, point_line_to_hom_mat2dPointLineToHomMat2d

Module🔗

Foundation