Skip to content

orientation_xldOrientationXldOrientationXldorientation_xldorientation_xld🔗

Short description🔗

orientation_xldOrientationXldOrientationXldorientation_xldorientation_xld — Calculate the orientation of contours or polygons.

Signature🔗

orientation_xld( xld XLD, out angle.rad Phi )void OrientationXld( const HObject& XLD, HTuple* Phi )static void HOperatorSet.OrientationXld( HObject XLD, out HTuple phi )def orientation_xld( xld: HObject ) -> Sequence[float]

def orientation_xld_s( xld: HObject ) -> floatHerror orientation_xld( const Hobject XLD, double* Phi )

Herror T_orientation_xld( const Hobject XLD, Htuple* Phi )

HTuple HXLD::OrientationXld( ) const

HTuple HXLD.OrientationXld( )

Description🔗

The operator orientation_xldOrientationXld calculates the orientation (Phiphiphi) of each input contour or polygon (XLDXLDxld). The operator is based on elliptic_axis_xldEllipticAxisXld. In addition, the contour respectively polygon point with maximum distance to the center of gravity is calculated. If the column coordinate of this point is less than the column coordinate of the center of gravity the value of \(\pi\) is added to the angle. It is assumed that the contours or polygons are closed. If this is not the case orientation_xldOrientationXld will artificially close the contours or polygons.

It should be noted that orientation_xldOrientationXld only returns useful results if the contour or polygon encloses a region in the plane. In particular, the contour or polygon must not intersect itself. This is particularly important if open contours or polygons are passed because they are closed automatically, which can produce a self-intersection. To test whether the contours or polygons intersect themselves, test_self_intersection_xldTestSelfIntersectionXld can be used. If the contour or polygon intersects itself, useful values for the orientation can be calculated with orientation_points_xldOrientationPointsXld.

If more than one contour or polygon is passed, the values of the orientations are stored in a tuple in the same order as the respective contours or polygons in XLDXLDxld.

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🔗

XLDXLDxld (input_object) xld(-array) → objectHObjectHXLDHObjectHobject

Contours or polygons to be examined.

Phiphiphi (output_control) angle.rad(-array) → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Orientation of the contours or polygons (radians).

Assertion: -pi < Phi && Phi <= pi

Result🔗

The operator orientation_xldOrientationXld returns the value 2 (H_MSG_TRUE) if the input is not empty. The behavior in case of empty input (no input contours available) is set via the operator set_system('no_object_result',<Result>). If necessary an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

gen_contours_skeleton_xldGenContoursSkeletonXld, edges_sub_pixEdgesSubPix, threshold_sub_pixThresholdSubPix, gen_contour_polygon_xldGenContourPolygonXld, test_self_intersection_xldTestSelfIntersectionXld

Alternatives

elliptic_axis_xldEllipticAxisXld, smallest_rectangle2_xldSmallestRectangle2Xld

See also

moments_region_2ndMomentsRegion2nd

Module🔗

Foundation