Connectivity

In a binary (black and white) image, two neighboring pixels (as defined above) are connected if their values are the same, i.e., both equal to 0 (black) or 255 (white).

In a gray level image, two neighboring pixels are connected if their values are close to each other, i.e., they both belong to the same subset of similar gray levels: $p \in V$ and $q \in V$, where $V$ is a subset of all gray levels in the image.

Specifically, the connectivity can be defined as one of the following:

Two pixels at $p$ at $(x,y)$ and $q$ at $(u,v)$ not 4, 8, or mix-connected can still be connected through a path composed of a sequence (chain) of pixels

$\displaystyle (x_0,y_0)=(x,y), (x_1,y_1), \cdots, (x_{n-1},y_{n-1}),(x_n,y_n)=(u,v)$ (10)

with all neighboring pixels $(x_i,y_i)$ and $(x_{i+1},y_{i+1})$ 4, 8, or mix-connected.

Example:

The upper-right pixel and the lower-left pixel are 8 and mix-connected, but they are not 4-connected:

0 0 1
0 1 0
1 0 0

The upper-right pixel and the lower-left pixel are 4, 8 and mix-connected:

0 1 1
0 1 0
1 1 0