Skip to content

affine_trans_pixelAffineTransPixelAffineTransPixelaffine_trans_pixelT_affine_trans_pixelπŸ”—

Short descriptionπŸ”—

affine_trans_pixelAffineTransPixelAffineTransPixelaffine_trans_pixelT_affine_trans_pixel β€” Apply an arbitrary affine 2D transformation to pixel coordinates.

SignatureπŸ”—

affine_trans_pixel( hom_mat2d HomMat2D, point.x Row, point.y Col, out point.x RowTrans, out point.y ColTrans )void AffineTransPixel( const HTuple& HomMat2D, const HTuple& Row, const HTuple& Col, HTuple* RowTrans, HTuple* ColTrans )static void HOperatorSet.AffineTransPixel( HTuple homMat2D, HTuple row, HTuple col, out HTuple rowTrans, out HTuple colTrans )def affine_trans_pixel( hom_mat_2d: Sequence[float], row: MaybeSequence[Union[float, int]], col: MaybeSequence[Union[float, int]] ) -> Tuple[Sequence[float], Sequence[float]]

def affine_trans_pixel_s( hom_mat_2d: Sequence[float], row: MaybeSequence[Union[float, int]], col: MaybeSequence[Union[float, int]] ) -> Tuple[float, float]Herror T_affine_trans_pixel( const Htuple HomMat2D, const Htuple Row, const Htuple Col, Htuple* RowTrans, Htuple* ColTrans )

void HHomMat2D::AffineTransPixel( const HTuple& Row, const HTuple& Col, HTuple* RowTrans, HTuple* ColTrans ) const

void HHomMat2D::AffineTransPixel( double Row, double Col, double* RowTrans, double* ColTrans ) const

void HHomMat2D.AffineTransPixel( HTuple row, HTuple col, out HTuple rowTrans, out HTuple colTrans )

void HHomMat2D.AffineTransPixel( double row, double col, out double rowTrans, out double colTrans )

DescriptionπŸ”—

affine_trans_pixelAffineTransPixel applies an arbitrary affine 2D transformation, i.e., scaling, rotation, translation, and slant (skewing), to the input pixels (Rowrowrow,Colcolcol) and returns the resulting pixels in (RowTransrowTransrow_trans,ColTranscolTranscol_trans); the input and output pixels are subpixel precise coordinates. The affine transformation is described by the homogeneous transformation matrix given in HomMat2DhomMat2Dhom_mat_2d.

In contrast to affine_trans_point_2dAffineTransPoint2d, affine_trans_pixelAffineTransPixel first converts the input coordinates from HALCON’s standard coordinate system (with the origin in the center of the upper left pixel) to a coordinate system with the origin in the upper left corner of the upper left pixel. After the transformation with HomMat2DhomMat2Dhom_mat_2d the result is converted back to the standard coordinate system. This way, affine_trans_pixelAffineTransPixel is compatible with affine_trans_imageAffineTransImage, affine_trans_image_sizeAffineTransImageSize, affine_trans_regionAffineTransRegion, affine_trans_contour_xldAffineTransContourXld, and affine_trans_polygon_xldAffineTransPolygonXld.

Applying affine_trans_pixelAffineTransPixel corresponds to the following chain of transformations (input and output pixels as homogeneous vectors):

\[\begin{eqnarray*} \mvHomVectorTwoD{\textrm{RowTrans}}{\textrm{ColTrans}} = \mvHomMatrixTwoDElements{1 & 0 & - 0.5 \\ 0 & 1 & - 0.5} \cdot \textrm{HomMat2D} \cdot \mvHomMatrixTwoDElements{1 & 0 & + 0.5 \\ 0 & 1 & + 0.5} \cdot \mvHomVectorTwoD{\textrm{Row}}{\textrm{Col}} \end{eqnarray*}\]

Hence, affine_trans_pixel(HomMat2D, Row, Col, RowTrans, ColTrans)AffineTransPixel(HomMat2D, Row, Col, RowTrans, ColTrans)AffineTransPixel(HomMat2D, Row, Col, RowTrans, ColTrans)affine_trans_pixel(HomMat2D, Row, Col, RowTrans, ColTrans)affine_trans_pixel(HomMat2D, Row, Col, RowTrans, ColTrans) corresponds to the following operator sequence:

Β 
affine_trans_point_2d(HomMat2D, Row+0.5, Col+0.5, RowTmp, ColTmp)AffineTransPoint2d(HomMat2D, Row+0.5, Col+0.5, RowTmp, ColTmp)AffineTransPoint2d(HomMat2D, Row+0.5, Col+0.5, RowTmp, ColTmp)affine_trans_point_2d(HomMat2D, Row+0.5, Col+0.5, RowTmp, ColTmp)affine_trans_point_2d(HomMat2D, Row+0.5, Col+0.5, RowTmp, ColTmp)
RowTrans := RowTmp-0.5
ColTrans := ColTmp-0.5

Further InformationπŸ”—

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 internal data level.

ParametersπŸ”—

HomMat2DhomMat2Dhom_mat_2d (input_control) hom_mat2d β†’ (real)HTuple (double)HHomMat2D, HTuple (double)Sequence[float]Htuple (double)

Input transformation matrix.

Rowrowrow (input_control) point.x(-array) β†’ (real / integer)HTuple (double / Hlong)HTuple (double / int / long)MaybeSequence[Union[float, int]]Htuple (double / Hlong)

Input pixel(s) (row coordinate).

Default: 6464
Suggested values: 0, 16, 32, 64, 128, 256, 512, 10240, 16, 32, 64, 128, 256, 512, 1024

Colcolcol (input_control) point.y(-array) β†’ (real / integer)HTuple (double / Hlong)HTuple (double / int / long)MaybeSequence[Union[float, int]]Htuple (double / Hlong)

Input pixel(s) (column coordinate).

Default: 6464
Suggested values: 0, 16, 32, 64, 128, 256, 512, 10240, 16, 32, 64, 128, 256, 512, 1024

RowTransrowTransrow_trans (output_control) point.x(-array) β†’ (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Output pixel(s) (row coordinate).

ColTranscolTranscol_trans (output_control) point.y(-array) β†’ (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Output pixel(s) (column coordinate).

ResultπŸ”—

If the matrix HomMat2DhomMat2Dhom_mat_2d represents an affine transformation (i.e., not a projective transformation), affine_trans_pixelAffineTransPixel returns 2 (H_MSG_TRUE). Otherwise, an exception is raised.

Combinations with other operatorsπŸ”—

Combinations

Possible predecessors

hom_mat2d_translateHomMat2dTranslate, hom_mat2d_translate_localHomMat2dTranslateLocal, hom_mat2d_scaleHomMat2dScale, hom_mat2d_scale_localHomMat2dScaleLocal, hom_mat2d_rotateHomMat2dRotate, hom_mat2d_rotate_localHomMat2dRotateLocal, hom_mat2d_slantHomMat2dSlant, hom_mat2d_slant_localHomMat2dSlantLocal, hom_mat2d_reflectHomMat2dReflect, hom_mat2d_reflect_localHomMat2dReflectLocal

Alternatives

affine_trans_point_2dAffineTransPoint2d

ModuleπŸ”—

Foundation