Skip to content

rectangularity_xldRectangularityXldRectangularityXldrectangularity_xldrectangularity_xldπŸ”—

Short descriptionπŸ”—

rectangularity_xldRectangularityXldRectangularityXldrectangularity_xldrectangularity_xld β€” Shape factor for the rectangularity of contours or polygons.

SignatureπŸ”—

rectangularity_xld( xld XLD, out real Rectangularity )void RectangularityXld( const HObject& XLD, HTuple* Rectangularity )static void HOperatorSet.RectangularityXld( HObject XLD, out HTuple rectangularity )def rectangularity_xld( xld: HObject ) -> Sequence[float]

def rectangularity_xld_s( xld: HObject ) -> floatHerror rectangularity_xld( const Hobject XLD, double* Rectangularity )

Herror T_rectangularity_xld( const Hobject XLD, Htuple* Rectangularity )

HTuple HXLD::RectangularityXld( ) const

HTuple HXLD.RectangularityXld( )

DescriptionπŸ”—

The operator rectangularity_xldRectangularityXld calculates the rectangularity 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.

To determine the rectangularity, first a rectangle is computed that has the same first and second order moments as the input contour or polygon. The computation of the rectangularity measure is finally based on the area of the difference between the computed rectangle and the input contour or polygon normalized with respect to the area of the rectangle.

For rectangles rectangularity_xldRectangularityXld returns the value 1. The more the input contour or polygon deviates from a perfect rectangle, the less the returned value for Rectangularityrectangularityrectangularity will be. If more than one contour or polygon is passed, the results are stored in tuples in the same order as the respective contours or polygons in XLDXLDxld.

AttentionπŸ”—

For input contours or polygons which orientation cannot be computed by using second order moments (as it is the case for squares, for example), the returned Rectangularityrectangularityrectangularity is underestimated by up to 10% depending on the orientation of the input contour or polygon.

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.

Rectangularityrectangularityrectangularity (output_control) real(-array) β†’ (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Rectangularity of the input contours or polygons.

Assertion: 0 <= Rectangularity && Rectangularity <= 1.0

ResultπŸ”—

The operator rectangularity_xldRectangularityXld returns the value 2 (H_MSG_TRUE) if the input is not empty. The behavior in case of empty input (no input contours or polygons 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, compactness_xldCompactnessXld, eccentricity_xldEccentricityXld

See also

area_center_xldAreaCenterXld, select_shape_xldSelectShapeXld

ReferencesπŸ”—

P. L. Rosin: β€œMeasuring rectangularity”; Machine Vision and Applications; vol. 11; pp. 191-196; Springer-Verlag, 1999.

ModuleπŸ”—

Foundation