Floyd-Steinberg dithering
From Wikipedia, the free encyclopedia
Floyd-Steinberg is a dithering algorithm first published in 1976 by Robert W. Floyd and Louis Steinberg.
The algorithm achieves dithering by diffusing the quantization error of a pixel to its neighboring pixels. More specifically, 7/16 of it is added to the pixel to its right, 3/16 of it to the pixel to its lower left, 5/16 to the pixel below, and 1/16 to the pixel to its lower right.
For example, consider this matrix of pixel values:
If the center value is quantized to zero and the error is diffused by the Floyd-Steinberg algorithm, this would be the result:
Note that the whole algorithm should run in-place instead of accumulating the errors on a separate buffer.