Dithering in Colour
10 comments
·March 9, 2025kaoD
> Dithering a black-to-white gradient will be wrong without linearising first.
TBH both look wrong to me. If I squint, neither dithering patterns match the original gradient... but the non-linearized one looks the most similar.
What could be causing this?
hagbard_c
> What could be causing this?
Hypercorrection, in this care over-linearisation.
Clamchop
They may not want to imply that didder's linearized rabbit is wrong, but I'm comfortable saying so. It's not just a little dark, it's way dark, to the point of hiding detail.
The linearized RGB palette is similarly awful. It clobbers a whole swath of colors, rendering them as nearly black. Purples are particularly brutalized. Yellows disappeared and became white.
On my phone, the middle palette doesn't appear too bright to my eyes, either.
Even the linearized gradient looks worse, .
Maybe linear is not best for perceptual accuracy.
Sesse__
For perceptual color difference, there are much better metrics than “distance in linear RGB”. CIE has some implementations of a metric called ΔE*, for instance.
I don't know if they actually do well in dithering, though. My experience with dithering is that it actually works better in gamma space than trying to linearize anything, since the quantization is fundamentally after gamma.
nextts
> We have just committed a mortal sin of image processing. I didn’t notice it, you might not have noticed either, but colour-space enthusiasts will be knocking on your door shortly.
obrhubr
Thanks for your comment! I'm glad you're seeing the same thing :) I re-implemented the linearised dithering in python and got similar results. I checked and rechecked the colour profiles in GIMP, nothing... At this point I can only hope for an expert to appear and tell me what exactly I am doing wrong.
mkesper
Did you try any of the OKlab color space implementations for calculating? https://bottosson.github.io/posts/oklab/
yapyap
Dithering is so neat.
oniony
Print halftoning is interesting too https://photo.stackexchange.com/questions/5779/what-is-the-d...
It might be worth using a lightness estimate like OKLab, OKLrab[1], or CIE Lab instead of the RGB luminance weighting, as it should produce a more perceptually accurate result.
The other issue with your code right now, is that it is using euclidean distance in RGB space to choose the nearest color, but it would be probably also more accurate to use a perceptual color difference metric, a very simple choice is euclidean distance on OKLab colors.
I think dithering is a pretty interesting area of exploration, especially as a lot of the popular dithering algorithms are quite old and optimized for ancient compute requirements. It would be nice to see some dithering that isn't using 8-bits for errors, is based on perceptual accuracy, and perhaps uses something like a neural net to diffuse things in the best way possible.
[1] https://bottosson.github.io/posts/colorpicker/