In a usual image, a pixel at coordinates has four horizontal and vertical neighbors whose coordinates are given by
Considering these 4 neighbors, we speak of 4-connectivity (french: 4-connexité).
Besides, there are also four diagonal pixels with coordinates
These pixels, together with the 4-neighbors, are the 8 neighbors in 8-connectivity (french: 8-connexité).
The neighbors of the green pixel are represented in red, with 4-connectivity (left) and 8-connectivity (right).
A path between two pixels with coordinates and is a sequence of pixels such that two consecutive pixels are neighbors in the considered connectivity.
Let represent a set of pixels in an image. Two pixels are said to be connected if there exists a path between them consisting entirely of pixels in .
The set of pixels that are connected is called a connected component (french: composante connexe).
In this image, there are 2 connected components with 4-connectivity, but only 1 connected component with 8-connectivity.