moments_any_xldmoments_any_xldMomentsAnyXldMomentsAnyXldmoments_any_xld (算子)

名称

moments_any_xldmoments_any_xldMomentsAnyXldMomentsAnyXldmoments_any_xld — 轮廓或多边形的任意几何矩。

签名

moments_any_xld(XLD : : Mode, PointOrder, Area, CenterRow, CenterCol, P, Q : M)

Herror moments_any_xld(const Hobject XLD, const char* Mode, const char* PointOrder, double Area, double CenterRow, double CenterCol, const Hlong P, const Hlong Q, double* M)

Herror T_moments_any_xld(const 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)

void MomentsAnyXld(const 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)

HTuple HXLD::MomentsAnyXld(const HString& Mode, const HTuple& PointOrder, const HTuple& Area, const HTuple& CenterRow, const HTuple& CenterCol, const HTuple& P, const HTuple& Q) const

double HXLD::MomentsAnyXld(const HString& Mode, const HString& PointOrder, double Area, double CenterRow, double CenterCol, Hlong P, Hlong Q) const

double HXLD::MomentsAnyXld(const char* Mode, const char* PointOrder, double Area, double CenterRow, double CenterCol, Hlong P, Hlong Q) const

double HXLD::MomentsAnyXld(const wchar_t* Mode, const wchar_t* PointOrder, double Area, double CenterRow, double CenterCol, Hlong P, Hlong Q) const   ( Windows only)

static void HOperatorSet.MomentsAnyXld(HObject XLD, HTuple mode, HTuple pointOrder, HTuple area, HTuple centerRow, HTuple centerCol, HTuple p, HTuple q, out HTuple m)

HTuple HXLD.MomentsAnyXld(string mode, HTuple pointOrder, HTuple area, HTuple centerRow, HTuple centerCol, HTuple p, HTuple q)

double HXLD.MomentsAnyXld(string mode, string pointOrder, double area, double centerRow, double centerCol, int p, int q)

def moments_any_xld(xld: HObject, mode: str, point_order: MaybeSequence[str], area: MaybeSequence[float], center_row: MaybeSequence[float], center_col: MaybeSequence[float], p: MaybeSequence[int], q: MaybeSequence[int]) -> Sequence[float]

def moments_any_xld_s(xld: HObject, mode: str, point_order: MaybeSequence[str], area: MaybeSequence[float], center_row: MaybeSequence[float], center_col: MaybeSequence[float], p: MaybeSequence[int], q: MaybeSequence[int]) -> float

描述

moments_any_xldmoments_any_xldMomentsAnyXldMomentsAnyXldMomentsAnyXldmoments_any_xld calculates arbitrary moments MMMMmm of the regions enclosed by the contours or polygons XLDXLDXLDXLDXLDxld. 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.假设轮廓或多边形是闭合的。 If this is not the case moments_any_xldmoments_any_xldMomentsAnyXldMomentsAnyXldMomentsAnyXldmoments_any_xld will artificially close the contours or polygons.

需要注意的是,moments_any_xldmoments_any_xldMomentsAnyXldMomentsAnyXldMomentsAnyXldmoments_any_xld 仅在轮廓或多边形在平面上包围区域时才会返回有效结果。特别需要注意的是,轮廓或多边形不得自相交。当传递开放轮廓或多边形时,这一点尤为重要,因为它们会被自动闭合,从而可能产生自相交的情况。可使用 test_self_intersection_xldtest_self_intersection_xldTestSelfIntersectionXldTestSelfIntersectionXldTestSelfIntersectionXldtest_self_intersection_xld 检测轮廓或多边形是否自相交。 If the contour or polygon intersects itself, useful values for the moments can be calculated with moments_any_points_xldmoments_any_points_xldMomentsAnyPointsXldMomentsAnyPointsXldMomentsAnyPointsXldmoments_any_points_xld

The computed moments are normalized depending on the desired mode ModeModeModeModemodemode:

'unnormalized':

No normalization. Let be the enclosed image region. Then the computed moment is equivalent to:

'unnormalized_central':

Shift the region by its centroid [CenterRowCenterRowCenterRowCenterRowcenterRowcenter_row, CenterColCenterColCenterColCenterColcenterColcenter_col]:

'normalized':

Normalization by the area AreaAreaAreaAreaareaarea of the enclosed image region:

'central':

Normalization by the area AreaAreaAreaAreaareaarea of the enclosed image region and a shift of the region by it's centroid [CenterRowCenterRowCenterRowCenterRowcenterRowcenter_row, CenterColCenterColCenterColCenterColcenterColcenter_col]:

