OpenCV453
公開メンバ関数 | 全メンバ一覧
cv::Moments クラス

struct returned by cv::moments [詳解]

#include <types.hpp>

公開メンバ関数

 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
 

公開変数類

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

詳解

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 http://en.wikipedia.org/wiki/Green_theorem). 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.

このクラス詳解は次のファイルから抽出されました: