a dither algorithm; small, spatially stable, based on magic numbers and arithmetic.
GIF animations and eink benefit from the spatial stableness; since fewer pixels change during partial changes
The tiny code size; and not LUT makes it suited for micro-controller or direct hardware implementations,
|bayer 1.2M||a dither 1.3M (addition based)||a dither 1.3M (xor based)||error diffusion 2.9M|
The above videos shows how the dither applies to a bitdepth reduction task of RGB 8:8:8 to RGB 3:3:2 with a total of 256 colors - below is a 1bit dither with various methods on a gray ramp.
Patches for ffmpeg adding these dithering methods; which is how the above
GIFs were generated:
I claim no copyright on the formula; I've merely discovered it. By speculating that something simple like this; without too bad results might exist; and then writing some software to help me look for it. With a better fitness critera; I think better constants for simple formulas with more blue/green noise like results can be found.
The main novelty of a dither is its simplicity/compactness and ease of implementation. For dithering to RGB 565 or 24bit RGB it is sufficient, it is however not faster than using a LUT with dither array, either of a dither's or a much higher quality dither mask like void and cluster. The way a dither is employed is exactly like other dither masks would be - but it is procedural/shader based. If someone comes up with better magic numbers to use on variations of the above formulas, please tell me :)
This is a work in progress - published early and pushed often. Further improvements both expected and to be hoped for. The part of the big-buck bunny clip chosen is chosen to highlight problems of 'a dither', if I wanted to make a-dither look good I would instead hunt out examples making bayer and error diffusion look bad ;)Øyvind Kolås, email@example.com in 2013.