Back to Adaptive Vision Library website

You are here: Start » Function Reference » Region » Region Features » RegionMoment


Header: AVL.h
Namespace: avl
Module: FoundationBasic

Computes selected second-order moment of a region in regular and normalized ( divided by region area ) variant.


void avl::RegionMoment
	const avl::Region& inRegion,
	avl::RegionMomentType::Type inMomentType,
	bool inCentral,
	float& outMoment,
	float& outNormMoment


Name Type Default Description
inRegion const Region& Input region
inMomentType RegionMomentType::Type
inCentral bool
outMoment float&
outNormMoment float&


The operation computes the mathematical features of a shape called moments. Those are sums computed as follows:

\[ \begin{aligned} Moment_{2,0}(R) &= \sum_{p \in R} p_x^2 \\ Moment_{1,1}(R) &= \sum_{p \in R} p_x p_y \\ Moment_{0,2}(R) &= \sum_{p \in R} p_y^2 \end{aligned} \]

The summing is conducted over region pixels, while \( p_x \) and \( p_y \) denote, accordingly, x and y coordinate of a pixel.

When inCentral parameter is set, the region is shifted before computations, so that its mass center is at location (0,0).


  • If the input region is not guaranteed to be non-empty, precede this filter with SkipEmptyRegion.


List of possible exceptions:

Error type Description
DomainError Empty region on input in RegionMoment.
DomainError Not supported moment type in RegionMoment.

See Also

  • PolygonMoment – Computes the selected second-order moment of a polygon in regular and normalized ( divided by polygon area ) variant.
  • ImageMoment – Computes the selected moment of an image in regular and normalized (divided by sum of pixel values) variant.