News for hackers. Stuff that matters.
Re:Image Dithering: Eleven Algorithms and Source Code by microcolonel on Friday October 06, 2017 @04:26AM (#15415229)
24bpp is not enough for shallow gradients which don't come from a photographic source (especially in dark images). I frequently dither 48bpp material for 24bpp displays.

I typically use Sierra Lite.

I've recently been experimenting with error diffusion along continuous space-filling curves (I forget where I saw this technique first), and using color difference functions (CIEDE2000) to gauge quantization error. These are overkill, but it sure beats doing it the same boring way forever.

Frankly, I would like it if the CRTCs attached to modern GPUs had some ability to apply dither (even just ordered dither) to buffers as they're scanned out, while exposing more precision to applications.

Re:Image Dithering: Eleven Algorithms and Source Code by jacobolus on Friday October 06, 2017 @05:11AM (#15415425)
Unless you are integrating many pixels (how many and with what weights depends on the future processing, intended output, and viewing conditions for the image) I would not expect using a fancy color difference formula for comparing individual pixels to give a particularly useful result. Indeed, the whole point of dithering (especially with high resolution output) is that we can adjust the average light coming from a several-pixel-wide blob by brightening or darkening individual pixels, and thereby make finer distinctions in light level, since the individual pixels are not really noticed. I’m also pretty skeptical about the space-filling curve thing. Those both sound like placebo features to me.
Re:Image Dithering: Eleven Algorithms and Source Code by microcolonel on Friday October 06, 2017 @05:19AM (#15415440)
Well, I did say experimenting, didn't I?

I found the thing which inspired my space filling curve exploration: https://www.compuphase.com/riemer.htm

The Butteraugli score between the standard lena and the Riemersma dither is about 0.5 better than the standard Floyd-Steinberg one.

Approaches like this come closer to back-propagation of errors, the lack of which is where some of the artifacts of unidirectional dither come from. In practice, any decent (full bleed) error diffusion dither works perfectly fine going between 16 and 8 bit planes, but why shouldn't I try some things out which (as you are quick to point out) may have very little value.

Heck, even gamma correction isn't strictly necessary when you're going from 16 to 8 bit sRGB.

Re:Image Dithering: Eleven Algorithms and Source Code by jacobolus on Friday October 06, 2017 @03:50PM (#15419847)
I don’t know enough about Butteraugli (in particular in the range of very very tiny differences in the image) to know whether it’s a reasonable metric for comparing dithering algorithms.

Why do you think this Riemersma method does better at that metric? Maybe it just keeps the diffused errors spatially closer to the original pixel?

Re:Image Dithering: Eleven Algorithms and Source Code by mark-r on Friday October 06, 2017 @09:23AM (#15416568)
Yes, once you start working on a very small segment of the curve it's close enough to linear and gamma correction becomes overkill.
Re:Image Dithering: Eleven Algorithms and Source Code by jacobolus on Friday October 06, 2017 @03:52PM (#15419856)
I could see it making a difference in average color of very noisy regions, especially brightly colored ones. I suspect you could deliberately construct an image where the difference could be seen by human observers.
Re:Image Dithering: Eleven Algorithms and Source Code by dahart on Friday October 06, 2017 @09:52AM (#15416749)
You don't need error diffusion when your target color space is greater than 8 bits per channel. You can just use a random number generator (or sequence).
Re:Image Dithering: Eleven Algorithms and Source Code by tripzilch on Saturday October 07, 2017 @03:01PM (#15425135)
Why exactly? Is there a threshold of bits per channel / resolution, why at 8 bits?

I can understand that it would become less useful, because error diffusion does less if you have more levels. But (I expect) it's still useful at 6 bits (64 values), is 8 not just an arbitrary treshold?

Re:Image Dithering: Eleven Algorithms and Source Code by dahart on Sunday October 08, 2017 @06:33PM (#15430394)
It's because with 8 bits you can't really see the dither pattern itself once a 1-bit difference is at the human threshold of perception.

8 bits is not just an arbitrary threshold, it's the number of bits you need so that a 1 bit difference is just about the "just noticeable difference", assuming you've handled gamma and color reasonably well. 9 bits is more lightness resolution than you can normally see, and 7 bits is too few. If you want to geek out super hard, check out figure 238 here: http://www.telescope-optics.net/eye_intensity_response.htm

The JND of Weber's law is 0.4 - 0.5% for print and monitors most of the time, which is between 1/200 and 1/250. This is why 8 bits is so super popular, it has a 1-bit step of 1/256, which is normally just barely below what we can see with our eyes.

You may need to dither at 6 bits, banding could start to become pretty obvious. Whether you need error diffusion, I don't know, I doubt it would always useful at 6 bits, but I'm sure it would sometimes. I'd say try it on some images and compare to random dithering. Random dithering only sucks on really small palettes like 2 or 16 total colors. It's not that bad on a 256 color gif, and it becomes hard to tell the difference when you're above 4 bits per channel or 12 bits per pixel. 6 bits per channel is decent color resolution, and random will sometimes be good enough. If it's a photograph from a digital camera that's older than a year or two, chances are pretty good you can threshold the image without even dithering, because it's already noisy enough.