Xref: utzoo comp.graphics:3896 comp.windows.x:6716 Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!ncar!tank!nic.MR.NET!shamash!nis!ems!datapg!questar!midgard!dal From: dal@midgard.Midgard.MN.ORG (Dale Schumacher) Newsgroups: comp.graphics,comp.windows.x Subject: Re: Luminance from RGB Message-ID: <518@midgard.Midgard.MN.ORG> Date: 13 Dec 88 23:21:38 GMT References: <8241@pasteur.Berkeley.EDU> Reply-To: dal@midgard.Midgard.MN.ORG (Dale Schumacher) Organization: The Midgard Realm, St Paul MN Lines: 20 In article <8241@pasteur.Berkeley.EDU> ph@miro.Berkeley.EDU (Paul Heckbert) writes: | |Paraphrasing, Dale is convering the 3 bit number abc, where each of a, b, |and c are 0 or 1, into the 8 bit number abcabcab. | |This is very close to the "correct" formula, but you've found a somewhat |roundabout way to compute it. The formula you want will map black (000) |to black (00000000) and white (111) to white (11111111) and map everything |inbetween linearly. In other words, you want to multiply by 255/7. |Your formula actually multiplies by 255.9375/7. The point of my "round-about" method is performance. It's much easier to replicate bits and do shifts than to divide by 7. I believe that this approximation will yield the "correct" value (to 8-bit int precision) for all cases, right? |Dale also asked about algorithms for selecting the 16 colors out of a |palette of 512 that best represent an image. This is called "color image |quantization". I wrote about it in a paper: Thank you for the references. I'll check into them.