OpenCV  4.10.0-dev
Open Source Computer Vision
No Matches
Public Member Functions | List of all members

struct returned by cv::moments More...

#include <opencv2/core/types.hpp>

Collaboration diagram for cv::Moments:

Public Member Functions

 Moments ()
 the default constructor
 Moments (double m00, double m10, double m01, double m20, double m11, double m02, double m30, double m21, double m12, double m03)
 the full constructor

Public Attributes

spatial moments
double m00
double m10
double m01
double m20
double m11
double m02
double m30
double m21
double m12
double m03
central moments
double mu20
double mu11
double mu02
double mu30
double mu21
double mu12
double mu03
central normalized moments
double nu20
double nu11
double nu02
double nu30
double nu21
double nu12
double nu03

Detailed Description

struct returned by cv::moments

The spatial moments \(\texttt{Moments::m}_{ji}\) are computed as:

\[\texttt{m} _{ji}= \sum _{x,y} \left ( \texttt{array} (x,y) \cdot x^j \cdot y^i \right )\]

The central moments \(\texttt{Moments::mu}_{ji}\) are computed as:

\[\texttt{mu} _{ji}= \sum _{x,y} \left ( \texttt{array} (x,y) \cdot (x - \bar{x} )^j \cdot (y - \bar{y} )^i \right )\]

where \((\bar{x}, \bar{y})\) is the mass center:

\[\bar{x} = \frac{\texttt{m}_{10}}{\texttt{m}_{00}} , \; \bar{y} = \frac{\texttt{m}_{01}}{\texttt{m}_{00}}\]

The normalized central moments \(\texttt{Moments::nu}_{ij}\) are computed as:

\[\texttt{nu} _{ji}= \frac{\texttt{mu}_{ji}}{\texttt{m}_{00}^{(i+j)/2+1}} .\]

\(\texttt{mu}_{00}=\texttt{m}_{00}\), \(\texttt{nu}_{00}=1\) \(\texttt{nu}_{10}=\texttt{mu}_{10}=\texttt{mu}_{01}=\texttt{mu}_{10}=0\) , hence the values are not stored.

The moments of a contour are defined in the same way but computed using the Green's formula (see So, due to a limited raster resolution, the moments computed for a contour are slightly different from the moments computed for the same rasterized contour.

Since the contour moments are computed using Green formula, you may get seemingly odd results for contours with self-intersections, e.g. a zero area (m00) for butterfly-shaped contours.

Constructor & Destructor Documentation

◆ Moments() [1/2]

cv::Moments::Moments ( )

the default constructor

◆ Moments() [2/2]

cv::Moments::Moments ( double  m00,
double  m10,
double  m01,
double  m20,
double  m11,
double  m02,
double  m30,
double  m21,
double  m12,
double  m03 

the full constructor

Member Data Documentation

◆ m00

double cv::Moments::m00

◆ m01

double cv::Moments::m01

◆ m02

double cv::Moments::m02

◆ m03

double cv::Moments::m03

◆ m10

double cv::Moments::m10

◆ m11

double cv::Moments::m11

◆ m12

double cv::Moments::m12

◆ m20

double cv::Moments::m20

◆ m21

double cv::Moments::m21

◆ m30

double cv::Moments::m30

◆ mu02

double cv::Moments::mu02

◆ mu03

double cv::Moments::mu03

◆ mu11

double cv::Moments::mu11

◆ mu12

double cv::Moments::mu12

◆ mu20

double cv::Moments::mu20

◆ mu21

double cv::Moments::mu21

◆ mu30

double cv::Moments::mu30

◆ nu02

double cv::Moments::nu02

◆ nu03

double cv::Moments::nu03

◆ nu11

double cv::Moments::nu11

◆ nu12

double cv::Moments::nu12

◆ nu20

double cv::Moments::nu20

◆ nu21

double cv::Moments::nu21

◆ nu30

double cv::Moments::nu30

The documentation for this class was generated from the following file: