Image moments

From Wikipedia, the free encyclopedia

Used in image processing, computer vision and related fields, image moments are certain particular weighted averages (moments) of the image pixels' intensities, or functions of those moments, usually chosen to have some attractive property or interpretation.

They are useful to describe objects after segmentation. Simple properties of the image which are found via image moments include area (or total intensity), its centroid, and information about its orientation.

Contents

[edit] Raw moments

For a 2-D continuous function f(x,y) the moment (sometimes called "raw moment") of order (p + q) is defined as

M_{pq}=\int\limits_{-\infty}^{\infty} \int\limits_{-\infty}^{\infty} x^py^qf(x,y) \,dx\, dy

for p,q = 0,1,2,... Adapting this to scalar (greytone) image with pixel intensities I(x,y), raw image moments Mij are calculated by

M_{ij} = \sum_x \sum_y x^i y^j I(x,y)\,\!

In some cases, this may be calculated by considering the image as a probability density function, e.g., by dividing the above by

\sum_x \sum_y I(x,y) \,\!

A uniqueness theorem (Papoulis [1991]) states that if f(x,y) is piecewise continuous and has nonzero values only in a finite part of the xy plane, moments of all orders exist, and the moment sequence (Mpq) is uniquely determined by f(x,y). Conversely, (Mpq) uniquely determines f(x,y). In practice, the image is summarized with functions of a few lower order moments.


[edit] Examples

Simple image properties derived via raw moments include:

  • Area (for binary images) or sum of grey level (for greytone images): M_{00}\,\!
  • Centroid: \{\bar{x},\ \bar{y} \} = \{M_{10}/M_{00},\ M_{01}/M_{00}\}

[edit] Central moments

Central moments are defined as:

\mu_{pq} = \int\limits_{-\infty}^{\infty} \int\limits_{-\infty}^{\infty} (x - \bar{x})^p(y - \bar{y})^q f(x,y) dx dy

where \bar{x}=\frac{M_{10}}{M_{00}} and \bar{y}=\frac{M_{01}}{M_{00}} are the components of the centroid.

If f(x,y) is a digital image, then the previous equation becomes

\mu_{pq} = \sum_{x} \sum_{y} (x - \bar{x})^p(y - \bar{y})^q f(x,y)

The central moments of order up to 3 are:

\mu_{00} = M_{00},\,\!
\mu_{01} = 0,\,\!
\mu_{10} = 0,\,\!
\mu_{11} = M_{11} - \bar{x} M_{01} = M_{11} - \bar{y} M_{10},
\mu_{20} = M_{20} - \bar{x} M_{10},
\mu_{02} = M_{02} - \bar{y} M_{01},
\mu_{21} = M_{21} - 2 \bar{x} M_{11} - \bar{y} M_{20} + 2 \bar{x}^2 M_{01},
\mu_{12} = M_{12} - 2 \bar{y} M_{11} - \bar{x} M_{02} + 2 \bar{y}^2 M_{10},
\mu_{30} = M_{30} - 3 \bar{x} M_{20} + 2 \bar{x}^2 M_{10},
\mu_{03} = M_{03} - 3 \bar{y} M_{02} + 2 \bar{y}^2 M_{01}.

It can be shown that:

\mu_{pq} = \sum_{m}^p \sum_{n}^q {p\choose m} {q\choose n}(-\bar{x})^{(p-m)}(-\bar{y})^{(q-n)}  M_{mn}

Central moments are translational invariant.

[edit] Examples

Information about image orientation can be derived by first using the second order central moments to construct a covariance matrix.

\mu'_{20} = \mu_{20} / \mu_{00} = M_{20}/M_{00} - \bar{x}^2
\mu'_{02} = \mu_{02} / \mu_{00} = M_{02}/M_{00} - \bar{y}^2
\mu'_{11} = \mu_{11} / \mu_{00} = M_{11}/M_{00} - \bar{x}\bar{y}

The covariance matrix of the image I(x,y) is now

\operatorname{cov}[I(x,y)] = \begin{bmatrix} \mu'_{20}  & \mu'_{11} \\ \mu'_{11} & \mu'_{02} \end{bmatrix}.

The eigenvectors of this matrix correspond to the major and minor axes of the image intensity, so the orientation can thus be extracted from the angle of the eigenvector associated with the largest eigenvalue. It can be shown that this angle Θ is given by the following formula:

\Theta = \frac{1}{2} \tan^{-1} \left( \frac{2\mu'_{11}}{\mu'_{20} - \mu'_{02}} \right)

The eigenvalues of the covariance matrix can easily be shown to be

\lambda_i = \frac{\mu'_{20} + \mu'_{02}}{2}  \pm \frac{\sqrt{4{\mu'}_{11}^2 + ({\mu'}_{20}-{\mu'}_{02})^2  }}{2},

which are proportional to the squared length of the eigenvector axes. Thus the relative difference in magnitude of the eigenvalues are an indication of how elongated the image is.

[edit] Scale invariant moments

Moments where i+j \geq 2 can also be invariant to both translation and changes in scale by dividing central moments by the properly scaled (00)th moment, using the following formula.

\eta_{ij} = \frac{\mu_{ij}}                          {\mu_{00}^{\left(1 + \frac{i+j}{2}\right)}}\,\!

[edit] Rotation invariant moments

It is possible to calculate moments which are invariant under translation, changes in scale, and also rotation. Most frequently used are the Hu set of invariant moments:

I1 = η20 + η02
I2 = (η20 − η02)2 + (2η11)2
I3 = (η30 − 3η12)2 + (3η21 − η03)2
I4 = (η30 + η12)2 + (η21 + η03)2
I5 = (η30 − 3η12)(η30 + η12)[(η30 + η12)2 − 3(η21 + η03)2] + (3η21 − η03)(η21 + η03)[3(η30 + η12)2 − (η21 + η03)2]
I6 = (η20 − η02)[(η30 + η12)2 − (η21 + η03)2 + 4η1130 + η12)(η21 + η03)]
I7 = (3η21 − η03)(η30 + η12)[(η30 + η12)2 − 3(η21 + η03)2] − (η30 − 3η12)(η21 + η03)[3(η30 + η12)2 − (η21 + η03)2].


The first one, I1, is roughly proportional to the moment of inertia around the image's centroid, if the pixels' intensities were interpreted as physical density. The last one, I7, is skew invariant, which enables it to distinguish mirror images of otherwise identical images.

[edit] External links

[edit] References

  • M. K. Hu, "Visual Pattern Recognition by Moment Invariants", IRE Trans. Info. Theory, vol. IT-8, pp.179-187, 1962.