affine_trans_regionT_affine_trans_regionAffineTransRegionAffineTransRegionaffine_trans_region (Operator)
Name
affine_trans_regionT_affine_trans_regionAffineTransRegionAffineTransRegionaffine_trans_region
— Apply an arbitrary affine 2D transformation to regions.
Signature
Description
affine_trans_regionaffine_trans_regionAffineTransRegionAffineTransRegionAffineTransRegionaffine_trans_region
applies an arbitrary affine 2D
transformation, i.e., scaling, rotation, translation, and slant (skewing), to
the regions given in RegionRegionRegionRegionregionregion
and returns the transformed
regions in RegionAffineTransRegionAffineTransRegionAffineTransRegionAffineTransregionAffineTransregion_affine_trans
. The affine transformation is
described by the homogeneous transformation matrix given in
HomMat2DHomMat2DHomMat2DHomMat2DhomMat2Dhom_mat_2d
, which can be created using the operators
hom_mat2d_identityhom_mat2d_identityHomMat2dIdentityHomMat2dIdentityHomMat2dIdentityhom_mat2d_identity
, hom_mat2d_scalehom_mat2d_scaleHomMat2dScaleHomMat2dScaleHomMat2dScalehom_mat2d_scale
,
hom_mat2d_rotatehom_mat2d_rotateHomMat2dRotateHomMat2dRotateHomMat2dRotatehom_mat2d_rotate
, hom_mat2d_translatehom_mat2d_translateHomMat2dTranslateHomMat2dTranslateHomMat2dTranslatehom_mat2d_translate
, etc., or be the result
of operators like vector_angle_to_rigidvector_angle_to_rigidVectorAngleToRigidVectorAngleToRigidVectorAngleToRigidvector_angle_to_rigid
.
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.
The parameter InterpolateInterpolateInterpolateInterpolateinterpolateinterpolate
determines whether the transformation is
to be done by using interpolation internally. The interpolation modes
'nearest_neighbor'"nearest_neighbor""nearest_neighbor""nearest_neighbor""nearest_neighbor""nearest_neighbor" and 'constant'"constant""constant""constant""constant""constant", which are
described in detail for affine_trans_imageaffine_trans_imageAffineTransImageAffineTransImageAffineTransImageaffine_trans_image
, can be used. An
interpolation can lead to smoother region boundaries, especially if regions
are enlarged. However, the runtime increases drastically.
Attention
affine_trans_regionaffine_trans_regionAffineTransRegionAffineTransRegionAffineTransRegionaffine_trans_region
in general is not reversible
(clipping and discretization during rotation and scaling).
affine_trans_regionaffine_trans_regionAffineTransRegionAffineTransRegionAffineTransRegionaffine_trans_region
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_pixelaffine_trans_pixelAffineTransPixelAffineTransPixelAffineTransPixelaffine_trans_pixel
, i.e., the origin lies in the upper
left corner of the upper left pixel. Therefore,
applying affine_trans_regionaffine_trans_regionAffineTransRegionAffineTransRegionAffineTransRegionaffine_trans_region
corresponds to
a chain of transformations (see affine_trans_pixelaffine_trans_pixelAffineTransPixelAffineTransPixelAffineTransPixelaffine_trans_pixel
), which is
applied to each point of the region (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
region, e.g., by operators like
area_centerarea_centerAreaCenterAreaCenterAreaCenterarea_center
. For example, if you use this operator to calculate
the center of gravity of a rotationally symmetric region and then rotate
the region around this point using hom_mat2d_rotatehom_mat2d_rotateHomMat2dRotateHomMat2dRotateHomMat2dRotatehom_mat2d_rotate
, the resulting
region will not lie on the original one. In such a case, you can compensate
this effect by applying the following translations to HomMat2DHomMat2DHomMat2DHomMat2DhomMat2Dhom_mat_2d
before using it in affine_trans_regionaffine_trans_regionAffineTransRegionAffineTransRegionAffineTransRegionaffine_trans_region
:
hom_mat2d_translate(HomMat2D, 0.5, 0.5, HomMat2DTmp)hom_mat2d_translate(HomMat2D, 0.5, 0.5, HomMat2DTmp)HomMat2dTranslate(HomMat2D, 0.5, 0.5, HomMat2DTmp)HomMat2dTranslate(HomMat2D, 0.5, 0.5, HomMat2DTmp)HomMat2dTranslate(HomMat2D, 0.5, 0.5, HomMat2DTmp)hom_mat2d_translate(HomMat2D, 0.5, 0.5, HomMat2DTmp)
|
hom_mat2d_translate_local(HomMat2DTmp, -0.5, -0.5, HomMat2DAdapted)hom_mat2d_translate_local(HomMat2DTmp, -0.5, -0.5, HomMat2DAdapted)HomMat2dTranslateLocal(HomMat2DTmp, -0.5, -0.5, HomMat2DAdapted)HomMat2dTranslateLocal(HomMat2DTmp, -0.5, -0.5, HomMat2DAdapted)HomMat2dTranslateLocal(HomMat2DTmp, -0.5, -0.5, HomMat2DAdapted)hom_mat2d_translate_local(HomMat2DTmp, -0.5, -0.5, HomMat2DAdapted)
|
affine_trans_region(Region, RegionAffineTrans, HomMat2DAdapted, 'nearest_neighbor')affine_trans_region(Region, RegionAffineTrans, HomMat2DAdapted, "nearest_neighbor")AffineTransRegion(Region, RegionAffineTrans, HomMat2DAdapted, "nearest_neighbor")AffineTransRegion(Region, RegionAffineTrans, HomMat2DAdapted, "nearest_neighbor")AffineTransRegion(Region, RegionAffineTrans, HomMat2DAdapted, "nearest_neighbor")affine_trans_region(Region, RegionAffineTrans, HomMat2DAdapted, "nearest_neighbor")
|
For an explanation of the different 2D coordinate systems
used in HALCON, see the introduction of chapter
Transformations / 2D Transformations.
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
RegionRegionRegionRegionregionregion
(input_object) region(-array) →
objectHRegionHObjectHRegionHobject
Region(s) to be rotated and scaled.
RegionAffineTransRegionAffineTransRegionAffineTransRegionAffineTransregionAffineTransregion_affine_trans
(output_object) region(-array) →
objectHRegionHObjectHRegionHobject *
Transformed output region(s).
Number of elements: RegionAffineTrans == Region
HomMat2DHomMat2DHomMat2DHomMat2DhomMat2Dhom_mat_2d
(input_control) hom_mat2d →
HHomMat2D, HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)
Input transformation matrix.
InterpolateInterpolateInterpolateInterpolateinterpolateinterpolate
(input_control) string →
HTuplestrHTupleHtuple (string) (string) (HString) (char*)
Should the transformation be done using interpolation?
Default value:
'nearest_neighbor'
"nearest_neighbor"
"nearest_neighbor"
"nearest_neighbor"
"nearest_neighbor"
"nearest_neighbor"
List of values: 'constant'"constant""constant""constant""constant""constant", 'nearest_neighbor'"nearest_neighbor""nearest_neighbor""nearest_neighbor""nearest_neighbor""nearest_neighbor"
Result
If the matrix HomMat2DHomMat2DHomMat2DHomMat2DhomMat2Dhom_mat_2d
represents an affine transformation
(i.e., not a projective transformation), affine_trans_regionaffine_trans_regionAffineTransRegionAffineTransRegionAffineTransRegionaffine_trans_region
returns TRUE. The behavior in case of empty input (no regions
given) can be set via
set_system('no_object_result',<Result>)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)set_system("no_object_result",<Result>)
, the behavior in
case of an empty input region via
set_system('empty_region_result',<Result>)set_system("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)SetSystem("empty_region_result",<Result>)set_system("empty_region_result",<Result>)
, and the behavior
in case of an empty result region via
set_system('store_empty_region',<'2 (H_MSG_TRUE)'/'3 (H_MSG_FALSE)'>)set_system("store_empty_region",<"2 (H_MSG_TRUE)"/"3 (H_MSG_FALSE)">)SetSystem("store_empty_region",<"2 (H_MSG_TRUE)"/"3 (H_MSG_FALSE)">)SetSystem("store_empty_region",<"2 (H_MSG_TRUE)"/"3 (H_MSG_FALSE)">)SetSystem("store_empty_region",<"2 (H_MSG_TRUE)"/"3 (H_MSG_FALSE)">)set_system("store_empty_region",<"2 (H_MSG_TRUE)"/"3 (H_MSG_FALSE)">)
. If
necessary, an exception is raised.
Possible Predecessors
hom_mat2d_identityhom_mat2d_identityHomMat2dIdentityHomMat2dIdentityHomMat2dIdentityhom_mat2d_identity
,
hom_mat2d_scalehom_mat2d_scaleHomMat2dScaleHomMat2dScaleHomMat2dScalehom_mat2d_scale
,
hom_mat2d_translatehom_mat2d_translateHomMat2dTranslateHomMat2dTranslateHomMat2dTranslatehom_mat2d_translate
,
hom_mat2d_inverthom_mat2d_invertHomMat2dInvertHomMat2dInvertHomMat2dInverthom_mat2d_invert
,
hom_mat2d_rotatehom_mat2d_rotateHomMat2dRotateHomMat2dRotateHomMat2dRotatehom_mat2d_rotate
,
hom_mat2d_reflecthom_mat2d_reflectHomMat2dReflectHomMat2dReflectHomMat2dReflecthom_mat2d_reflect
Possible Successors
select_shapeselect_shapeSelectShapeSelectShapeSelectShapeselect_shape
Alternatives
move_regionmove_regionMoveRegionMoveRegionMoveRegionmove_region
,
mirror_regionmirror_regionMirrorRegionMirrorRegionMirrorRegionmirror_region
,
zoom_regionzoom_regionZoomRegionZoomRegionZoomRegionzoom_region
See also
affine_trans_imageaffine_trans_imageAffineTransImageAffineTransImageAffineTransImageaffine_trans_image
Module
Foundation