Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!convex!texsun!newstop!exodus!nelsun.Eng.Sun.COM!srnelson From: srnelson@nelsun.Eng.Sun.COM (Scott R. Nelson) Newsgroups: comp.graphics Subject: Re: gamma correction Message-ID: <8526@exodus.Eng.Sun.COM> Date: 25 Feb 91 15:42:53 GMT References: <10652@bunny.GTE.COM> Sender: news@exodus.Eng.Sun.COM Lines: 49 From article <10652@bunny.GTE.COM>, by sg04@harvey.gte.com (Steven Gutfreund): > Foley & Van Dam tells me how to do gamma correction for b/w images, > how do I do it for rbg? You do the same thing three times, once for red, once for green and once for blue. Really. Or you can do what most graphics hardware manufacturers do and set the gamma correction value to be the same for red, green and blue. If the CRT is of good quality and is adjusted properly the gamma values for each of the three color channels will be the same. A grey-scale ramp (bars of color increasing linearly across the screen) where each intensity has equal values of red, green and blue will appear as a uniform grey with no colored spots. For those of you that don't have Foley & Van Dam or that have a hard time converting mathematic notation to code, here is a very short C program that prints a gamma correction table: /* * gamma.c * * Print a gamma table. Compile on a unix machine as follows: * cc -o gamma gamma.c -lm */ #include #define CLUT_GAMMA 2.5 /* Gamma setting, typically 2.0 to 2.5 */ main() { int i; /* The CLUT entry number */ int g; /* The computed gamma value */ for (i = 0; i < 256; i++) { g = (int)(255.0 * pow((double) i / 255.0, 1.0 / CLUT_GAMMA)); printf("%d: %d\n", i, g); } } --- Scott R. Nelson srnelson@eng.sun.com Sun Microsystems "Proofread carefully to see if you any words out." Brought to you by Super Global Mega Corp .com