Suppose we have isolated a character as a set
of pixels. Let us not draw a box around it, let
us first find its centre of gravity. If A is the
set of pixels in the figure, with integer
co-ordinates x and y for each pixel p in A, then
let fA be the characteristic function of
A, i.e.
iff
there is a pixel of A at location
,and otherwise fA takes the value 0. Then
we can write the count of the number of pixels
in A as



These numbers give us information about the set A. We can rewrite things slightly by defining the (p,q)th moment of fA (or of A) by
![\begin{displaymath}
% latex2html id marker 1385
\mu_{[p,q]} = \sum x^p y^q f_A \left(\begin{array}
{c}
x \\ y \end{array} \right) \end{displaymath}](img87.gif)
and the normalised (p,q)th moment of fA (or of A) by
![\begin{displaymath}
% latex2html id marker 1386
\mu_{[p,q]} = \frac{\sum x^p y^q...
...{\sum
f_A\left(\begin{array}
{c} x \\ y \end{array}
\right)} \end{displaymath}](img88.gif)
Then the moment
is the pixel count
of A,the mean x-value of A is the moment
divided by the pixel count,or alternatively
the normalised (1,0) moment, and
the mean of the y-values of the pixels of A is
the moment
divided by the pixel
count.
It is easy also to compute higher order moments. These give extra information about the distribution of the pixels in A.
The central moments are computed in the
same way, except that the origin is shifted to
the centroid
for all the
pixels of A.
All the moments
where p+q takes
the value v, are called moments of order
v. A little thought and recollection of statistics
will no doubt remind you that the
second order central moments, moments of
order 2, i.e. the (2,0), (0,2) and (1,1)
central moments, are the elements of the covariance
matrix of the set of points, except
for a scaling dependent on the number of points.
The use of central moments is clearly a way of
taking
out any information about where the set A actually
is. Since this is a good idea, we
have a distinct preference for the central moments.
The three central moments of order 2 would
allow us to distinguish between a disk and a thin
bar rather easily. In the exercises we ask you
to
compute the central moments for some simple shapes.
Example We give an example for the easy case of sets A and B defined by

and

Then A has 33 pixels and B has 35; B is squarer than A. Both have the origin as the centroid so as to save us some arithmetic.
A has three rows, so to calculate
which is the sum of the squares of all the
x-values of the pixels in A we get
![]()
i.e.
. Similarly,
, and
![]()
![]()
So the three second order moments, in the right
order, give the vector
, while
the same calculation for B gives
.
So if we were to represent these objects as points
in
, it would be easy to tell them
apart. Unfortunately, it takes rather higher dimensions,
i.e. higher order moments, to discriminate
between characters, but it can be done by the
same methods.