Skip to content

elliptic_axis_xldelliptic_axis_xldEllipticAxisXldEllipticAxisXldelliptic_axis_xldelliptic_axis_xldπŸ”—

Short descriptionπŸ”—

elliptic_axis_xldelliptic_axis_xldEllipticAxisXldEllipticAxisXldelliptic_axis_xldelliptic_axis_xld β€” Parameters of the equivalent ellipse of contours or polygons.

SignatureπŸ”—

elliptic_axis_xld( xld XLD, out real Ra, out real Rb, out angle.rad Phi )elliptic_axis_xld( XLD : : : Ra, Rb, Phi )void EllipticAxisXld( const HObject& XLD, HTuple* Ra, HTuple* Rb, HTuple* Phi )static void HOperatorSet.EllipticAxisXld( HObject XLD, out HTuple ra, out HTuple rb, out HTuple phi )def elliptic_axis_xld( xld: HObject ) -> Tuple[Sequence[float], Sequence[float], Sequence[float]]

def elliptic_axis_xld_s( xld: HObject ) -> Tuple[float, float, float]Herror elliptic_axis_xld( const Hobject XLD, double* Ra, double* Rb, double* Phi )

Herror T_elliptic_axis_xld( const Hobject XLD, Htuple* Ra, Htuple* Rb, Htuple* Phi )

HTuple HXLD::EllipticAxisXld( HTuple* Rb, HTuple* Phi ) const

double HXLD::EllipticAxisXld( double* Rb, double* Phi ) const

HTuple HXLD.EllipticAxisXld( out HTuple rb, out HTuple phi )

double HXLD.EllipticAxisXld( out double rb, out double phi )

DescriptionπŸ”—

The operator elliptic_axis_xldEllipticAxisXld calculates the radii and the orientations of the ellipses having the same orientation and the same aspect ratio as the input contours or polygons. The length of the major radius Rarara and the minor radius Rbrbrb as well as the orientation of the main axis with regard to the horizontal (Phiphiphi) are determined. The angle is indicated in radians. It is assumed that the contours or polygons are closed. If this is not the case elliptic_axis_xldEllipticAxisXld will artificially close the contours or polygons.

Calculation: If the moments \(M_{20}\), \(M_{02}\) and \(M_{11}\) are normalized and passed to the area (see moments_xldMomentsXld), 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} \\ \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 \textrm{atan2}(2 M_{11},M_{02} - M_{20}) \end{eqnarray*}\]

It should be noted that elliptic_axis_xldEllipticAxisXld only returns useful results if the contour or polygon encloses a region in the plane. In particular, the contour or polygon must not intersect itself. This is particularly important if open contours or polygons are passed because they are closed automatically, which can produce a self-intersection. To test whether the contours or polygons intersect themselves, test_self_intersection_xldTestSelfIntersectionXld can be used. If the contour or polygon intersects itself, useful values for the ellipse parameters can be calculated with elliptic_axis_points_xldEllipticAxisPointsXld.

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.

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) β†’ objectobjectHObjectHXLDHObjectHobject

Contours or polygons to be examined.

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

Major radius.

Assertion: Ra >= 0.0

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

Minor radius.

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

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

Angle between the major axis and the x axis (radians).

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

ComplexityπŸ”—

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

ResultπŸ”—

elliptic_axis_xldEllipticAxisXld 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, test_self_intersection_xldTestSelfIntersectionXld

Possible successors

area_center_xldAreaCenterXld, gen_ellipse_contour_xldGenEllipseContourXld

Alternatives

elliptic_axis_points_xldEllipticAxisPointsXld, smallest_rectangle2SmallestRectangle2

See also

moments_xldMomentsXld, smallest_circle_xldSmallestCircleXld, smallest_rectangle1_xldSmallestRectangle1Xld, smallest_rectangle2_xldSmallestRectangle2Xld, shape_trans_xldShapeTransXld

ReferencesπŸ”—

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

ModuleπŸ”—

Foundation