For the normalization of the moments three specific moments are used: The area AreaAreaAreaAreaareaarea of the enclosed image region and the coordinates CenterRowCenterRowCenterRowCenterRowcenterRowcenter_row,CenterColCenterColCenterColCenterColcenterColcenter_col of it's centroid (this values can be calculated with area_center_xldarea_center_xldAreaCenterXldAreaCenterXldAreaCenterXldarea_center_xld). In addition to that moments_any_xldmoments_any_xldMomentsAnyXldMomentsAnyXldMomentsAnyXldmoments_any_xld expects information about the point order of the input contours/polygons in PointOrderPointOrderPointOrderPointOrderpointOrderpoint_order, see area_center_xldarea_center_xldAreaCenterXldAreaCenterXldAreaCenterXldarea_center_xld again.

If more than one contour or polygon is passed, MMMMmm contains all desired moments of the first contour/polygon followed by all the moments of the second contour/polygon and so forth.

执行信息

参数

XLDXLDXLDXLDXLDxld (输入对象)  xld(-array) objectHXLDHObjectHXLDHobject

待检查的轮廓或多边形。

ModeModeModeModemodemode (输入控制)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Computation mode.

默认值: 'unnormalized' "unnormalized" "unnormalized" "unnormalized" "unnormalized" "unnormalized"

建议值: 'unnormalized'"unnormalized""unnormalized""unnormalized""unnormalized""unnormalized", 'unnormalized_central'"unnormalized_central""unnormalized_central""unnormalized_central""unnormalized_central""unnormalized_central", 'normalized'"normalized""normalized""normalized""normalized""normalized", 'central'"central""central""central""central""central"

PointOrderPointOrderPointOrderPointOrderpointOrderpoint_order (输入控制)  string(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Point order along the boundary.

默认值: 'positive' "positive" "positive" "positive" "positive" "positive"

建议值: 'positive'"positive""positive""positive""positive""positive", 'negative'"negative""negative""negative""negative""negative"

AreaAreaAreaAreaareaarea (输入控制)  real(-array) HTupleMaybeSequence[float]HTupleHtuple (real) (double) (double) (double)

由轮廓或多边形包围的面积。

CenterRowCenterRowCenterRowCenterRowcenterRowcenter_row (输入控制)  point.y(-array) HTupleMaybeSequence[float]HTupleHtuple (real) (double) (double) (double)

质心的行坐标。

CenterColCenterColCenterColCenterColcenterColcenter_col (输入控制)  point.x(-array) HTupleMaybeSequence[float]HTupleHtuple (real) (double) (double) (double)

质心的列坐标。

PPPPpp (输入控制)  point.x(-array) HTupleMaybeSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

First index of the desired moments

默认值: 1

建议值: 0, 1, 2, 3, 4

QQQQqq (输入控制)  point.x(-array) HTupleMaybeSequence[int]HTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Second index of the desired moments

默认值: 1

建议值: 0, 1, 2, 3, 4

MMMMmm (输出控制)  real(-array) HTupleSequence[float]HTupleHtuple (real) (double) (double) (double)

The computed moments.

复杂度

设 n 为轮廓或多边形的点数。则运行时间为 O(n)。

结果

moments_any_xldmoments_any_xldMomentsAnyXldMomentsAnyXldMomentsAnyXldmoments_any_xld 在输入不为空时返回 2 ( H_MSG_TRUE )。如果输入为空则可设置行为通过 set_system(::'no_object_result',<Result>:)set_system("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)SetSystem("no_object_result",<Result>)set_system("no_object_result",<Result>)。如有必要,则抛出异常。

可能的前趋

area_center_xldarea_center_xldAreaCenterXldAreaCenterXldAreaCenterXldarea_center_xld, gen_contours_skeleton_xldgen_contours_skeleton_xldGenContoursSkeletonXldGenContoursSkeletonXldGenContoursSkeletonXldgen_contours_skeleton_xld, smooth_contours_xldsmooth_contours_xldSmoothContoursXldSmoothContoursXldSmoothContoursXldsmooth_contours_xld, gen_polygons_xldgen_polygons_xldGenPolygonsXldGenPolygonsXldGenPolygonsXldgen_polygons_xld

替代

moments_xldmoments_xldMomentsXldMomentsXldMomentsXldmoments_xld, moments_any_points_xldmoments_any_points_xldMomentsAnyPointsXldMomentsAnyPointsXldMomentsAnyPointsXldmoments_any_points_xld

另见

moments_xldmoments_xldMomentsXldMomentsXldMomentsXldmoments_xld, area_center_xldarea_center_xldAreaCenterXldAreaCenterXldAreaCenterXldarea_center_xld, moments_region_2ndmoments_region_2ndMomentsRegion2ndMomentsRegion2ndMomentsRegion2ndmoments_region_2nd, area_centerarea_centerAreaCenterAreaCenterAreaCenterarea_center

模块

基础