Pixel Connectivity

Work in progress. This note is still being written and incomplete.

Once an image is digitized, only a matrix of values remains. Pixel geometry is often lost.

  • Pixels may not be square, and capture and reproduction devices may not share the same pixel geometry
  • A mismatch between input and output pixel geometry causes geometric distortion
  • Final geometry depends on how pixels are arranged in the output device
  • Size, resolution and aspect ratio all need to be considered

Connectivity

Connectivity establishes the boundaries of objects, components and regions in an image.

2 pixels are connected iff they’re adjacent to each other and satisfy some similarity in grey level, given a similarity set VV.

  • 4-connectivity
    Adjacency restricted to the 4 pixels sharing an edge.
  • 8-connectivity
    Adjacency extended to the 4 pixels sharing only a corner.

Neighborhoods and Paths

  • A path between 2 pixels is a sequence of adjacent pixels connecting them
  • A local neighborhood is a sample window selecting the pixels around a given pixel pp, used when an operation depends on a group of adjacent pixels

Distance Measures

For 2 pixels p(x,y)p(x,y) and q(s,t)q(s,t):

Euclidean Distance

Straight-line distance between pp and qq.

De(p,q)=(xs)2+(yt)2D_e(p,q) = \sqrt{(x-s)^2 + (y-t)^2}

City-Block Distance

Aka. Manhattan distance. Straight-line distance along the grid.

D4(p,q)=xs+ytD_4(p,q) = |x-s| + |y-t|

Chessboard Distance

D8(p,q)=max(xs,yt)D_8(p,q) = \max(|x-s|, |y-t|)

Connectivity Correspondence

Each metric equals the length of the shortest path allowed by its matching connectivity.

  • D4D_4 matches 4-connectivity
    Pixels within D41D_4 \le 1 of pp are pp and its 4 edge-sharing neighbors. A minimal D4D_4 path moves only horizontally and vertically.
  • D8D_8 matches 8-connectivity
    Pixels within D81D_8 \le 1 of pp are pp and all 8 surrounding pixels. A minimal D8D_8 path may also move diagonally.

DeD_e has no such grid correspondence, since its unit disc is not aligned to the pixel lattice.

Written by September 13, 2026 2 min read
Was this helpful?