In a discrete binary image objects are represented in terms of discrete pixels. Calculations of areas, centroids, moments and so on are straightforward -- we use summations instead of the integral equations we used in the continuous case.
Suppose there are several objects in the image. We must separate them before calculating the various moments. We need to establish what makes an object connected or separate from other objects.
Two points in a binary image are connected if a path can be found between them along which the characteristic function remains constant. To decide this we need to know what the topology is, that is, under what conditions do we say that two pixels are neighbours.
There are various possibilities for deciding upon the appropriate topology.
The Jordan Curve Theorem says A simple closed curve separates the plane into two simply connected components (namely, the inside and the outside).
Consider the following simple example:
If we use 8 connectedness we have an object that creates a closed curve -- but the background element in the middle is also connected to the outside!
The ideal solution is to use a hexagonal grid, which gives us 6 connectedness. Unfortunately, images don't come in this form.
Another solution is to consider object pixels as 8 connected and background points as 4 connected (or vice versa). However, this asymmetry may be considered undesirable. Alternatively one can skew the rectangular grid.