Skip to content

circularity_xldCircularityXldCircularityXldcircularity_xldcircularity_xld🔗

Short description🔗

circularity_xldCircularityXldCircularityXldcircularity_xldcircularity_xld — Shape factor for the circularity (similarity to a circle) of contours or polygons.

Signature🔗

circularity_xld( xld XLD, out real Circularity )void CircularityXld( const HObject& XLD, HTuple* Circularity )static void HOperatorSet.CircularityXld( HObject XLD, out HTuple circularity )def circularity_xld( xld: HObject ) -> Sequence[float]

def circularity_xld_s( xld: HObject ) -> floatHerror circularity_xld( const Hobject XLD, double* Circularity )

Herror T_circularity_xld( const Hobject XLD, Htuple* Circularity )

HTuple HXLD::CircularityXld( ) const

HTuple HXLD.CircularityXld( )

Description🔗

The operator circularity_xldCircularityXld calculates the similarity of each input contour or polygon with a circle. 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\) is the enclosed area of the contour or polygon and \(max\) is the maximum distance from the center to all contour or polygon pixels, the shape factor Circularitycircularitycircularity is defined as:

\[\begin{eqnarray*} \textrm{Circularity} = \frac{F}{(max^2 * \pi)} \end{eqnarray*}\]

The shape factor Circularitycircularitycircularity of a circle is 1. If the contour or polygon encloses an elongated area Circularitycircularitycircularity is smaller than 1. The operator circularity_xldCircularityXld especially responds to large bulges.

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

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

Roundness of the input contours or polygons.

Assertion: 0 <= Circularity && Circularity <= 1.0

Result🔗

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

Alternatives

compactness_xldCompactnessXld, convexity_xldConvexityXld, eccentricity_xldEccentricityXld, rectangularity_xldRectangularityXld

See also

area_center_xldAreaCenterXld, select_shape_xldSelectShapeXld

Module🔗

Foundation