moments_any_points_xld🔗
Short description🔗
moments_any_points_xld — Arbitrary geometric moments of contours or polygons treated as point
clouds.
Signature🔗
moments_any_points_xld( xld XLD, string Mode, real Area, point.y CenterRow, point.x CenterCol, point.x P, point.x Q, out real M )
Description🔗
moments_any_points_xld calculates arbitrary moments
M of the point clouds given by the contours or polygons
XLD (i.e., the order of the points in the contour or
polygon is not taken into account).
The computed moments are normalized depending on the desired mode
Mode:
-
‘unnormalized’: No normalization. The computed moment \(M_{p,q}\) is:
\[\begin{eqnarray*} M_{p,q} = \sum_{i=0}^{n-1} r_{i}^p c_{i}^q \end{eqnarray*}\] -
‘unnormalized_central’: Shift the contour points by their centroid \([\bar{r},\bar{c}]\) \(= [\textrm{CenterRow}, \textrm{CenterCol}]\):
\[\begin{eqnarray*} M_{p,q} = \sum_{i=0}^{n-1} (r_{i} - \bar{r})^p (c_{i} - \bar{c})^q \end{eqnarray*}\] -
‘normalized’: Normalization by the area \(A =\)
AreafromXLD:\[\begin{eqnarray*} M_{p,q} = \frac{1}{A} \sum_{i=0}^{n-1} r_{i}^p c_{i}^q \end{eqnarray*}\] -
‘central’: Normalization by the area \(A =\)
Areaand a shift of the contour points by their centroid \([\bar{r},\bar{c}]\) \(= [\textrm{CenterRow}, \textrm{CenterCol}]\):\[\begin{eqnarray*} M_{p,q} = \frac{1}{A} \sum_{i=0}^{n-1} (r_{i} - \bar{r})^p (c_{i} - \bar{c})^q \end{eqnarray*}\]
For the normalization of the moments three specific values are
used: The area Area and the coordinates
CenterRow,CenterCol of it’s centroid (this values can be
computed with area_center_points_xld).
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_any_xld should be used if the contour XLD
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_any_xld does not produce useful results. To test whether the
contours or polygons intersect themselves,
test_self_intersection_xld can be used.
If more than one contour or polygon is passed, M contains
all desired moments of the first contour/polygon followed by all the
moments of the second contour/polygon and so forth.
Execution information🔗
Execution information
-
Multithreading type: reentrant (runs in parallel with non-exclusive operators).
-
Multithreading scope: global (may be called from any thread).
-
Processed without parallelization.
Parameters🔗
XLD (input_object) xld(-array) → object
Contours or polygons to be examined.
Mode (input_control) string → (string)
Computation mode.
Default: 'unnormalized'
Suggested values: 'unnormalized', 'unnormalized_central', 'normalized', 'central'
Area (input_control) real(-array) → (real)
Area enclosed by the contour or polygon.
CenterRow (input_control) point.y(-array) → (real)
Row coordinate of the centroid.
CenterCol (input_control) point.x(-array) → (real)
Column coordinate of the centroid.
P (input_control) point.x(-array) → (integer)
First index of the desired moments \(M_{p,q}\).
Default: 1
Suggested values: 0, 1, 2, 3, 4
Q (input_control) point.x(-array) → (integer)
Second index of the desired moments \(M_{p,q}\).
Default: 1
Suggested values: 0, 1, 2, 3, 4
M (output_control) real(-array) → (real)
The computed moments.
Complexity🔗
Let n be the number of points of the contour or polygon. Then the run time is O(n).
Result🔗
moments_any_points_xld 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
area_center_points_xld, gen_contours_skeleton_xld, smooth_contours_xld, gen_polygons_xld
Alternatives
moments_points_xld, moments_any_xld
See also
moments_points_xld, area_center_points_xld, moments_region_2nd, area_center
Module🔗
Foundation