Faking more shades with fewer, using a threshold matrix.
#graphics#image processing
Dithering represents a range of tones with fewer output levels by mixing them in a pattern. Ordered dithering does this with a fixed threshold matrix instead of spreading error between pixels.
the bayer matrix
The 4×4 Bayer matrix orders 16 thresholds so neighbouring values are as far apart as possible:
0 8 2 10
12 4 14 6
3 11 1 9
15 7 13 5
For a pixel at (x, y) with brightness v in [0, 1]:
t = (M[y % 4][x % 4] + 0.5) / 16
out = v > t ? 1 : 0
properties
- Deterministic and parallel. Every pixel is independent, so it's trivial on a GPU.
- Stable under animation. The pattern doesn't crawl between frames the way error diffusion can.
- Visible texture. The cross-hatch is regular, which reads as "retro" rather than as noise.
compared with error diffusion
Floyd-Steinberg pushes each pixel's rounding error onto its unprocessed neighbours. It preserves detail better but is sequential and produces worm-like artefacts in flat areas.
next
Try the same thresholds on characters instead of pixels: map each threshold band to a glyph and compare against plain luminance ramps.