Neighborhood and connectivity#
In a usual image, a pixel at coordinates \((m,n)\) 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é).
A path between two pixels with coordinates \((m_1,n_1)\) and \((m_N,n_N)\) is a sequence of pixels such that two consecutive pixels are neighbors in the considered connectivity.
Let \(S\) 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 \(S\).
The set of pixels that are connected is called a connected component (french: composante connexe).