Mail Archives: djgpp/1998/02/13/04:00:33
Nate Eldredge <eldredge AT ap DOT net> writes:
>
> At 07:02 2/12/1998 GMT, Keith Bonawitz wrote:
...
> >either 24-bit. How can I convert these 24-bit images to 256 color
> >images? I understand that an palette has to be created that matches
> I think you would be more likely to get a good answer if you ask on
> comp.graphics.algorithms. However, I do know that the program `display' has
> several 24->8 conversion algorithms, and I *think* the source is available.
> Check the `graphics' directory of a Simtelnet site.
>
This is one of the classic problems in computer graphics. You might take
a look at the source of the pbmplus-package by Jef Poskanzer. I solved
my color reduction problem by adopting the algorithm in ppmquant.c
of this package. The famous x11 image viwer/converter 'xv' uses the
same routines. This package uses the median cut algorithm based on
Paul Heckbert's paper "Color Image Quantization for Frame Buffer Display",
SIGGRAPH '82 Proceedings, page 297. It assumes that all your pixels are
stored in a color cube. Now you cut the color cube into smaller ones
with the intention to have the same ammount of pixels in each of the
new small cubes. After creating for example 256 cubes you calculate the
'gravity center' of all pixels inside each cube and take that as the
new color value for all pixels placed in that cube.
Ciao,
Till
- Raw text -