Neighbors, Connectivity, Distance, Measures between pixels

Neighbors, Connectivity, Distance, Measures between pixels

Published by: Neha Khadka

Published date: 23 Jul 2024

Neighbors,  Connectivity, Distance, Measures between pixels

 Neighbors,Connectivity, Distance, Measures between pixels

Neighbors

The pixels that are next to a pixel in an image are called its neighbors. In order to define pixel connection and perform different image processing operations, the notion of neighbors is necessary.

Types of Neighbors

4-Neighbors (4-connected):

  • Consists of the pixels that share an edge with the given pixel.
  • For a pixel at position (i,j)(i, j)(i,j), the 4-neighbors are (i−1,j)(i-1, j)(i−1,j), (i+1,j)(i+1, j)(i+1,j), (i,j−1)(i, j-1)(i,j−1), and (i,j+1)(i, j+1)(i,j+1).

 

8-Neighbors (8-connected):

  • Includes the 4-neighbors and the diagonal neighbors.
  • For a pixel at position (i,j)(i, j)(i,j), the 8-neighbors are (i−1,j−1)(i-1, j-1)(i−1,j−1), (i−1,j)(i-1, j)(i−1,j), (i−1,j+1)(i-1, j+1)(i−1,j+1), (i,j−1)(i, j-1)(i,j−1), (i,j+1)(i, j+1)(i,j+1), (i+1,j−1)(i+1, j-1)(i+1,j−1), (i+1,j)(i+1, j)(i+1,j), and (i+1,j+1)(i+1, j+1)(i+1,j+1)

6-Neighbors (in 3D images):

  • For a voxel at position (i,j,k)(i, j, k)(i,j,k) in a 3D image, the 6-neighbors are those voxels that share a face with the given voxel.

Connectivity

Based on their neighbors, pixels in an image are defined by their connectivity. It is essential for locating and examining certain areas of a picture.

Types of Connectivity:

4-Connectivity

  • Pixels are connected if they are 4-neighbors.
  • Used in scenarios where diagonal connections might introduce ambiguity

8- Connectivity

  • Pixels are connected if they are 8-neighbors.
  • Suitable for situations where diagonal connections are acceptable.

6-Connectivity (in 3D images)

  • Voxels are connected if they are 6-neighbors

Distance Measures

The spatial link between pixels is computed using distance measures between them. Typical distance measurements consist of

  • Euclidean Distance:

    1. The straight-line distance between two pixels (x1,y1)(x_1, y_1)(x1​,y1​) and (x2,y2)(x_2, y_2)(x2​,y2​).
    2. Formula: d=(x2−x1)2+(y2−y1)2d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2}d=(x2​−x1​)2+(y2​−y1​)2​
  • Manhattan Distance (City Block Distance):

    1. The distance between two pixels measured along axes at right angles.
    2. Formula: d=∣x2−x1∣+∣y2−y1∣d = |x_2 - x_1| + |y_2 - y_1|d=∣x2​−x1​∣+∣y2​−y1​∣
  • Chebyshev Distance:

  1. The maximum of the absolute differences between the coordinates of two pixels.
  2. Formula: d=max⁡(∣x2−x1∣,∣y2−y1∣)d = \max(|x_2 - x_1|, |y_2 - y_1|)d=max(∣x2​−x1​∣,∣y2​−y1​∣)

In summary, understanding neighbors, connectivity, and distance measures between pixels is fundamental for many image processing techniques and applications.