Image moment explained

In image processing, computer vision and related fields, an image moment is a certain particular weighted average (moment) of the image pixels' intensities, or a function of such moments, usually chosen to have some attractive property or interpretation.

Image moments 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.

Raw moments

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

Mpq

infty
=\int\limits
-infty
infty
\int\limits
-infty

xpyqf(x,y)dxdy

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

Mij=\sumx\sumyxiyjI(x,y)

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

\sumx\sumyI(x,y)

A uniqueness theorem (Hu [1962]) 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).[1] Conversely, (Mpq) uniquely determines f(x,y). In practice, the image is summarized with functions of a few lower order moments.

Examples

Simple image properties derived via raw moments include:

M00

\{\bar{x},\bar{y}\}=\left\{

M10
M00

,

M01
M00

\right\}

Central moments

Central moments are defined as

\mupq=

infty
\int\limits
-infty
infty
\int\limits
-infty

(x-\bar{x})p(y-\bar{y})qf(x,y)dxdy

where

\bar{x}=M10
M00
and
\bar{y}=M01
M00
are the components of the centroid.

If ƒ(xy) is a digital image, then the previous equation becomes

\mupq=\sumx\sumy(x-\bar{x})p(y-\bar{y})qf(x,y)

The central moments of order up to 3 are:

\mu00=M00,

\mu01=0,

\mu10=0,

\mu11=M11-\bar{x}M01=M11-\bar{y}M10,

\mu20=M20-\bar{x}M10,

\mu02=M02-\bar{y}M01,

\mu21=M21-2\bar{x}M11-\bar{y}M20+2\bar{x}2M01,

\mu12=M12-2\bar{y}M11-\bar{x}M02+2\bar{y}2M10,

\mu30=M30-3\bar{x}M20+2\bar{x}2M10,

\mu03=M03-3\bar{y}M02+2\bar{y}2M01.

It can be shown that:

\mupq=

p
\sum
m
q
\sum
n

{p\choosem}{q\choosen}(-\bar{x})(p-m)(-\bar{y})(q-n)Mmn

Central moments are translational invariant.

Examples

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

\mu'20=\mu20/\mu00=M20/M00-\bar{x}2

\mu'02=\mu02/\mu00=M02/M00-\bar{y}2

\mu'11=\mu11/\mu00=M11/M00-\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 towards the axis closest to this eigenvector. It can be shown that this angle Θ is given by the following formula:

\Theta=

1
2

\arctan\left(

2\mu'11
\mu'20-\mu'02

\right)

The above formula holds as long as:

\mu'20-\mu'02\ne0

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

λi=

\mu'20+\mu'02
2

\pm

\sqrt{4{\mu'
11

2+({\mu'}20-{\mu'}02)2}}{2},

and are proportional to the squared length of the eigenvector axes. The relative difference in magnitude of the eigenvalues are thus an indication of the eccentricity of the image, or how elongated it is. The eccentricity is

\sqrt{1-

λ2
λ1
}.

Moment invariants

Moments are well-known for their application in image analysis, since they can be used to derive invariants with respect to specific transformation classes.

The term invariant moments is often abused in this context. However, while moment invariants are invariants that are formed from moments, the only moments that are invariants themselves are the central moments.

Note that the invariants detailed below are exactly invariant only in the continuous domain. In a discrete domain, neither scaling nor rotation are well defined: a discrete image transformed in such a way is generally an approximation, and the transformation is not reversible. These invariants therefore are only approximately invariant when describing a shape in a discrete image.

Translation invariants

The central moments μi j of any order are, by construction, invariant with respect to translations.

Scale invariants

Invariants ηi j with respect to both translation and scale can be constructed from central moments by dividing through a properly scaled zero-th central moment:

ηij=

\muij
\left(1+
i+j
2
\right)
\mu
00

where i + j ≥ 2.Note that translational invariance directly follows by only using central moments.

Rotation invariants

As shown in the work of Hu,[2] [3] invariants with respect to translation, scale, and rotation can be constructed:

I1=η20+η02

I2=(η20-η02)2+

2
11

I3=(η30-12)2+(21-η03)2

I4=(η30+η12)2+(η21+η03)2

I5=(η30-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]+11(η30+η12)(η21+η03)

I7=(3η21-η03)(η30+η12)[(η30+η12)2-3(η21+η03)2]-(η30-12)(η21+η03)[3(η30+η12)2-(η21+η03)2].

These are well-known as Hu moment invariants.

The first one, I1, is analogous to the moment of inertia around the image's centroid, where the pixels' intensities are analogous to physical density. The first six, I1 ... I6, are reflection symmetric, i.e. they are unchanged if the image is changed to a mirror image. The last one, I7, is reflection antisymmetric (changes sign under reflection), which enables it to distinguish mirror images of otherwise identical images.

A general theory on deriving complete and independent sets of rotation moment invariants was proposed by J. Flusser.[4] He showed that the traditional set of Hu moment invariants is neither independent nor complete. I3 is not very useful as it is dependent on the others (

I3=

2
(I
5

+

2)
I
7

/

3
I
4
). In the original Hu's set there is a missing third order independent moment invariant:

I8=η11[(η30+η12)2-(η03+η21)2]-(η2002)(η3012)(η0321)

Like I7, I8 is also reflection antisymmetric.

Later, J. Flusser and T. Suk[5] specialized the theory for N-rotationally symmetric shapes case.

Applications

Zhang et al. applied Hu moment invariants to solve the Pathological Brain Detection (PBD) problem.[6] Doerr and Florence used information of the object orientation related to the second order central moments to effectively extract translation- and rotation-invariant object cross-sections from micro-X-ray tomography image data.[7]

D. A. Hoeltzel and Wei-Hua Chieng used Hu moment invariant to perform on a dimensionally-parameterized four bar mechanism which yielded 15 distinct coupler curve groups (patterns) from a total of 356 generated coupler curves.[8]

External links

Notes and References

  1. Book: Gonzalez . Rafael C. . Woods . Richard E. . 2001 . Digital Image Processing . Prentice Hall . 0-201-18075-8 . 672.
  2. M. K. Hu, "Visual Pattern Recognition by Moment Invariants", IRE Trans. Info. Theory, vol. IT-8, pp.179 - 187, 1962
  3. http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=cvmatchshapes#humoments Hu Moments' OpenCV method
  4. J. Flusser: "On the Independence of Rotation Moment Invariants", Pattern Recognition, vol. 33, pp. 1405 - 1410, 2000.
  5. J. Flusser and T. Suk, "Rotation Moment Invariants for Recognition of Symmetric Objects", IEEE Trans. Image Proc., vol. 15, pp. 3784 - 3790, 2006.
  6. Zhang. Y.. Pathological Brain Detection based on wavelet entropy and Hu moment invariants. Bio-Medical Materials and Engineering. 2015. 26. 1283–1290. 10.3233/BME-151426. 26405888. free.
  7. Doerr . Frederik . Florence . Alastair . A micro-XRT image analysis and machine learning methodology for the characterisation of multi-particulate capsule formulations . International Journal of Pharmaceutics: X . 2020 . 2 . 100041 . 10.1016/j.ijpx.2020.100041 . 32025658 . 6997304 . free .
  8. Hoeltzel. D.A.. Chieng. Wei-Hua. Pattern Matching Synthesis as an Automated Approach to Mechanism Design . Transactions of the ASME, Journal of Mechanical Design . 1990. 112 . 190-199. 10.1115/1.2912592 . free .