Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!sun-barr!newstop!sun!falk From: falk@sun.Eng.Sun.COM (Ed Falk) Newsgroups: comp.graphics Subject: Re: How to map 24-bit RGB to 256 co Message-ID: <124502@sun.Eng.Sun.COM> Date: 12 Sep 89 02:59:59 GMT References: <7772@cbmvax.UUCP> <1109@krafla.rhi.hi.is> Organization: Sun Microsystems, Inc. - Mtn View, CA Lines: 29 In article <1109@krafla.rhi.hi.is>, pierre@rhi.hi.is (Kjartan Pierre Emilsson) writes: > [summary of Heckbert's median cut algorithm] > When I tried implementing this method, I got into trouble when > a lot of pixels were concentrated on a single colour, because > then the subdivision was actually trying to split a single > colour cell. One way out of this is to make a histogram of the > picture, and single out the sharpest peaks and allocating them > specially. The reast of the picture can then be treated with > the CCC algorithm. In Heckbert's Siggraph paper, he says that when you encounter a box with only a single value inside, that you don't try to split it (since you obviously can't). Instead, you should simply go on, and when all boxes have been split, go back and further split the larger boxes until the unused boxes are all used up. In my own implementation, I did it diferently. Instead of recursively splitting *all* boxes, I just pick the current largest box and split that. I keep doing this until I have 256 (or whatever number I choose) boxes. I think the results are better, and it makes it easy to use numbers that are not a power of two. -- -ed falk, sun microsystems, sun!falk, falk@sun.com "If you wrapped yourself in the flag like George Bush does, you'd be worried about flag-burning too"