You are here: Start » Function Reference » Shape Features » ShapeMoment

ShapeMoment
Header: | FIL.h |
---|---|
Namespace: | fil |
Computes the selected second-order moment of a shape in regular and normalized ( divided by shape area ) variant.
Syntax
void fil::ShapeMoment ( const fil::Path& inShape, fil::ShapeMomentType::Type inMomentType, bool inCentral, float& outMoment, float& outNormMoment )
Parameters
Name | Type | Default | Description | |
---|---|---|---|---|
![]() |
inShape | const Path& | ||
![]() |
inMomentType | ShapeMomentType::Type | ||
![]() |
inCentral | bool | ||
![]() |
outMoment | float& | ||
![]() |
outNormMoment | float& |
Description
The operation computes the mathematical features of a shape called moments. Those are integrals computed as follows:
\[ \begin{aligned} Moment_{2,0}(S) &= \int_{S} p_x^2 \\ Moment_{1,1}(S) &= \int_{S} p_x p_y \\ Moment_{0,2}(S) &= \int_{S} p_y^2 \end{aligned} \]The integration is conducted over shape surface, while \( p_x \) and \( p_y \) denote, accordingly, x and y coordinate of a point.
When inCentral parameter is set, the shape is shifted before computations so that its mass center is at location (0,0).
Note that if the input path is not a valid shape (i.e. it has at least one self-intersection), the computation may lead to results that are not intuitive.
Errors
List of possible exceptions:
Error type | Description |
---|---|
DomainError | Not supported moment type in ShapeMoment. |
DomainError | Open path on input in ShapeMoment. |
See Also
- RegionMoment – Computes selected second-order moment of a region in regular and normalized ( divided by region area ) variant.
- ImageMoment – Computes the selected moment of an image in regular and normalized (divided by sum of pixel values) variant.