Skip to content

elliptic_axis_points_xldelliptic_axis_points_xldEllipticAxisPointsXldEllipticAxisPointsXldelliptic_axis_points_xldelliptic_axis_points_xldπŸ”—

Short descriptionπŸ”—

elliptic_axis_points_xldelliptic_axis_points_xldEllipticAxisPointsXldEllipticAxisPointsXldelliptic_axis_points_xldelliptic_axis_points_xld β€” Parameters of the equivalent ellipse of contours or polygons treated as point clouds.

SignatureπŸ”—

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

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

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

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

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

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

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

DescriptionπŸ”—

The operator elliptic_axis_points_xldEllipticAxisPointsXld calculates the radii (Rarara, Rbrbrb) and the orientation (Phiphiphi, in radians) of the ellipse having the same orientation and the same aspect ratio as the point cloud given by the contour or polygon XLDXLDxld (i.e., the order of the points in the contour or polygon is not taken into account). If the contour or polygon is closed (end point = start point), the end point of the contour or polygon is not taken into account to avoid that it receives twice the weight of the other points.

Calculation: If the moments \(M_{20}\), \(M_{02}\) and \(M_{11}\) are normalized to the area (see moments_points_xldMomentsPointsXld), the major radius Rarara and the minor radius 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, i.e., the angle between the major axis and the \(x\) (column) axis, is defined by:

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

elliptic_axis_points_xldEllipticAxisPointsXld should be used if the contour XLDXLDxld intersects itself or if it is not possible to close the contour using a line from end to start point without self-intersection, because in this case elliptic_axis_xldEllipticAxisXld does not produce useful results. To test whether the contours or polygons intersect themselves, test_self_intersection_xldTestSelfIntersectionXld can be used.

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 column axis (radians).

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

ComplexityπŸ”—

Let n be the number of points of the contour or polygon. Then the run time is O(n).

ResultπŸ”—

elliptic_axis_points_xldEllipticAxisPointsXld 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_points_xldAreaCenterPointsXld, gen_ellipse_contour_xldGenEllipseContourXld

Alternatives

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