Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!rpi!usc!wuarchive!uunet!mcsun!ukc!icdoc!citycs!ans From: ans@cs.city.ac.uk (Ashley Salisbury) Newsgroups: comp.graphics Subject: Re: RGB -> 16 grayscale Message-ID: <1991Mar25.121645.17608@cs.city.ac.uk> Date: 25 Mar 91 12:16:45 GMT References: <5083.669373541@ics.uci.edu> <1991Mar19.115516.21440@lynx.CS.ORST.EDU> Reply-To: ans@city.cs.ac.uk (Ashley Salisbury) Organization: City University, London Lines: 59 In article <1991Mar19.115516.21440@lynx.CS.ORST.EDU> kempkec@mist.CS.ORST.EDU (Christopher Kempke) writes: >In article <5083.669373541@ics.uci.edu> wong@ICS.UCI.EDU (Wang-chan Wong) writes: >>Hi, I am working on a project that requires to display 256 colors with >>a 16 levels grayscale (as with a gas plasma screen.) I understand >>that the following formula will compute the corresponding of graylevel >>given the rgb intensity: >> >> grayscale= .299*red+ .587*green + .114*blue >> >>However, given 256 colors, this formula still maps onto more than 16 >>distinct grayscales. My question is: how to map exactly onto 16 >>grayscales? Are there any algorithms that map onto 16 grayscales >>while minimizing color collison at the same time? (i.e. I can still >>view a 256 pictures in the 16 grayscales gas plasma screen.) >> >>Thanks in advance. -- wang > > > Yes, easily. Assuming that those (red, green, blue) values are > 0-255, you just divide the resultant value by 16, and you get 16 > possible outcomes. Now just devide your available greys into > 16 possibilities 0 = black, 15 = white. > > ..colors represented by the same grey (intensity) value. Just > throw away the least significant bits (as many as necessary) to > leave yourself with the number of intensity values you want. > > You ARE losing information this way, but there's no way to reflect > the 256 colors with only 16 greys unless you halftone, dither, or > use some other method which actually changes the pixel pattern. > > --Chris This is essentially true, however 4 bit quantisation from 256 grey levels to 16 can look a bit poor, I would suggest that you use Floyd -Steinberg Error diffusion to distribute the quantisation error, you get a more pleasing picture to view, although this is more computationally expensive. Another method is to use the dithering method of noise injection to upset the quantisation (described in Ch.4 (?) of Digital Coding of Waveforms : principles and applications to speech and video by N.S. Jayant, and Peter Noll) good luck, Ashley. P.S. The only other thing I might suggest (flames elsewhere please !) is try frame switching on the display (if you can bear the flicker) so that you achieve 31 grey (gray) levels ! .. I have tried this and hated the flicker, but on an LCD or gas plasma it may be bearable (?) .. by having two closely matched pixel values displayed at the same place on alternate display frames the effect with vision persistance is to get an "in-between" grey tone. ie imagine the top left corner pixel .. display say grey level 7, then on the next display frame (1/50th or 1/60 or 1/72 or whatever of a second later) display say grey level 8. Then on the next frame back to 7 etc. The effect (if you are not eppileptic (?) should be a grey level of say 7.5) this 16 grey levels can be used to give the effect of 31. This may provide a more reasonable picture than just 16 grey levels.