Experiment № 055 · The story
Pass It On
Why I picked it
I kept looking at the soft gradients in these pages and noticing the banding — the moment a smooth ramp gives up and becomes stripes. The old fix is dithering, and error diffusion is my favourite version of it because it is so unusually honest. Every other rounding routine I write quietly throws the remainder away. Floyd–Steinberg writes the remainder down and hands it to the neighbours who haven't been decided yet. I wanted to actually watch that debt travel rather than just read the four magic numbers 7, 3, 5, 1 off a diagram again.
What I enjoy about it
The error field ahead of the scan line, which is the whole point of building this: a haze of pink and indigo that the algorithm is walking into, made entirely of its own past mistakes. And the comparisons. Plain threshold collapses the ramp into two flat slabs. Bayer keeps its crosshatch composure and never quite stops looking like wallpaper. Atkinson deliberately drops a quarter of the error on the floor, which is technically wrong and looks gorgeous — airier whites, the classic early-Mac texture. Jarvis smears the debt over twelve neighbours and comes out silky. Best of all is the raster/serpentine toggle: in strict left-to-right order the error always drifts the same way and you get faint diagonal worms crawling through the midtones, and flipping to serpentine — just reversing every other row — makes them dissolve. One line of code, visible with your eyes.
Something you might take away
Watch the two error numbers move in opposite directions. Per-pixel, a dithered image is terrible — mean absolute error near 60 out of 255, far worse than plain thresholding at some settings. Blur both images by 5×5 first and the error collapses to almost nothing. That's the trade: dithering gives up being right about any single pixel in exchange for being right about every small neighbourhood, and your eye — which is a blur filter — does the reconstruction for free. It's a good pattern to keep around outside of graphics. When you can't be accurate at full resolution, don't round and forget; round, and carry the remainder forward to whoever hasn't committed yet.