Last updated on September 11, 1995 at 6:30 AM
Suppose that we consider as neighbors only the four pixels that share an edge (not a corner) with the pixel in question: (x+1,y), (x-1,y), (x,y+1), and (x,y-1). These are called "4-connected" neighbors for obvious reasons. Now consider the following:

The black pixels on the diagonal in Fig. 3.1 are not 4-connected. However, they serve as an effective insulator between the two sets of white pixels, which are also not 4-connected across the black pixels. This creates undesirable topological anomalies.
An alternative is to consider a pixel as connected not just pixels on the same row or column, but also the diagonal pixels. The four 4-connected pixels plus the diagonal pixels are called "8-connected" neighbors, again for obvious reasons.
But again, a topological anomaly occurs:

The black pixels on the diagonal are connected, but then again so are the white background pixels. Some pixels are connected across the links between other connected pixels!
The usual solution is to use 4-connectivity for the foreground with
8-connectivity for the background or to use 8-connectivity for the
foreground with 4-connectivity for the background, as illustrated
in Fig 3.3.

Another form of connectivity is "mixed-connectivity", a form of 8-connectivity that considers diagonally-adjacent pixels to be connected if no shared 4-connected neighbor exists. (In other words, use 4-connectivity where possible and 8-connectivity where not.)
It is pretty easy to see that connectivity is also symmetric: a pixel and its neighbor are mutually connected.
4-connectivity and 8-connectivity are also transitive: if pixel A is connected to pixel B, and pixel B is connected to pixel C, then there exists a connected path between pixels A and C. (Mixed-connectivity is not transitive--can you explain why?)
A relation (such as connectivity) is called an equivalence relation if it is reflexive, symmetric, and transitive.
If one finds all equivalence classes of connected pixels in a binary image, this is called connected component labeling. The result of connected component labeling is another image in which everything in one connected region is labeled "1" (for example), everything in another connected region is labeled "2", etc.
Can you think of ways to do connected component labeling?
Here is one algorithm:
You will implement this algorithm as part of your first programming assignment.
and
.
One obvious measure is the Euclidean (as the crow flies) distance
.
Another measure is the 4-connected distance
(sometimes called
city-block distance
.
A third measure is the 8-connected distance
(sometimes called
chessboard distance
.
For those familiar with vector norms, these correspond to the
,
, and
norms.
© Bryan S. Morse, 1995