IMAGE DITHERING STUDIO
Floyd–Steinberg, Atkinson, Stucki, Bayer and friends, on a palette of your choosing. The whole trick is that a pixel's rounding error is not thrown away — it is pushed onto the neighbours that have not been decided yet.
Error diffusion walks the pixels in order and hands each one's rounding error to neighbours it has not visited yet — which is why the kernel is always lopsided towards the right and down, and why a serpentine scan (alternating direction every row) breaks up the diagonal artefacts a straight left-to-right pass leaves behind. Ordered dithering instead adds a fixed threshold pattern, so it has no memory at all: every pixel is independent, the result is stable under animation, and the price is a visible weave.
Strength is the fraction of each pixel's error that gets passed on. At 1 the error is conserved, which is what makes the average come out right; below 1 some is discarded and the image drifts towards the nearest palette colour. Above 1 it would diverge — the loop feeds on itself and the result is noise — so 1 is the ceiling.
Nearest colour is measured as plain Euclidean distance in sRGB, the same convention the classic implementations use. “Diffuse in linear light” converts to linear, does the whole thing there, and converts back — more physically correct, and usually visibly brighter in the midtones, which is why it is a choice rather than the default.
"Four colours is not a limitation once the error has somewhere to go."