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 built
const 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 lightIn 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.

