Okay, so I could no longer keep my restless fingers under control...
here it is, dithered output directly from POV-Ray.
To showcase the effect, I chose a bit depth of 5 bit (the lowest you can
get with PNG), but the algorithm works perfectly fine with other bit
depths as well.
First image shows the original in 8 bit (no dithering applied; if you
look /very/ closely, you may still see some banding in the sky). All
other images use 5 bits per colour channel:
(off) 5 bit image without dithering (I guess I don't need to mention the
banding).
(b2) Bayes dithering using a 2x2 pattern
(b4) Bayes dithering using a 4x4 pattern
(d1) 1-dimensional error diffusion dithering (propagating all the error
to the next pixel to the right)
(d2) 2-dimensional error diffusion dithering (propagating half of the
error to the next pixel to the right, and a quarter, respectively, to
the pixels below and below right)
(fs) the famous Floyd-Steinberg dithering (another error diffusion
dithering)
I didn't bother to implement random dithering, as I don't think it gives
real added value at the bit depths typically used. (b2), (b4) and (d1)
have the advantage of using (almost) no additional memory (I implemented
(d2) and (fs) using an additional 2-pixel-row buffer to avoid messing
with the original data), while (fs) probably gives the best results.
I'll probably drop (d2) as it doesn't seem to add much value either.
A point I'd like to emphasize is that I implemented the diffusion
dithering methods to propagate the error /before/ gamma
encoding/pre-correction. (One reason why dithered black-and-white images
typically lose quite some "depth" is that they are implemented without
attention to gamma.) Not that it will probably matter much with the
typical bit depths, but you know - I just had to do this right ;-)
Post a reply to this message
Attachments:
Download 'dither_off_8bit.png' (129 KB)
Download 'dither_off.png' (80 KB)
Download 'dither_b2.png' (113 KB)
Download 'dither_b4.png' (132 KB)
Download 'dither_d1.png' (299 KB)
Download 'dither_d2.png' (326 KB)
Download 'dither_fs.png' (331 KB)
Preview of image 'dither_off_8bit.png'
Preview of image 'dither_off.png'
Preview of image 'dither_b2.png'
Preview of image 'dither_b4.png'
Preview of image 'dither_d1.png'
Preview of image 'dither_d2.png'
Preview of image 'dither_fs.png'
|