Skip to content

compactness_xldCompactnessXldCompactnessXldcompactness_xldcompactness_xld🔗

Short description🔗

compactness_xldCompactnessXldCompactnessXldcompactness_xldcompactness_xld — Shape factor for the compactness of contours or polygons.

Signature🔗

compactness_xld( xld XLD, out real Compactness )void CompactnessXld( const HObject& XLD, HTuple* Compactness )static void HOperatorSet.CompactnessXld( HObject XLD, out HTuple compactness )def compactness_xld( xld: HObject ) -> Sequence[float]

def compactness_xld_s( xld: HObject ) -> floatHerror compactness_xld( const Hobject XLD, double* Compactness )

Herror T_compactness_xld( const Hobject XLD, Htuple* Compactness )

HTuple HXLD::CompactnessXld( ) const

HTuple HXLD.CompactnessXld( )

Description🔗

The operator compactness_xldCompactnessXld calculates the compactness of each input contour or polygon in XLDXLDxld. 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 \(L\) is the length and \(F\) the enclosed area of the contour or polygon the shape factor Compactnesscompactnesscompactness is defined as:

\[\begin{eqnarray*} \textrm{Compactness} = \frac{L^2}{4 F \pi} \end{eqnarray*}\]

The shape factor Compactnesscompactnesscompactness of a circle is 1. If the contour or polygon encloses an elongated area Compactnesscompactnesscompactness is larger than 1. The operator compactness_xldCompactnessXld responds to the course of the contour or polygon (roughness). If more than one contour or polygon is passed, the shape factors 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.

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

Compactness of the input contours or polygons.

Assertion: Compactness >= 1.0 || Compactness == 0

Result🔗

The operator compactness_xldCompactnessXld 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

circularity_xldCircularityXld, convexity_xldConvexityXld, eccentricity_xldEccentricityXld, rectangularity_xldRectangularityXld

See also

area_center_xldAreaCenterXld, select_shape_xldSelectShapeXld

Module🔗

Foundation