In
image processing
An image or picture is a visual representation. An image can be two-dimensional, such as a drawing, painting, or photograph, or three-dimensional, such as a carving or sculpture. Images may be displayed through other media, including a pr ...
,
computer vision
Computer vision tasks include methods for image sensor, acquiring, Image processing, processing, Image analysis, analyzing, and understanding digital images, and extraction of high-dimensional data from the real world in order to produce numerical ...
and related fields, an image moment is a certain particular
weighted average
The weighted arithmetic mean is similar to an ordinary arithmetic mean (the most common type of average), except that instead of each of the data points contributing equally to the final average, some data points contribute more than others. The ...
(
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
In mathematics and physics, the centroid, also known as geometric center or center of figure, of a plane figure or solid figure is the arithmetic mean position of all the points in the figure. The same definition extends to any object in n-d ...
, 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
:
for ''p'',''q'' = 0,1,2,...
Adapting this to scalar (
grayscale
In digital photography, computer-generated imagery, and colorimetry, a greyscale (more common in Commonwealth English) or grayscale (more common in American English) image is one in which the value of each pixel is a single sample (signal), s ...
) image with pixel intensities ''I''(''x'',''y''), raw image moments ''M
ij'' are calculated by
:
In some cases, this may be calculated by considering the image as a
probability density function
In probability theory, a probability density function (PDF), density function, or density of an absolutely continuous random variable, is a Function (mathematics), function whose value at any given sample (or point) in the sample space (the s ...
, ''i.e.'', by dividing the above by
:
A uniqueness theorem 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 (''M
pq'') is uniquely determined by ''f''(''x'',''y''). Conversely, (''M
pq'') 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:
* Area (for binary images) or sum of grey level (for greytone images):
* Centroid:
Central moments
Central moments are defined as
:
where
and
are the components of the
centroid
In mathematics and physics, the centroid, also known as geometric center or center of figure, of a plane figure or solid figure is the arithmetic mean position of all the points in the figure. The same definition extends to any object in n-d ...
.
If ''ƒ''(''x'', ''y'') is a digital image, then the previous equation becomes
:
The central moments of order up to 3 are:
It can be shown that:
:
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
In probability theory and statistics, a covariance matrix (also known as auto-covariance matrix, dispersion matrix, variance matrix, or variance–covariance matrix) is a square matrix giving the covariance between each pair of elements of ...
.
The
covariance matrix
In probability theory and statistics, a covariance matrix (also known as auto-covariance matrix, dispersion matrix, variance matrix, or variance–covariance matrix) is a square matrix giving the covariance between each pair of elements of ...
of the image
is now
:
The
eigenvector
In linear algebra, an eigenvector ( ) or characteristic vector is a vector that has its direction unchanged (or reversed) by a given linear transformation. More precisely, an eigenvector \mathbf v of a linear transformation T is scaled by ...
s 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:
:
The above formula holds as long as:
:
The
eigenvalue
In linear algebra, an eigenvector ( ) or characteristic vector is a vector that has its direction unchanged (or reversed) by a given linear transformation. More precisely, an eigenvector \mathbf v of a linear transformation T is scaled by a ...
s of the covariance matrix can easily be shown to be
:
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
Eccentricity or eccentric may refer to:
* Eccentricity (behavior), odd behavior on the part of a person, as opposed to being "normal"
Mathematics, science and technology Mathematics
* Off-Centre (geometry), center, in geometry
* Eccentricity (g ...
is
:
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
Translation is the communication of the meaning of a source-language text by means of an equivalent target-language text. The English language draws a terminological distinction (which does not exist in every language) between ''transl ...
.
Scale invariants
Invariants ''η
i j'' with respect to both
translation
Translation is the communication of the semantics, meaning of a #Source and target languages, source-language text by means of an Dynamic and formal equivalence, equivalent #Source and target languages, target-language text. The English la ...
and
scale can be constructed from central moments by dividing through a properly scaled zero-th central moment:
:
where ''i'' + ''j'' ≥ 2.
Note that translational invariance directly follows by only using central moments.
Rotation invariants
As shown in the work of Hu,
[M. K. Hu, "Visual Pattern Recognition by Moment Invariants", IRE Trans. Info. Theory, vol. IT-8, pp.179–187, 1962]
invariants with respect to
translation
Translation is the communication of the semantics, meaning of a #Source and target languages, source-language text by means of an Dynamic and formal equivalence, equivalent #Source and target languages, target-language text. The English la ...
,
scale, and ''
rotation
Rotation or rotational/rotary motion is the circular movement of an object around a central line, known as an ''axis of rotation''. A plane figure can rotate in either a clockwise or counterclockwise sense around a perpendicular axis intersect ...
'' can be constructed:
These are well-known as ''Hu moment invariants''.
The first one, ''I''
1, is analogous to the
moment of inertia
The moment of inertia, otherwise known as the mass moment of inertia, angular/rotational mass, second moment of mass, or most accurately, rotational inertia, of a rigid body is defined relatively to a rotational axis. It is the ratio between ...
around the image's centroid, where the pixels' intensities are analogous to physical density. The first six, ''I''
1 ... ''I''
6, are reflection symmetric, i.e. they are unchanged if the image is changed to a mirror image. The last one, ''I''
7, 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.
[J. Flusser:]
On the Independence of Rotation Moment Invariants
, Pattern Recognition, vol. 33, pp. 1405–1410, 2000. He showed that the traditional set of Hu moment invariants is neither independent nor complete. ''I''
3 is not very useful as it is dependent on the others (
). In the original Hu's set there is a missing third order independent moment invariant:
:
Like ''I''
7, ''I''
8 is also reflection antisymmetric.
Later, J. Flusser and T. Suk
[J. Flusser and T. Suk, ]
Rotation Moment Invariants for Recognition of Symmetric Objects
, IEEE Trans. Image Proc., vol. 15, pp. 3784–3790, 2006. 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.
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.
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.
External links
University of Edinburgh
University of Edinburgh
Machine Perception and Computer Vision page (Matlab and Python source code)
Hu Momentsintroductory video on YouTube
GistImplementation of this page, jupyter and python.
References
{{DEFAULTSORT:Image Moment
Computer vision
Digital imaging
Image processing
Moment (physics)