Path: utzoo!utgpu!watserv1!watmath!att!att!linac!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!ucsd!ucbvax!ulkyvx.BITNET!twdorr01 From: twdorr01@ulkyvx.BITNET (ThomasD) Newsgroups: comp.graphics Subject: Re: RGB to gray Message-ID: <9011200035.AA21751@lilac.berkeley.edu> Date: 20 Nov 90 00:35:51 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: University of Louisville, $peed $cientific Lines: 31 In some article andrew@ee.su.oz.au (Andrew Ho) writes: > I am trying to convert some full color images (RGB) into >gray level images (because I hope to get some non-colorful >laser printouts after doing the convertion). > > Are there any algorithms/lookup tables to do the "RGB to >gray level" matching ? I'm sure there are better algorithms than the one I am going to suggest, but this is the way I've done it and the results are as good as could be expected I suppose. Besides, I've been very anxious to post to this news- group and this seems a good time. I write almost exclusively in assembly, but I'll try to explain in a more intelligible language. I think the best way to go about this would be to take an example. Let's assume your system is set up like mine (for convenience) and each color is defined by an RGB value of 12 bits (4 bits per component). If you take each pixel, add up the components of that pixel, divide by three and round up, you'll have a value that can be mapped back into the Red, Green, and Blue components. I'm sure you realize that if the Red, Green, and Blue components of a pixel take on a common value, then the color of that pixel will be a greyscale. Or, (you're trying to print the RGB image to a laser printer, right?), what I did in my laser routine was to use the common value as an index (in conjunction with the X and Y coordinate of the pixel) into a look-up table of bit map pixels (on and off) that matched the greyscale value as closely as possible. The results were very nice, but I suspect there's a better way to do it. Anybody know? ThomasD