Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uupsi!sunic!liuida!isy!lysator.liu.se!zap From: zap@lysator.liu.se (Zap Andersson) Newsgroups: comp.graphics Subject: Color quantization ideas: To histogram or not to histogram, comments? Summary: Yawn Keywords: graphics quantization Message-ID: <606@lysator.liu.se> Date: 30 Apr 91 14:44:59 GMT Sender: news@isy.liu.se (Lord of the News) Distribution: comp Organization: Lysator Computer Club, Linkoping University, Sweden Lines: 62 Hello, fellow netters and fellow graphicists (!?) I have always, always, always wondered one thing: * Is there ANY sane reason whatsoever, when trying to quantize a 24 bit image to an 8 bit image, to make a histogram? As I see it, the fact that a certain color is used MORE OFTEN than another, has NOTHING whatsoever to do with if it should be found in the palette or not. I have a good example of this. Assume I have a 24 bit image of a small, red, spaceship flying in front of a rainbow-colored background. The spaceship only occupies about 4-5% of the image, nevertheless it is very important that it is represented accurately. However, the background, being so massively over-represented in the image, (and so variant in color) rips all 256 palette entries from under our feet, leaving none (or very few) to the spaceship! If *I* had been the quantizer, I would have realized that the ship was important, and perhaps replaced the rainbow background with a red, a green and a blue color (3 colors!!) that via dithering created the 'same' rainbow effect. Then I would use the other 253 colors for the spaceship. Ok, that was a bit drastic :-) but think of how much gain there could be in letting the RENDERER do the quantization as the image is built, because it may 'know' such things (this surface is less important, that is more important). But the loss is also obvious: The renderer cannot now a priori how the image will look, until it IS rendered....and it must 'try and fail' to squeeze colors into the palette, and then squeeze the PALETTE if it gets full. This can be a time consuming task (I know - my renderer does exactly this). However, the RESULT of my renderer is MUCH better 8 bit images than using any 'standard' algorithm. And the main bottleneck (I think) is the histo- gram they (all?) use. To create one, you need to pre-quantize to a manageable number of colors, most often 5 bits per channel, yielding 15 bits (32768 colors). BUT 5 BITS PER COLOR IS NOT ENOUGH! If you forget the pre-quantization stage, and forget that stupid histogram (that only decreases image quality) the result is much better. What I like to "know" is: Q: Any comments on the above? Q: When are these STUPID 8 bit displays gonna disappear for good :-) ? /Z -- * * * * * * * * * * * * * * * * * (This rent for space) * My signature is smaller than * Be warned! The letter 'Z' is Copyright 1991 * yours! - zap@lysator.liu.se * by Zap Inc. So are the colors Red, Green and * * * * * * * * * * * * * * * * * Greenish-yellow (Blue was taken by IBM)