Skip to content

moments_points_xldmoments_points_xldMomentsPointsXldMomentsPointsXldmoments_points_xldmoments_points_xld🔗

Short description🔗

moments_points_xldmoments_points_xldMomentsPointsXldMomentsPointsXldmoments_points_xldmoments_points_xld — Geometric moments \(M_{20}\), \(M_{02}\), and \(M_{11}\) of contours or polygons treated as point clouds.

Signature🔗

moments_points_xld( xld XLD, out real M11, out real M20, out real M02 )moments_points_xld( XLD : : : M11, M20, M02 )void MomentsPointsXld( const HObject& XLD, HTuple* M11, HTuple* M20, HTuple* M02 )static void HOperatorSet.MomentsPointsXld( HObject XLD, out HTuple m11, out HTuple m20, out HTuple m02 )def moments_points_xld( xld: HObject ) -> Tuple[Sequence[float], Sequence[float], Sequence[float]]

def moments_points_xld_s( xld: HObject ) -> Tuple[float, float, float]Herror moments_points_xld( const Hobject XLD, double* M11, double* M20, double* M02 )

Herror T_moments_points_xld( const Hobject XLD, Htuple* M11, Htuple* M20, Htuple* M02 )

HTuple HXLD::MomentsPointsXld( HTuple* M20, HTuple* M02 ) const

double HXLD::MomentsPointsXld( double* M20, double* M02 ) const

HTuple HXLD.MomentsPointsXld( out HTuple m20, out HTuple m02 )

double HXLD.MomentsPointsXld( out double m20, out double m02 )

Description🔗

moments_points_xldMomentsPointsXld calculates the moments (M20m20m20, M02m02m02, and M11m11m11) of a point cloud given by a contour or a polygon XLDXLDxld (i.e., the order of the points in the contour or polygon is not taken into account). Therefore, the moments are given by

\[\begin{eqnarray*} M_{p,q} = \sum_{i=0}^{n-1} (r_{i} - \bar{r})^p (c_{i} - \bar{c})^q. \end{eqnarray*}\]

. Here, \((\bar{r},\bar{c})\) is the centroid and \(n\) the number of points.

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.

moments_points_xldMomentsPointsXld 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 moments_xldMomentsXld 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.

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

Mixed second order moment.

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

Second order moment along the row axis.

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

Second order moment along the column axis.

Complexity🔗

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

Result🔗

moments_points_xldMomentsPointsXld 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, smooth_contours_xldSmoothContoursXld, gen_polygons_xldGenPolygonsXld

Alternatives

moments_xldMomentsXld, moments_any_xldMomentsAnyXld, moments_any_points_xldMomentsAnyPointsXld

See also

moments_any_points_xldMomentsAnyPointsXld, area_center_points_xldAreaCenterPointsXld, moments_region_2ndMomentsRegion2nd, area_centerAreaCenter

Module🔗

Foundation