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: and , where is a subset of all gray levels in the image.
Specifically, the connectivity can be defined as one of the following:
The second condition states that if and are 8-connected and they are also 4-connected through a third pixel, the tighter 4-connectivity through a third pixel is preferred and therefore and are no longer considered as 8-connected.
Two pixels at at and at not 4, 8, or mix-connected can still be connected through a path composed of a sequence (chain) of pixels
(10) |
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 |