home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / rec / video / 15002 < prev    next >
Encoding:
Text File  |  1992-12-22  |  3.4 KB  |  81 lines

  1. Newsgroups: rec.video
  2. Path: sparky!uunet!usc!cs.utexas.edu!torn!watserv2.uwaterloo.ca!watmath!watcgl!imax!dave
  3. From: dave@imax.imax.com (Dave Martindale)
  4. Subject: Re: Need help with gamma computation
  5. Message-ID: <1992Dec22.051901.13536@imax.imax.com>
  6. Organization: Imax Corporation, Mississauga Canada
  7. References: <-62130@nemesis>
  8. Date: Tue, 22 Dec 1992 05:19:01 GMT
  9. Lines: 70
  10.  
  11. In article <-62130@nemesis> uhclem@nemesis.UUCP writes:
  12. >
  13. >I am working with a device that as far as programming goes looks like a
  14. >VGA controller but outputs NTSC.  Recently I have encountered
  15. >excessive brightness problems and am trying to find how to compute
  16. >the gamma value for NTSC.  I know there is a standard for televisions
  17. >and I would like a definitive value on that too.
  18.  
  19. [ further explanation deleted }
  20.  
  21. You're confusing two different subjects: gamma correction and non-encodable
  22. colours.
  23.  
  24. First, gamma correction:  The CRT is a nonlinear device - light out is not
  25. proportional to voltage in, but proportional to voltage in raised to
  26. some power between 2 and 3.  This power is called the CRT's gamma.
  27. To compensate, you apply "gamma correction".
  28.  
  29. For example, say you have an intensity between 0 (black) and 1 (white),
  30. represented as a floating-point number.  To convert to an 8-bit value to
  31. feed to the D/A converter, the naive way to do it is
  32.  
  33.     pixel_value = (int)(intensity * 255.0 + 0.5);
  34.  
  35. This doesn't work properly, because of CRT gamma.  Instead, do gamma
  36. correction first:
  37.  
  38.     gc_intens = pow(intensity, 0.45);
  39.     pixel_value = (int)(intensity * 255.0 + 0.5);
  40.  
  41. The 0.45 is the reciprocal of a CRT gamma of 2.2.  This is in fact the
  42. value that the NTSC standard says you should compensate for (PAL uses 2.8).
  43. For example, if the intensity is 0.18 (mid-grey), the correct pixel value
  44. is 118 (not 46!).
  45.  
  46. If your intensities are already in integer form, you can do gamma
  47. correction as
  48.  
  49.     pixel_value = (int)(255.0 * pow(pixel_value / 255.0, 0.45) + 0.5);
  50.  
  51. Unfortunately, quantizing to integer twice like this throws away a lot of
  52. the intensity resolution in dark areas, and you are going to get banding
  53. problems in dark regions of some images.  Doing gamma correction in hardware
  54. with only 8-bit pixel values suffers the same fate.
  55.  
  56. Also, note that 0 and 1 are fixed points for the gamma correction function:
  57. 0->0 and 1->1.  It is only intermediate values that are different.
  58.  
  59. Now for the second part: non-encodable colours.  The NTSC standard was
  60. set up with the assumption that scenes would never contain full-saturation
  61. full-intensity colours.  Nature just isn't like that.  You can use
  62. full saturation up to 75% intensity without the NTSC-encoded waveform
  63. reaching amplitudes that are outside the normal B&W range, and you can
  64. use higher intensities at somewhat lower saturation.  But there are some
  65. RGB colours that you can display on a monitor that just can't be turned
  66. into broadcastable NTSC signals.
  67.  
  68. For more detail about video colour encoding, unrepresentable colours,
  69. and one way of dealing with them, see "Television Colour Encoding and
  70. "Hot" Broadcast Colours", p 147, Graphics Gems II, edited by James Arvo,
  71. Academic Press.
  72.  
  73. A final note: Standard colour bars use 75% intensity colours.  That's
  74. 75% *after* gamma correction, not before.  So the correct thing to
  75. store in the frame buffer is just 0.75 * 255 = 191.  (Unless the
  76. frame buffer has gamma correction hardware and you're using it,
  77. in which case you have to figure out what to store in the image in
  78. order to get 191 after gamma correction.)
  79.  
  80.     Dave
  81.