Image color quantization procedure (FAD)

Share your advanced PureBasic knowledge/code with the community.
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

The 24 bit values are in first instance reduced to 15 bit for that purpose. I use 5-5-5 for RGB, but you can use 6-4-5 if that suits you best, or any other combination. Sorry for the badly commented code. I'll try to clean it a bit when I return to Spain.
El_Choni
LCD
Enthusiast
Enthusiast
Posts: 206
Joined: Sun Jun 01, 2003 10:55 pm
Location: Austria, Vienna
Contact:

Post by LCD »

El_Choni wrote:The 24 bit values are in first instance reduced to 15 bit for that purpose. I use 5-5-5 for RGB, but you can use 6-4-5 if that suits you best, or any other combination. Sorry for the badly commented code. I'll try to clean it a bit when I return to Spain.
I have two purposes for quantisation: For the Spec256 Emulator (256 colors out of 24 Bit palette), where I can use the faked octree, that is damn slow but offers excellent quality of choosen palette.
The second quantisation is to SAM Coupe Palette (64 colours in 2 bright levels=128 colors, 16 on screen without using line interupt), which works very good. I also have the possibility to choose the percentage of error distribution, because the results can be improved significantly for less colours if I choose for example 70-80% of the error for distribution.

Oh yes, don't worry about the comments too much, I just cannot speak very good spain language ;-). And I saw C++ source code that got exactly not even a single comment.
My PC
Ryzen 9 5950, 64 GB RAM, nVidia RTX A4000, Win 10
Ryzen 7 1700, 32 GB RAM, nVidia RTX A2000, Win 10
Post Reply