Skip to content

elliptic_axisEllipticAxisEllipticAxiselliptic_axiselliptic_axisπŸ”—

Short descriptionπŸ”—

elliptic_axisEllipticAxisEllipticAxiselliptic_axiselliptic_axis β€” Calculate the parameters of the equivalent ellipse.

SignatureπŸ”—

elliptic_axis( region Regions, out real Ra, out real Rb, out angle.rad Phi )void EllipticAxis( const HObject& Regions, HTuple* Ra, HTuple* Rb, HTuple* Phi )static void HOperatorSet.EllipticAxis( HObject regions, out HTuple ra, out HTuple rb, out HTuple phi )def elliptic_axis( regions: HObject ) -> Tuple[Sequence[float], Sequence[float], Sequence[float]]

def elliptic_axis_s( regions: HObject ) -> Tuple[float, float, float]Herror elliptic_axis( const Hobject Regions, double* Ra, double* Rb, double* Phi )

Herror T_elliptic_axis( const Hobject Regions, Htuple* Ra, Htuple* Rb, Htuple* Phi )

HTuple HRegion::EllipticAxis( HTuple* Rb, HTuple* Phi ) const

double HRegion::EllipticAxis( double* Rb, double* Phi ) const

HTuple HRegion.EllipticAxis( out HTuple rb, out HTuple phi )

double HRegion.EllipticAxis( out double rb, out double phi )

DescriptionπŸ”—

The operator elliptic_axisEllipticAxis calculates the radii Rarara and Rbrbrb and the orientation Phiphiphi of the ellipse having the same orientation and the same aspect ratio as the input region in Regionsregionsregions. Several input regions can be passed as tuples. Rarara represents the main radius of the ellipse whereas the radius Rbrbrb represents the secondary radius of the ellipse. The orientation of the main axis with regard to the x-axis is returned in Phiphiphi which is represented in radians. The principle axis of the ellipse is equivalent to the principle axis of the inertia moment of the input region.

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

Calculation:

If the moments \(M_{20}\), \(M_{02}\) and \(M_{11}\) are normalized and passed to the area (see moments_region_2ndMomentsRegion2nd), the radii Rarara and Rbrbrb are calculated as:

\[\begin{eqnarray*} \textrm{Ra} = \frac{\sqrt{8(M_{20}+M_{02}+\sqrt{(M_{20}-M_{02})^2+4M_{11}^2})}}{2} \end{eqnarray*}\]
\[\begin{eqnarray*} \textrm{Rb} = \frac{\sqrt{8(M_{20}+M_{02}-\sqrt{(M_{20}-M_{02})^2+4M_{11}^2})}}{2} \end{eqnarray*}\]

The orientation Phiphiphi is defined by:

\[\begin{eqnarray*} \textrm{Phi} = -0.5 atan2(2 M_{11},M_{02} - M_{20}) \end{eqnarray*}\]

If more than one region is passed, the results are stored in tuples. The index of an resulting tuple element corresponds to the index of the respective input region.

If an empty region is passed, all parameters have the value 0.0 if no other behavior was set (see set_system('no_object_result',<Result>)).

AttentionπŸ”—

It should be noted that, like for all region-moments-based operators, the region’s pixels are regarded as mathematical, infinitely small points that are represented by the center of the pixels. This means that Rarara and Rbrbrb can assume the value 00. In particular, for an empty region and a region containing a single point Rarara \(=\) Rbrbrb \(=\) 00 is returned. Furthermore, for regions whose points lie exactly on a straight line (e.g., one pixel high horizontal regions or one pixel wide vertical regions), Rbrbrb \(=\) 00 is returned.

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

Input regions.

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

Main radius (normalized to the area).

Assertion: Ra >= 0.0

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

Secondary radius (normalized to the area).

Assertion: Rb >= 0.0 && Rb <= Ra

Phiphiphi (output_control) angle.rad(-array) β†’ (real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Angle between main radius and x-axis in radians.

Assertion: -pi / 2 < Phi && Phi <= pi / 2

ExampleπŸ”—

(HDevelop)

read_image(Image,'fabrik')
regiongrowing(Image,Seg,5,5,6,100)
elliptic_axis(Seg,Ra,Rb,Phi)
area_center(Seg,_,Row,Column)
gen_ellipse(Ellipses,Row,Column,Phi,Ra,Rb)
dev_set_draw('margin')
dev_display(Ellipses)
(C)
read_image(&Image,"fabrik")\;
regiongrowing(Image,&Seg,5,5,6.0,100)\;
T_elliptic_axis(Seg,&Ra,&Rb,&Phi)\;
T_area_center(Seg,NULL,&Row,&Column)\;
T_gen_ellipse(&Ellipses,Row,Column,Phi,Ra,Rb)\;

ComplexityπŸ”—

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

ResultπŸ”—

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

Possible successors

gen_ellipseGenEllipse

Alternatives

smallest_rectangle2SmallestRectangle2, orientation_regionOrientationRegion

See also

moments_region_2ndMomentsRegion2nd, select_shapeSelectShape, set_shapeSetShape

ReferencesπŸ”—

R. Haralick, L. Shapiro β€œComputer and Robot Vision” Addison-Wesley, 1992, pp. 73-75

ModuleπŸ”—

Foundation