Dithering: Creating Illusions with Mathematics
The Problem: Too Few Colors
Imagine you have a photograph with 16.7 million possible colors, but your display — or your artistic constraint — allows only 16. How do you bridge that gap without losing the essence of the image? This is the fundamental challenge that dithering solves.
Early computer graphics faced this problem constantly. The Commodore 64 had 16 colors. The Game Boy had 4 shades of green. Yet artists and engineers produced images of surprising depth and realism on these machines. Their secret weapon was dithering.
What Is Dithering?
Dithering is the deliberate introduction of noise — carefully calculated noise — to reduce the visual impact of quantization. When you reduce an image from millions of colors to a handful, the transitions between shades become harsh, banded steps. Dithering scatters pixels of available colors in patterns that, at a distance, blend optically into the missing intermediate shades.
This is not random noise. The best dithering algorithms are deterministic and mathematically elegant, distributing quantization error across neighboring pixels in precise ratios.
Ordered Dithering: The Grid Approach
The simplest dithering method uses a threshold matrix — a small grid of values (typically 2×2, 4×4, or 8×8) that defines when a pixel should be rounded up or down. The classic Bayer matrix creates the characteristic cross-hatch pattern visible in retro console graphics.
Ordered dithering is fast — each pixel is processed independently — but the resulting patterns can be visually obvious, especially in gradients. The regularity is both its charm (in pixel art) and its limitation (in photography).
Error Diffusion: Floyd-Steinberg and Beyond
In 1976, Robert Floyd and Louis Steinberg published a deceptively simple algorithm. For each pixel, calculate the quantization error (the difference between the original color and the nearest available color). Then diffuse that error to neighboring pixels that haven't been processed yet, using specific ratios:
7/16 to the right neighbor, to the pixel below-left, directly below, and to below-right. These fractions sum to 1, ensuring no error is lost — only redistributed.
Gerelateerde concepten
Gerelateerde artikelen
Probeer in het Lab
Gerelateerde kunstwerken
Verken Gerelateerde Secties
Gebruik deze secties om kunstwerken te ontdekken, technische context te lezen en het volledige ecosysteem van algoritmische kunst te verkennen.
