Error Diffusion

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

Like dithering, error diffusion trades something else for grey-level depth on a device with few output levels. Each pixel is rounded to the nearest available level. The rounding error, the gap between the original value and the chosen level, is spread over neighbouring pixels not yet processed. Those neighbours are nudged toward the value the current pixel could not hold, so the error cancels over a small region instead of building up.

  • Pixels are processed in raster order, left to right and top to bottom.
  • The error is split by a fixed kernel whose weights sum to 11, so total intensity is preserved.
  • No sub-pixel division, so spatial resolution is preserved.
  • The flat bands of false contouring become high-frequency noise, which the eye tolerates better.

Floyd-Steinberg is the common kernel. With ∗* the current pixel and −- the pixels already done, the error is shared as:

116[−∗7351]\frac{1}{16} \begin{bmatrix} - & * & 7 \\ 3 & 5 & 1 \end{bmatrix}

Serpentine scanning reverses direction every other row, so the error is not always pushed the same way and directional streaks are avoided.

Worked Example

Bi-level device with levels 00 and 255255. One row of 4 pixels, all at value 128128, using 1D diffusion that passes the whole error to the next pixel.

  • Pixel 1’s 128128 rounds to 00, error 128128. Pixel 2 becomes 128+128=256128 + 128 = 256.
  • Pixel 2’s 256256 rounds to 255255, error 11. Pixel 3 becomes 128+1=129128 + 1 = 129.
  • Pixel 3’s 129129 rounds to 255255, error −126-126. Pixel 4 becomes 128−126=2128 - 126 = 2.
  • Pixel 4’s 22 rounds to 00.

Output is 0,255,255,00, 255, 255, 0, mean 127.5127.5, matching the target 128128 that no single pixel could represent.

False contouring and error diffusion

Left: Original greyscale. Centre: Reduced to 4 levels, showing false contouring. Right: Reduced to 4 levels with Floyd-Steinberg error diffusion, trading the flat bands for high-frequency noise. Generated from a photo by Hannes Röst, CC BY-SA 3.0.

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