rectangularity_xldrectangularity_xldRectangularityXldRectangularityXldrectangularity_xld (Operator)

Name

rectangularity_xldrectangularity_xldRectangularityXldRectangularityXldrectangularity_xld — Shape factor for the rectangularity of contours or polygons.

Signature

rectangularity_xld(XLD : : : Rectangularity)

Herror rectangularity_xld(const Hobject XLD, double* Rectangularity)

Herror T_rectangularity_xld(const Hobject XLD, Htuple* Rectangularity)

void RectangularityXld(const HObject& XLD, HTuple* Rectangularity)

HTuple HXLD::RectangularityXld() const

static void HOperatorSet.RectangularityXld(HObject XLD, out HTuple rectangularity)

HTuple HXLD.RectangularityXld()

def rectangularity_xld(xld: HObject) -> Sequence[float]

def rectangularity_xld_s(xld: HObject) -> float

Description

The operator rectangularity_xldrectangularity_xldRectangularityXldRectangularityXldrectangularity_xld calculates the rectangularity of each input contour or polygon in XLDXLDXLDXLDxld. 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_xldtest_self_intersection_xldTestSelfIntersectionXldTestSelfIntersectionXldtest_self_intersection_xld). 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_xldrectangularity_xldRectangularityXldRectangularityXldrectangularity_xld returns the value 1. The more the input contour or polygon deviates from a perfect rectangle, the less the returned value for RectangularityRectangularityRectangularityrectangularityrectangularity 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 XLDXLDXLDXLDxld.

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 RectangularityRectangularityRectangularityrectangularityrectangularity is underestimated by up to 10% depending on the orientation of the input contour or polygon.

Execution Information

Parameters

XLDXLDXLDXLDxld (input_object)  xld(-array) objectHXLDHObjectHObjectHobject

Contours or polygons to be examined.

RectangularityRectangularityRectangularityrectangularityrectangularity (output_control)  real(-array) HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)

Rectangularity of the input contours or polygons.

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

Result

The operator rectangularity_xldrectangularity_xldRectangularityXldRectangularityXldrectangularity_xld 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>)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)set_system("no_object_result",<Result>). If necessary an exception is raised.

Possible Predecessors

gen_contours_skeleton_xldgen_contours_skeleton_xldGenContoursSkeletonXldGenContoursSkeletonXldgen_contours_skeleton_xld, edges_sub_pixedges_sub_pixEdgesSubPixEdgesSubPixedges_sub_pix, threshold_sub_pixthreshold_sub_pixThresholdSubPixThresholdSubPixthreshold_sub_pix, gen_contour_polygon_xldgen_contour_polygon_xldGenContourPolygonXldGenContourPolygonXldgen_contour_polygon_xld, test_self_intersection_xldtest_self_intersection_xldTestSelfIntersectionXldTestSelfIntersectionXldtest_self_intersection_xld

Alternatives

circularity_xldcircularity_xldCircularityXldCircularityXldcircularity_xld, convexity_xldconvexity_xldConvexityXldConvexityXldconvexity_xld, compactness_xldcompactness_xldCompactnessXldCompactnessXldcompactness_xld, eccentricity_xldeccentricity_xldEccentricityXldEccentricityXldeccentricity_xld

See also

area_center_xldarea_center_xldAreaCenterXldAreaCenterXldarea_center_xld, select_shape_xldselect_shape_xldSelectShapeXldSelectShapeXldselect_shape_xld

References

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

Module

Foundation