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, 3/16 to the pixel below-left, 5/16 directly below, and 1/16 to below-right. These fractions sum to 1, ensuring no error is lost — only redistributed.
The result is dramatically better than ordered dithering for photographic images. Error diffusion produces organic-looking patterns that follow the natural contours of the image, creating smooth gradients from coarse palettes.
Dithering in the Color Cube
When dithering color images, the algorithm works in three dimensions simultaneously. Each pixel has an error in red, green, and blue, and each error component is diffused independently. This means a pixel that's "too red" will cause its neighbors to become slightly less red, creating a balanced average across local regions.
The choice of color palette is just as important as the dithering algorithm. A well-chosen 16-color palette can outperform a poorly chosen 256-color palette, because the error the dithering algorithm must compensate for is smaller in perceptual terms.
Dithering as an Aesthetic Choice
In algorithmic art, dithering is not just a technical necessity — it's a deliberate aesthetic tool. The characteristic texture of dithered images evokes nostalgia for early computing, while the mathematical precision of error diffusion creates patterns that are simultaneously chaotic and orderly.
Many of the artworks in this gallery use dithering as a final compositing step, reducing high-color renders to restricted palettes. The result is images where every single pixel matters — where the viewer can zoom in and find deliberate, calculated placement at every level.
Try It Yourself
The Dithering Lab lets you experiment with different dithering algorithms and palette sizes in real time. Upload an image or generate one with noise, then watch how Floyd-Steinberg, ordered dithering, and other algorithms transform it into a restricted-palette artwork.
Related Concepts
Related Articles
Try in the Lab
Related Artworks
Explore Related Sections
Use these sections to discover artworks, read technical context, and navigate the full algorithmic art ecosystem.
