# Thread: Trouble converting 24 bit image to 8 bit image...

1. ## Trouble converting 24 bit image to 8 bit image...

I can read and write the bitmap files just fine, but say I have now a large array of dwords (the dib's pixels) and I need to figure out what 256 colors I can use out of how ever many the 24-bit image has.

I made an algorithim that uses the colors that occure most often in the bitmap. But I quickly learned that it's not good enough.

I would link to make my program capable of acceptable 24 to 8 bit coversion. Like Corel Photo-Paint can do. Does anyone know how to make an algorithim that can do this good? I have done alot of googling, but I can't find anything.

Please help.
Yarin.

2. If you want to convert the bmp without a pallette this is pretty easy. Basically each byte would then hold the complete rbg value. the high 2 bits would be red, middle three green and the last two bits blue.

I'm not sure how coral paint make 8 bit bitmaps but if you are using a palette png format would be better.

3. It's no easy task.

If I remember correctly, Adobe photoshop, has 3 separate algorithms, for choosing a pallette, not inclding the predefined pallettes.

Really, you should get an image editor to do this properly for you.

4. What you want to Google is "dither algorithm".

gg

5. This is an absolutely fantastic article on dithering and colour palette reduction:
http://en.wikipedia.org/wiki/Dither

I believe the thing you asked about however is colour quantization, for which I'll point you at the folowing equally fantastic link:
http://en.wikipedia.org/wiki/Color_quantization

I highly suggest reading both!

6. Pallette optimization is a quite interesting field. You need to choose between speed and quality, as the best algorithms usually take the longest time. Its also easier to optimize a high resolution image than a low resolution one.

7. Thanks for the replys, but I already found out what to do. I created my own version of the Octree Quantization method, and it works sweet! Almost as good as Corel PP in fact.

Popular pages Recent additions