Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

In a usual image, a pixel at coordinates (m,n)(m,n) has four horizontal and vertical neighbors whose coordinates are given by

(m+1,n),(m−1,n),(m,n+1),(m,n−1).(m+1,n),\quad (m-1,n),\quad (m,n+1),\quad (m,n-1).

Considering these 4 neighbors, we speak of 4-connectivity (french: 4-connexité).

Besides, there are also four diagonal pixels with coordinates

(m+1,n+1),(m+1,n−1),(m−1,n+1),(m−1,n−1).(m+1,n+1),\quad (m+1,n-1),\quad (m-1,n+1),\quad (m-1,n-1).

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).

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 (m1,n1)(m_1,n_1) and (mN,nN)(m_N,n_N) is a sequence of pixels such that two consecutive pixels are neighbors in the considered connectivity.

Let SS 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 SS.

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.

In this image, there are 2 connected components with 4-connectivity, but only 1 connected component with 8-connectivity.