Xref: utzoo comp.graphics:4121 comp.windows.x:7305 Path: utzoo!attcan!uunet!seismo!sundc!pitstop!sun!falk From: falk@sun.uucp (Ed Falk) Newsgroups: comp.graphics,comp.windows.x Subject: Re: Luminance from RGB Message-ID: <85366@sun.uucp> Date: 14 Jan 89 19:52:17 GMT References: <23105@apple.Apple.COM> <2263@eos.UUCP> <83604@sun.uucp> <7559@watcgl.waterloo.edu> Organization: Sun Microsystems, Inc. - Mtn View, CA Lines: 24 > > BTW, this is an example of a function that couldn't easily > > be accelerated by table lookup unless R, G, and B have very > > few bits. Even then 3D subscript computation puts the table > > lookup in the same speed range as the faster 2 of these > > alternatives. > > Huh? Table look up can be used to replace each of the three multiplies > in aR+bG+cB so that the code becomes something like > > a[R]+b[G]+c[B] > I'm embarrassed. I had been doing (r*77 + g*150 + 29*b)/256 all along thinking that all multiplies took the same amount of time (the compiler, it turns out, optimizes constant multiplies in interesting ways). I've switched all my code to use look-up tables now. I've gained a new respect for look-up tables. -- -ed falk, sun microsystems sun!falk, falk@sun.com card-carrying ACLU member.