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).
Keep the tone under control while comparing thresholding, an ordered pattern and diffusion. The pattern carries the shades the palette cannot store.
Try it yourself
- Move the requested gray level while all patches keep the same two stored colors.
- Switch to the distant view and compare texture, white coverage and mean error.
Watch: Hard thresholding loses intermediate tones. Ordered, diffused and seeded-random decisions trade different textures and finite-patch errors for a closer average.
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 for a complete stencil. At an image boundary, contributions to neighbors outside the image may be discarded, so global error conservation also depends on boundary handling.
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.
Step through the signed error sent to four future neighbors. Contributions outside the image are discarded at its boundaries.
Try it yourself
- Step to the next pixel and follow source + incoming error → chosen value.
- Compare Floyd–Steinberg with Atkinson, then inspect a pixel at the right or bottom border.
Watch: The next decision includes earlier fractional errors. Floyd–Steinberg passes 100% through its stencil; Atkinson passes 75%, and destinations outside the image receive nothing.
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
In the Lab, open the Dither effects to compare Floyd–Steinberg, ordered dithering and other methods on an imported image or generated noise. Use Indexed palette when you need a fixed total number of colors; the dithering controls describe levels per channel.
Related Concepts
Related Articles
Related Artworks
Explore Related Sections
More about the work:
