Skip to content

affine_trans_contour_xldaffine_trans_contour_xldAffineTransContourXldAffineTransContourXldaffine_trans_contour_xldT_affine_trans_contour_xld🔗

Short description🔗

affine_trans_contour_xldaffine_trans_contour_xldAffineTransContourXldAffineTransContourXldaffine_trans_contour_xldT_affine_trans_contour_xld — Apply an arbitrary affine 2D transformation to XLD contours.

Signature🔗

affine_trans_contour_xld( xld_cont Contours, out xld_cont ContoursAffineTrans, hom_mat2d HomMat2D )affine_trans_contour_xld( Contours : ContoursAffineTrans : HomMat2D : )void AffineTransContourXld( const HObject& Contours, HObject* ContoursAffineTrans, const HTuple& HomMat2D )static void HOperatorSet.AffineTransContourXld( HObject contours, out HObject contoursAffineTrans, HTuple homMat2D )def affine_trans_contour_xld( contours: HObject, hom_mat_2d: Sequence[float] ) -> HObject

Herror T_affine_trans_contour_xld( const Hobject Contours, Hobject* ContoursAffineTrans, const Htuple HomMat2D )

HXLDCont HXLDCont::AffineTransContourXld( const HHomMat2D& HomMat2D ) const

HXLDCont HHomMat2D::AffineTransContourXld( const HXLDCont& Contours ) const

HXLDCont HXLDCont.AffineTransContourXld( HHomMat2D homMat2D )

HXLDCont HHomMat2D.AffineTransContourXld( HXLDCont contours )

Description🔗

affine_trans_contour_xldAffineTransContourXld applies an arbitrary affine 2D transformation, i.e., scaling, rotation, translation, and slant (skewing), to the XLD contours given in Contourscontourscontours and returns the transformed contours in ContoursAffineTranscontoursAffineTranscontours_affine_trans. The affine transformation is described by the homogeneous transformation matrix given in HomMat2DhomMat2Dhom_mat_2d, which can be created using the operators hom_mat2d_identityHomMat2dIdentity, hom_mat2d_scaleHomMat2dScale, hom_mat2d_rotateHomMat2dRotate, hom_mat2d_translateHomMat2dTranslate, etc., or be the result of operators like vector_angle_to_rigidVectorAngleToRigid.

The components of the homogeneous transformation matrix are interpreted as follows: The row coordinate of the image corresponds to \(x\) and the column coordinate corresponds to \(y\) of the coordinate system in which the transformation matrix was defined. This is necessary to obtain a right-handed coordinate system for the image. In particular, this assures that rotations are performed in the correct direction. Note that the (\(x\),\(y\)) order of the matrices quite naturally corresponds to the usual (row,column) order for coordinates in the image.

Attention🔗

affine_trans_contour_xldAffineTransContourXld does not use the HALCON standard coordinate system (with the origin in the center of the upper left pixel), but instead uses the same coordinate system as in affine_trans_pixelAffineTransPixel, i.e., the origin lies in the upper left corner of the upper left pixel. Therefore, applying affine_trans_contour_xldAffineTransContourXld corresponds to a chain of transformations (see affine_trans_pixelAffineTransPixel), which is applied to each point of the contour (input and output pixels as homogeneous vectors). As an effect, you might get unexpected results when creating affine transformations based on coordinates that are derived from the contour, e.g., by operators like area_center_xldAreaCenterXld. For example, if you use this operator to calculate the center of gravity of a rotationally symmetric XLD contour and then rotate the contour around this point using hom_mat2d_rotateHomMat2dRotate, the resulting contour will not lie on the original one. In such a case, you can compensate this effect by applying the following translations to HomMat2DhomMat2Dhom_mat_2d before using it in affine_trans_contour_xldAffineTransContourXld:

 
hom_mat2d_translate(HomMat2D, 0.5, 0.5, HomMat2DTmp)
hom_mat2d_translate_local(HomMat2DTmp, -0.5, -0.5, HomMat2DAdapted)
affine_trans_contour_xld(Contours, ContoursAffineTrans, HomMat2DAdapted)

For an explanation of the different 2D coordinate systems used in HALCON, see the introduction of chapter Transformations / 2D Transformations.

Execution information🔗

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

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

  • Automatically parallelized on tuple level.

Parameters🔗

Contourscontourscontours (input_object) xld_cont(-array) → objectobjectHObjectHXLDContHObjectHobject

Input XLD contours.

ContoursAffineTranscontoursAffineTranscontours_affine_trans (output_object) xld_cont(-array) → objectobjectHObjectHXLDContHObjectHobject *

Transformed XLD contours.

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

Input transformation matrix.

Result🔗

If the matrix HomMat2DhomMat2Dhom_mat_2d represents an affine transformation (i.e., not a projective transformation), affine_trans_contour_xldAffineTransContourXld returns 2 (H_MSG_TRUE). If the input is empty the behavior can be set via set_system(::'no_object_result',<Result>:). If necessary, an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

hom_mat2d_identityHomMat2dIdentity, hom_mat2d_translateHomMat2dTranslate, hom_mat2d_rotateHomMat2dRotate, hom_mat2d_scaleHomMat2dScale, hom_mat2d_reflectHomMat2dReflect

See also

affine_trans_imageAffineTransImage, affine_trans_regionAffineTransRegion

Module🔗

Foundation