Skip to content

compactnessCompactnessCompactnesscompactnesscompactnessπŸ”—

Short descriptionπŸ”—

compactnessCompactnessCompactnesscompactnesscompactness β€” Shape factor for the compactness of a region.

SignatureπŸ”—

compactness( region Regions, out real Compactness )void Compactness( const HObject& Regions, HTuple* Compactness )static void HOperatorSet.Compactness( HObject regions, out HTuple compactness )def compactness( regions: HObject ) -> Sequence[float]

def compactness_s( regions: HObject ) -> floatHerror compactness( const Hobject Regions, double* Compactness )

Herror T_compactness( const Hobject Regions, Htuple* Compactness )

HTuple HRegion::Compactness( ) const

HTuple HRegion.Compactness( )

DescriptionπŸ”—

The operator compactnessCompactness calculates the compactness of the input regions.

  • Calculation: If L is the length of the contour (see contlengthContlength) and F the area of the region the shape factor C is defined as:

    \[\begin{eqnarray*} C^\prime = \frac{L^2}{4 F \pi} \end{eqnarray*}\]

    C = max(1,C’)

In the documentation of this chapter (Regions / Features), you can find an image illustrating regions which vary in their compactness.

The shape factor C of a circle is 1. If the region is long or has holes C is larger than 1. The operator compactnessCompactness responds to the course of the contour (roughness) and to holes. The value of C is clipped to 1.0, because the pixel area of a region can only be an approximation of a real circle’s area. This approximation error is bigger for small regions than for large regions.

In case of an empty region the operator compactnessCompactness returns the value 0 if no other behavior was set (see set_systemSetSystem). If more than one region is passed the numerical values of the shape factor are stored in a tuple, the position of a value in the tuple corresponding to the position of the region in the input tuple.

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

Region(s) to be examined.

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

Compactness of the input region(s).

Assertion: Compactness >= 1.0 || Compactness == 0

ResultπŸ”—

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

Alternatives

convexityConvexity, eccentricityEccentricity

See also

contlengthContlength, area_centerAreaCenter, select_shapeSelectShape

ModuleπŸ”—

Foundation