Skip to content

height_width_ratioHeightWidthRatioHeightWidthRatioheight_width_ratioheight_width_ratio🔗

Short description🔗

height_width_ratioHeightWidthRatioHeightWidthRatioheight_width_ratioheight_width_ratio — Compute the width, height, and aspect ratio of the surrounding rectangle parallel to the coordinate axes.

Signature🔗

height_width_ratio( region Regions, out extent.y Height, out extent.x Width, out real Ratio )void HeightWidthRatio( const HObject& Regions, HTuple* Height, HTuple* Width, HTuple* Ratio )static void HOperatorSet.HeightWidthRatio( HObject regions, out HTuple height, out HTuple width, out HTuple ratio )def height_width_ratio( regions: HObject ) -> Tuple[Sequence[int], Sequence[int], Sequence[float]]

def height_width_ratio_s( regions: HObject ) -> Tuple[int, int, float]Herror height_width_ratio( const Hobject Regions, Hlong* Height, Hlong* Width, double* Ratio )

Herror T_height_width_ratio( const Hobject Regions, Htuple* Height, Htuple* Width, Htuple* Ratio )

HTuple HRegion::HeightWidthRatio( HTuple* Width, HTuple* Ratio ) const

Hlong HRegion::HeightWidthRatio( Hlong* Width, double* Ratio ) const

HTuple HRegion.HeightWidthRatio( out HTuple width, out HTuple ratio )

int HRegion.HeightWidthRatio( out int width, out double ratio )

Description🔗

The operator height_width_ratioHeightWidthRatio calculates the surrounding rectangle of all input regions (parallel to the coordinate axes). The surrounding rectangle is described by the coordinates of the corner pixels (Row1row1row_1,Column1column1column_1,Row2row2row_2,Column2column2column_2) (see smallest_rectangle1SmallestRectangle1). Based on these values, height_width_ratioHeightWidthRatio computes the width, height, and aspect ratio of the smallest surrounding rectangle as follows:

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

If more than one region is passed in Regionsregionsregions, the results are stored in tuples in the same order as the respective regions in the Regionsregionsregions. In case of empty regions, all parameters have the value 0 if no other behavior was set (see set_systemSetSystem).

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🔗

Regionsregionsregions (input_object) region(-array) → objectHObjectHRegionHObjectHobject

Regions to be examined.

Heightheightheight (output_control) extent.y(-array) → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

Height of the surrounding rectangle of the region.

Widthwidthwidth (output_control) extent.x(-array) → (integer)HTuple (Hlong)HTuple (int / long)Sequence[int]Htuple (Hlong)

Width of the surrounding rectangle of the region.

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

Aspect ratio of the surrounding rectangle of the region.

Complexity🔗

If \(F\) is the area of the region the mean runtime complexity is \(O(sqrt(F))\).

Result🔗

The operator height_width_ratioHeightWidthRatio returns the value 2 (H_MSG_TRUE) if the input is not empty. The behavior in case of empty input (no input regions available) is set via the operator set_system('no_object_result',<Result>). The behavior in case of empty region (the region is the empty set) is set via set_system('empty_region_result',<Result>). If necessary an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

thresholdThreshold, regiongrowingRegiongrowing, connectionConnection, runlength_featuresRunlengthFeatures

Alternatives

smallest_rectangle1SmallestRectangle1, smallest_rectangle2SmallestRectangle2, region_featuresRegionFeatures

See also

select_shapeSelectShape, smallest_circleSmallestCircle, elliptic_axisEllipticAxis, area_centerAreaCenter

Module🔗

Foundation