Pixel Connectivity

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.

Path

A path between 2 pixels is a sequence of adjacent pixels connecting them.

Neighborhood

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.

Resampling Neighbourhoods

Image resampling finds a source position for each pixel in a new grid. A non-integer source position lies inside a 2×22 \times 2 neighbourhood of source pixels.

Nearest Neighbour

Nearest-neighbour resampling copies the value of the closest source pixel. It preserves source values but creates blocky regions when enlarging an image.

The target output pixel maps backward to source coordinate (0.75,0.25)(0.75,0.25) between the 44 source-pixel centres. Its distance to the centre of 3030 is 0.252+0.252\sqrt{0.25^2 + 0.25^2}. Its distance to the centre of 1010 is 0.752+0.252\sqrt{0.75^2 + 0.25^2}. The 3030 pixel is closest, so nearest-neighbour resampling copies 3030 to the output.

Nearest-neighbour selection from 4 source pixels A mapped target position lies between 4 source-pixel centres. Its direct connection to the closest centre, with value 30, is highlighted. Source neighbourhood 10 30 50 90 mapped target at (0.75, 0.25) Output 30 closest source value
Nearest-neighbour selection from a 2 by 2 source neighbourhood.

Bilinear Interpolation

Bilinear interpolation forms a weighted sum of the 44 surrounding pixels. Each weight decreases with distance from the source position.

The distance-based weights are 0.18750.1875, 0.56250.5625, 0.06250.0625 and 0.18750.1875. Their weighted sum is 38.7538.75, which rounds to output value 3939.

Bilinear interpolation from 4 source pixels A mapped target position lies between 4 source-pixel centres. Dashed lines show that bilinear interpolation uses all 4 source values. Source neighbourhood 10 30 50 90 mapped target at (0.75, 0.25) Output 39 weighted sum
Bilinear interpolation from a 2 by 2 source neighbourhood.

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)=(x−s)2+(y−t)2D_e(p,q) = \sqrt{(x-s)^2 + (y-t)^2}

City-Block Distance

Also known as Manhattan distance. Straight-line distance along the grid.

D4(p,q)=∣x−s∣+∣y−t∣D_4(p,q) = |x-s| + |y-t|

Chessboard Distance

D8(p,q)=max⁡(∣x−s∣,∣y−t∣)D_8(p,q) = \max(|x-s|, |y-t|)
Euclidean, city-block and chessboard distances between the same pixels in a grid Euclidean Dₑ = √5 p q City-Block D₄ = 3 p q Chessboard D₈ = 2 p q Same endpoints: Δx = 2, Δy = 1
The same pixels are compared in each grid. Euclidean distance follows the direct line. City-block distance uses horizontal and vertical moves. The chessboard panel marks the 1-unit vertical component. Dotted guides retain the fixed horizontal offset.

Connectivity Correspondence

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

  • D4D_4 matches 4-connectivity
    Pixels within D4≤1D_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 D8≤1D_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.

Worked Example

Pixel Distances

Find the distances from p(2,3)p(2,3) to q(7,9)q(7,9).

Solution Reveal Hide
De(p,q)=(2−7)2+(3−9)2=61≈7.81D_e(p,q) = \sqrt{(2-7)^2 + (3-9)^2} = \sqrt{61} \approx 7.81D4(p,q)=∣2−7∣+∣3−9∣=11D_4(p,q) = |2-7| + |3-9| = 11D8(p,q)=max⁡(∣2−7∣,∣3−9∣)=6D_8(p,q) = \max(|2-7|, |3-9|) = 6

A shortest 4-path has 1111 moves. A shortest 8-path has 66 moves.

Written by October 28, 2026 3 min read
Was this helpful?