Skip to content

height_width_ratio_xldHeightWidthRatioXldHeightWidthRatioXldheight_width_ratio_xldheight_width_ratio_xld🔗

Short description🔗

height_width_ratio_xldHeightWidthRatioXldHeightWidthRatioXldheight_width_ratio_xldheight_width_ratio_xld — Compute the width, height, and aspect ratio of the enclosing rectangle parallel to the coordinate axes of contours or polygons.

Signature🔗

height_width_ratio_xld( xld XLD, out extent.y Height, out extent.x Width, out real Ratio )void HeightWidthRatioXld( const HObject& XLD, HTuple* Height, HTuple* Width, HTuple* Ratio )static void HOperatorSet.HeightWidthRatioXld( HObject XLD, out HTuple height, out HTuple width, out HTuple ratio )def height_width_ratio_xld( xld: HObject ) -> Tuple[Sequence[float], Sequence[float], Sequence[float]]

def height_width_ratio_xld_s( xld: HObject ) -> Tuple[float, float, float]Herror height_width_ratio_xld( const Hobject XLD, double* Height, double* Width, double* Ratio )

Herror T_height_width_ratio_xld( const Hobject XLD, Htuple* Height, Htuple* Width, Htuple* Ratio )

HTuple HXLD::HeightWidthRatioXld( HTuple* Width, HTuple* Ratio ) const

double HXLD::HeightWidthRatioXld( double* Width, double* Ratio ) const

HTuple HXLD.HeightWidthRatioXld( out HTuple width, out HTuple ratio )

double HXLD.HeightWidthRatioXld( out double width, out double ratio )

Description🔗

The operator height_width_ratio_xldHeightWidthRatioXld calculates the enclosing rectangle (parallel to the coordinate axes) for each input contour or polygon. The enclosing rectangle is described by the coordinates of the corner pixels (Row1row1row_1,Column1column1column_1,Row2row2row_2,Column2column2column_2) (see smallest_rectangle1_xldSmallestRectangle1Xld). Based on these values, height_width_ratio_xldHeightWidthRatioXld computes the width, height, and aspect ratio of the smallest surrounding rectangle as follows:

\[\begin{eqnarray*} \textrm{Width} & = & \textrm{Column2} - \textrm{Column1} \\ \textrm{Height} & = & \textrm{Row2} - \textrm{Row1} \\ \textrm{Ratio} & = & \textrm{Height} / \textrm{Width} \end{eqnarray*}\]

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. In case of an empty contour all parameters have the value 0 if no other behavior was set (see set_systemSetSystem).

Attention🔗

If \(\textrm{Width}=0\), Ratioratioratio is set to DBL_MAX (1.797e308).

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.

Heightheightheight (output_control) extent.y(-array) → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Height of the enclosing rectangle.

Widthwidthwidth (output_control) extent.x(-array) → (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Width of the enclosing rectangle.

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

Aspect ratio of the enclosing rectangle.

Complexity🔗

If \(N\) is the number of contour points, the runtime complexity is \(O(N)\).

Result🔗

height_width_ratio_xldHeightWidthRatioXld returns 2 (H_MSG_TRUE) if the input is not empty. If the input is empty the behavior can be set via 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

Possible successors

gen_polygons_xldGenPolygonsXld

Alternatives

smallest_rectangle1_xldSmallestRectangle1Xld, smallest_rectangle2_xldSmallestRectangle2Xld, shape_trans_xldShapeTransXld

See also

shape_trans_xldShapeTransXld, smallest_circle_xldSmallestCircleXld, elliptic_axis_xldEllipticAxisXld, area_center_xldAreaCenterXld

Module🔗

Foundation