[comp.graphics] What's the best colormap for a 24 bit color image?

mdich@schizo.samsung.com (Mike Dichiappari) (08/18/90)

I want to display some 24 bit color images on my Mac and Sun.  Both
machines have 8 bit display boards.

What is a good algorithm or method for determining the best (or a
very good) colormap given a 24 bit image?  I'd like the algorithm
to work for various sized colormaps (although 256 will be most
commonly used).

Is such an algorithm built into 32 bit Quickdraw?  Are there any
standard algorithms for doing this?  How about any technical 
references?

Thanks
  mike

wes@uh.msc.umn.edu (Wes Barris) (08/18/90)

In article <15019@samsung.samsung.com>, mdich@schizo.samsung.com (Mike
Dichiappari) writes:
> I want to display some 24 bit color images on my Mac and Sun.  Both
> machines have 8 bit display boards.
> 
> What is a good algorithm or method for determining the best (or a
> very good) colormap given a 24 bit image?  I'd like the algorithm
> to work for various sized colormaps (although 256 will be most
> commonly used).
> 
Popular algorithms for doing this are the "median-cut algorithm" or the
"variance-based method".  Both are used to quantize 24 bit images down to
8 bit mapped images.  Depending on the image format you wish to use, I
would check out either the PBMPLUS toolkit or the Utah Raster Toolkit.
They both are very useful toolkits.  PBMPLUS is available at
expo.lcs.mit.edu:contrib/pbmplus.tar.Z and the Utah Raster Toolkit is
available at cs.utah.edu:pub/urt-3.0.tar.Z

      o o o o o o o . . .   ________________________________ _____=======_____
    o      _____            |Wes Barris                    | | wes@msc.edu   |
  .][__n_n_|DD[  ====_____  |Minnesota Supercomputer Center| |(612) 626-1854 |
 >(________|__|_[_________]_|University of Minnesota_______|_|_FAX:_624-6550_|_
 _/oo OOOOO oo`  ooo   ooo  'o^o^o                    o^o^o` 'o^o         o^o`
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
Make it right before you make it faster.

russotto@eng.umd.edu (Matthew T. Russotto) (08/18/90)

In article <15019@samsung.samsung.com> mdich@schizo.samsung.com (Mike Dichiappari) writes:
>I want to display some 24 bit color images on my Mac and Sun.  Both
>machines have 8 bit display boards.
>
>What is a good algorithm or method for determining the best (or a
>very good) colormap given a 24 bit image?  I'd like the algorithm
>to work for various sized colormaps (although 256 will be most
>commonly used).

I've been told that the best algorithm is to be found in an article called
"Color Image Quantization for Frame Buffer Display", by Paul Heckbert,
Proceedings of SigGraph '82. Computer Graphics V16, N3.  I can't track
down the magazine, though.
--
Matthew T. Russotto	russotto@eng.umd.edu	russotto@wam.umd.edu
][, ][+, ///, ///+, //e, //c, IIGS, //c+ --- Any questions?

hawley@adobe.COM (Steve Hawley) (08/18/90)

In article <15019@samsung.samsung.com> mdich@schizo.samsung.com (Mike Dichiappari) writes:
>What is a good algorithm or method for determining the best (or a
>very good) colormap given a 24 bit image?  I'd like the algorithm
>to work for various sized colormaps (although 256 will be most
>commonly used).

See the answers to frequently asked questions in the newsgroup comp.graphics.
I believe a very  workable solution has been done by Paul Heckbert that
quantizes 24 bit color down to 8 bit color.


>Is such an algorithm built into 32 bit Quickdraw?  Are there any
>standard algorithms for doing this?  How about any technical 
>references?

I understand that 32-Bit Quickdraw has an option to do color dithering.  If
you go this route, your code will not work the same on both Macintosh and Suns
and you are limiting yourself to Macs that support or can support 32 bit
Quickdraw.

If you want portability across platforms, use a reasonable color quantizing
algorithm and perhaps sweat out the details of doing color Floyd-Steinberg
dithering or color ordered dithering.  A good general reference for dithering
is "Digital Halftoning" by Robert Ulichney published by MIT press.  I don't
recall if it has anything about color, though.

Steve Hawley
hawley@adobe.com
-- 
"I can always telephone, but I can't tell it much."
	-Roy Blount

thomas%gr.utah.edu@cs.utah.edu (Spencer W. Thomas) (08/20/90)

[I'm posting this from Utah because outgoing news from umich is not
working at the moment.  Please reply to the address below.]

Steve Hawley writes: 
>  A good general reference for dithering
> is "Digital Halftoning" by Robert Ulichney published by MIT press.  I
> don't recall if it has anything about color, though.

No, Ulichney's book doesn't say anything about color (well, nothing
useful).  'Twould be nice if someone wrote as good a book about color
quantization and dithering.

The Utah Raster Toolkit has several tools that do color quantization
(and dithering).  These are
	to8	Very simple ordered dither to a fixed colormap.  Quick
		but dumb.
	mcut	Median cut with optional Floyd-Steinberg dither.  Will
		quantize to any number of colors (<= 256).
	rlequant 
		Variance based quantization with optional
		(Floyd-Steinberg) dither.  Will quantize to any number
		of colors (<= 256).
	rledither
		Floyd-Steinberg dither with optional edge enhancement.
		Takes a color image to a given set of colors.

=Spencer W. Thomas 		EECS Dept, U of Michigan, Ann Arbor, MI 48109
spencer@eecs.umich.edu		313-936-2616 (8-6 E[SD]T M-F)

=Spencer   (spencer@eecs.umich.edu)

damian@bruce.cs.monash.OZ.AU (Damian Conway) (08/27/90)

In <2383@uc.msc.umn.edu> wes@uh.msc.umn.edu (Wes Barris) writes:

>Popular algorithms for doing this are the "median-cut algorithm" or the
>"variance-based method".

The reference for median cut is the Heckbert paper featured in the "Frequently
Asked Questions" posting.

Is there a similar reference for the variance-based method?

damian
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  who: Damian Conway                 email:..!seismo!munnari!bruce.oz!damian
where: Dept. Computer Science        phone: +61-3-565-5779
       Monash University             quote: "A pessimist is never disappointed."
       Clayton 3168
       AUSTRALIA

craig@weedeater.uucp (Craig Kolb) (08/28/90)

In article <2969@bruce.cs.monash.OZ.AU> damian@bruce.cs.monash.OZ.AU
(Damian Conway) writes:
>Is there a similar reference for the variance-based method?

Wan, Wong, and Prusinkiewicz,
An Algorithm for Multidimensional Data Clustering,
Transactions on Mathematical Software, Vol. 14 #2 (June, 1988), pp. 153-162.

A C implementation of variance-based color quantization is available
via anonymous ftp from weedeater.math.yale.edu (130.132.23.17) as
"pub/colorquant.shar".

An improved version (with Floyd-Steinberg dithering) comes as part of
the Utah Raster Toolkit.

Craig