Herror ::moments_any_xld (
    Hobject XLD,
    const HTuple &Mode,
    const HTuple &PointOrder,
    const HTuple &Area,
    const HTuple &CenterRow,
    const HTuple &CenterCol,
    const HTuple &P,
    const HTuple &Q,
    double *M
)
Herror ::moments_any_xld (
    Hobject XLD,
    const HTuple &Mode,
    const HTuple &PointOrder,
    const HTuple &Area,
    const HTuple &CenterRow,
    const HTuple &CenterCol,
    const HTuple &P,
    const HTuple &Q,
    HTuple *M
)

Arbitrary geometric moments of contours or polygons.

::moments_any_xld calculates arbitrary moments M of the region enclosed by the contours or polygons XLD. The moments are computed by applying Green's theorem using only the points on the contour or polygon, i.e., no region is generated explicitly for the purpose of calculating the features. It is assumed that the contours or polygons are closed. If this is not the case ::moments_any_xld will add one point to artificially produce a closed shape. The computed moments are normalized depending on the desired mode Mode:

'unnormalized': No normalization.

'normalized': Normalization by the area of the enclosed image region.

'central': Normalization by the area of the enclosed image region and a shift of the region by it's centroid.

For the normalization of the moments three specific moments are used: The area Area of the enclosed image region and the coordinates CenterRow,CenterRow of it's centroid, see ::area_center_xld. In addition to that ::moments_any_xld ecpects information about the point order of the input contours/polygons in PointOrder, see ::area_center_xld again. 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.


Parameters

XLD (input_object)
xld(-array) -> Hobject: HXLD(Array)
Contours or polygons to be examined.

Mode (input_control)
string -> HTuple.char *
computation mode.
Default value: 'unnormalized'
Suggested values: 'unnormalized', 'normalized', 'central'

PointOrder (input_control)
string(-array) -> HTuple.char *
point order along the boundary.
Default value: 'positive'
Suggested values: 'positive', 'negative'

Area (input_control)
real(-array) -> HTuple.double
Area enclosed by the contour or polygon.

CenterRow (input_control)
point.y(-array) -> HTuple.double
Row coordinate of the centroid.

CenterCol (input_control)
point.x(-array) -> HTuple.double
Column coordinate of the centroid.

P (input_control)
point.x(-array) -> HTuple.long
first index of the desired moments M[P,Q].
Default value: 1

Q (input_control)
point.x(-array) -> HTuple.long
second index of the desired moments M[P,Q].
Default value: 1

M (output_control)
real(-array) -> (HTuple.) double *
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_xld returns H_MSG_TRUE if the input is not empty. If the input is empty the behaviour can be set via ::set_system('no_object_result',<Result>). If necessary, an exception is raised.


Possible Predecessors

::area_center_xld, ::gen_contours_skeleton_xld, ::smooth_contours_xld, ::gen_polygons_xld


Alternatives

::moments_xld


See also

::moments_xld, ::area_center_xld, ::moments_region_2nd, ::area_center


Module

Sub-pixel operators



Copyright © 1996-2002 MVTec Software GmbH