Lexicon / Image · 5 of 7

29 / Image

Ordered Dithering

The picture is cut down to a handful of tones, and the ones that are missing are made up out of a regular grain. Drag to take more away.

Tones, taken away

Three photographs from three centuries: an actress, the surface of the Moon, and the Earth seen from it. Drag the slider: the tones go, and a regular grain makes up for them, down to two.

Sarah Bernhardt, by Nadar, 1864: Sarah Bernhardt at about twenty, in profile, wrapped in a dark velvet cloak, leaning on a column

every tone

Grain
0328402341042481656245018582612444361446638602852206230542233511431339415119592749175725154773913455376331552361295321
The 8×8 Bayer matrix: 64 thresholds, repeated across the picture
Picture

also called Bayer dithering · halftone · posterize

Real pixel work — it needs crossorigin="anonymous" and a CORS-clean host, otherwise the canvas is tainted and getImageData throws. Wikimedia sends the header; most museum CDNs do not. Every cell of the 8×8 matrix holds a threshold, and the 64 are spread so that neighbours differ as much as they can. A pixel takes the tone above its own when it lies further towards that tone than its cell’s threshold, and the tone below when it does not, so a grey a third of the way between two tones lights about a third of every tile. The decision is made in linear light, where light adds up, so the grain averages to the photograph’s own brightness. The grain never moves with the picture: it is the same regular pattern everywhere, which is what separates ordered dithering from the scattered kind.

How it is builtconst BAYER8 = [0, 32, 8, 40, 2, 34, 10, 42, …]; // 64 thresholds, spread as evenly as they can be const t = (BAYER8[(y % 8) * 8 + x % 8] + .5) / 64; // this pixel's threshold out = f > t ? above : below; // f: how far the pixel lies from the tone below to the tone above, in linear light

In full, on GitHub index.html showcase.css showcase.js

Photographs — public domain, via Wikimedia Commons: Sarah Bernhardt (Nadar, 1864), The Moon: Blancanus, Tycho, Schiller (Maurice Loewy and Pierre Puiseux, Paris Observatory, 1899), Earthrise (William Anders, Apollo 8, 24 December 1968); Earthrise is shown cropped to the Earth and the horizon. The Moon plate is from the National Gallery of Art’s open access collection; Earthrise is NASA’s. Facts — Ordered dithering; Earthrise; Sarah Bernhardt.