Skip to content

moments_region_2ndmoments_region_2ndMomentsRegion2ndMomentsRegion2ndmoments_region_2ndmoments_region_2ndπŸ”—

Short descriptionπŸ”—

moments_region_2ndmoments_region_2ndMomentsRegion2ndMomentsRegion2ndmoments_region_2ndmoments_region_2nd β€” Calculate the geometric moments of regions.

SignatureπŸ”—

moments_region_2nd( region Regions, out real M11, out real M20, out real M02, out real Ia, out real Ib )moments_region_2nd( Regions : : : M11, M20, M02, Ia, Ib )void MomentsRegion2nd( const HObject& Regions, HTuple* M11, HTuple* M20, HTuple* M02, HTuple* Ia, HTuple* Ib )static void HOperatorSet.MomentsRegion2nd( HObject regions, out HTuple m11, out HTuple m20, out HTuple m02, out HTuple ia, out HTuple ib )def moments_region_2nd( regions: HObject ) -> Tuple[Sequence[float], Sequence[float], Sequence[float], Sequence[float], Sequence[float]]

def moments_region_2nd_s( regions: HObject ) -> Tuple[float, float, float, float, float]Herror moments_region_2nd( const Hobject Regions, double* M11, double* M20, double* M02, double* Ia, double* Ib )

Herror T_moments_region_2nd( const Hobject Regions, Htuple* M11, Htuple* M20, Htuple* M02, Htuple* Ia, Htuple* Ib )

HTuple HRegion::MomentsRegion2nd( HTuple* M20, HTuple* M02, HTuple* Ia, HTuple* Ib ) const

double HRegion::MomentsRegion2nd( double* M20, double* M02, double* Ia, double* Ib ) const

HTuple HRegion.MomentsRegion2nd( out HTuple m20, out HTuple m02, out HTuple ia, out HTuple ib )

double HRegion.MomentsRegion2nd( out double m20, out double m02, out double ia, out double ib )

DescriptionπŸ”—

moments_region_2ndMomentsRegion2nd calculates the geometric moments M11m11m11, M20m20m20 and M02m02m02 of the input regions in Regionsregionsregions. Furthermore the major and minor axis of the input regions are calculated and returned in Iaiaia and Ibibib.

The covariance matrix is given by:

\[\begin{eqnarray*} \left[ \begin{array}{rr} M20 & M11\\ M11 & M02 \end{array} \right] \end{eqnarray*}\]

The row-dependent moment of 2nd order is returned in M20m20m20 and the column-dependent moment of 2nd order is returned in M02m02m02. The moment M11m11m11 represents the covariance between the row and column coordinates of the region points.

  • Calculation: \(r_{0}\) and \(c_{0}\) are the coordinates of the center of gravity of a region R. Then the moments \(M_{ij}\) are defined by:

    \[\begin{eqnarray*} M_{ij} = \sum_{(r,c) \in R} {(r_{0} - r)^i (c_{0} - c)^j} \end{eqnarray*}\]

    wherein \(r\) and \(c\) run over all pixels of the region R.

    Furthermore the length of the major and minor axes are defined by:

    \[\begin{eqnarray*} Ia = h + \sqrt{h^2 - M20 \ast M02 + M11^2} \end{eqnarray*}\]
    \[\begin{eqnarray*} Ib = h - \sqrt{h^2 - M20 \ast M02 + M11^2} \end{eqnarray*}\]

    wherein \(h\) is defined by:

    \[\begin{eqnarray*} h = \frac{M20 + M02}{2} \end{eqnarray*}\]

The equation for the major and minor axes can be derived from the definition of the moments by diagonalizing the covariance matrix and reforming the resulting formula.

If more than one region is passed, the results are returned in tuples. The index of a tuple element corresponds to the index of the respective input region.

If an empty region is passed, 0.0 is returned for all parameters, if no other behavior was set (see set_systemSetSystem).

Execution informationπŸ”—

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on tuple level.

ParametersπŸ”—

Regionsregionsregions (input_object) region(-array) β†’ objectobjectHObjectHRegionHObjectHobject

Input regions.

M11m11m11 (output_control) real(-array) β†’ (real)(real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Product of inertia of the axes through the center parallel to the coordinate axes.

M20m20m20 (output_control) real(-array) β†’ (real)(real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Moment of 2nd order (row-dependent).

M02m02m02 (output_control) real(-array) β†’ (real)(real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Moment of 2nd order (column-dependent).

Iaiaia (output_control) real(-array) β†’ (real)(real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Length of the major axis of the input region.

Ibibib (output_control) real(-array) β†’ (real)(real)HTuple (double)HTuple (double)Sequence[float]Htuple (double)

Length of the minor axis of the input region.

ComplexityπŸ”—

If \(F\) is the area of the region the mean runtime complexity is \(O(\sqrt{F})\).

ResultπŸ”—

The operator moments_region_2ndMomentsRegion2nd returns the value 2 (H_MSG_TRUE) if the input is not empty. The behavior in case of empty input (no input regions available) is set via the operator set_system('no_object_result',<Result>). The behavior in case of empty region (region is the empty set) is set via set_system('empty_region_result',<Result>). If necessary an exception is raised.

Combinations with other operatorsπŸ”—

Combinations

Possible predecessors

thresholdThreshold, regiongrowingRegiongrowing, connectionConnection

Alternatives

moments_region_2nd_invarMomentsRegion2ndInvar

See also

elliptic_axisEllipticAxis

ReferencesπŸ”—

R. Haralick, L. Shapiro β€œComputer and Robot Vision” Addison-Wesley, 1992, pp. 73-75

ModuleπŸ”—

Foundation