I got really bored so I wrote a simple dithering tool in Kotlin. It is surprising how little loss you get when reducing an image to 8 colors. Source code: https://gist.github.com/Frederikam/115a15450bec82720d3bb5a70b5ceefd
This particular algorithm is called Floyd-Steinberg dithering https://en.wikipedia.org/wiki/Floyd%E2%80%93Steinberg_dithering
Wow that's quite something. I guess it's kind of like using more than one pixel as a pixel, displaying the colour using a number of dots... presumably it can't be saved as a jpeg though? Is it a png?
@puffinux It can be saved as JPG, but the result is quite poor
The algorithm only deals with one pixel at a time, but tries to distribute the errors to unprocessed pixels, creating more balance
Interesting... I've heard people say that as it reduces file size, it's a useful technique for sites that operate on poor internet speeds / for people browsing with slow internet.
@puffinux In theory you could represent a pixel as 3 bits without further compression
I'm not sure how that compares to other image encodings, but that would certainly be interesting... some sort of header defining it as an image, a load of binary, and something to close it off...
@puffinux I think that's more or less how PNGs work, with some lossless compression as well
Oh right 😅 I don't know what I'm talking about. Just thinking it through I guess.
@fred i get weird flickers when i scroll that image at 100% zoom. Looks surprisingly good when it's still though!
@lord you can see how it seems to reverse its effect
@lord here's the unblurred image, followed by an upscaled then blurred image, followed by the second image down-scaled
BTW, the best way to get a good color reduction is to use some clustering algorithm to get the best color combination. There's plenty of relevant literature in the academia (key word: color quantization).
Self organizing networks like Kohonen's
( https://en.m.wikipedia.org/wiki/Self-organizing_map ) give out the best results.
@rick_777 looks interesting. Perhaps I'll try it out some day.
@tija being a masochist I'm sure she would like that
We are a cute and loving international community Ｏ(≧▽≦)Ｏ !