Skip to content

convexity_xldConvexityXldConvexityXldconvexity_xldconvexity_xld🔗

Short description🔗

convexity_xldConvexityXldConvexityXldconvexity_xldconvexity_xld — Shape factor for the convexity of contours or polygons.

Signature🔗

convexity_xld( xld XLD, out real Convexity )void ConvexityXld( const HObject& XLD, HTuple* Convexity )static void HOperatorSet.ConvexityXld( HObject XLD, out HTuple convexity )def convexity_xld( xld: HObject ) -> Sequence[float]

def convexity_xld_s( xld: HObject ) -> floatHerror convexity_xld( const Hobject XLD, double* Convexity )

Herror T_convexity_xld( const Hobject XLD, Htuple* Convexity )

HTuple HXLD::ConvexityXld( ) const

HTuple HXLD.ConvexityXld( )

Description🔗

The operator convexity_xldConvexityXld calculates the convexity for each input contour or polygon. The input contour or polygon must not intersect itself, otherwise the resulting parameter is not meaningful (Whether the input contour or polygon intersects itself or not can be determined with test_self_intersection_xldTestSelfIntersectionXld). If the input contour or polygon is not closed it will be closed automatically.

Calculation: If \(F_{c}\) is the area of the convex hull and \(F_{o}\) the area enclosed by the original contour or polygon the shape factor Convexityconvexityconvexity is defined as:

\[\begin{eqnarray*}\textrm{Convexity} = \frac{F_{o}}{F_{c}}\end{eqnarray*}\]

The shape factor Convexityconvexityconvexity is 1 if the contour or polygon is convex (e.g., a rectangle, circle, etc.). If there are indentations Convexityconvexityconvexity is smaller than 1.

If more than one contour or polygon is passed, the numerical results of the shape factor 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.

Convexityconvexityconvexity (output_control) real(-array) → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Convexity of the input contours or polygons.

Assertion: Convexity <= 1

Result🔗

The operator convexity_xldConvexityXld returns the value 2 (H_MSG_TRUE) if the input is not empty. The behavior in case of empty input (no input contour 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

See also

area_center_xldAreaCenterXld, select_shape_xldSelectShapeXld, shape_trans_xldShapeTransXld

Module🔗

Foundation