Xref: utzoo comp.graphics:4017 comp.windows.x:7059 Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!oliveb!sun!falk From: falk@sun.uucp (Ed Falk) Newsgroups: comp.graphics,comp.windows.x Subject: Re: Luminance from RGB Message-ID: <83604@sun.uucp> Date: 4 Jan 89 04:19:22 GMT References: <23105@apple.Apple.COM> <2263@eos.UUCP> Organization: Sun Microsystems, Inc. - Mtn View, CA Lines: 19 In article <2263@eos.UUCP>, jbm@eos.UUCP (Jeffrey Mulligan) writes: > From article <23105@apple.Apple.COM>, by turk@Apple.COM (Ken "Turk" Turkowski): > > Y = (R + 2G + B) / 4 > Y = 2R + 5G + B Yeesh, you people. Why do you need to simplify it? Are you going to be doing these calculations by hand? Get a calculator or something. If you *must* do it in integer for speed reasons, do it this way: out = (77*r + 151*g + 28*b)/256 ; /* NTSC weights (.3,.59,.11)*/ The results are correct to four decimal places and the divide is replaced by a right-shift in a decent compiler and a byte-move in a good compiler. -- -ed falk, sun microsystems sun!falk, falk@sun.com card-carrying ACLU member.