Thursday, June 11, 2009

Linear workflow from Larry Gritz

래리 아저씨가 말하는 linear workflow!

http://http.developer.nvidia.com/GPUGems3/gpugems3_ch24.html


Gamma is one of the most fundamental aspects of image synthesis and display, yet it is also probably the most misunderstood. Gamma correction is critical to high quality display of images.

Short tutorial on gamma:

When rendering, you generally assume that values are linear. In other words, a pixel value of 0.5 (half intensity) should end up producing half the photons of a pixel whose value is 1.0 (full intensity).

But CRT's don't have linear photometric intensity with respect to voltage. When the monitor is well tuned, the response is approximately exponential, i.e. I = V^gamma, where I is intensity, V
is voltage, and gamma is a constant that is *specific to your display device*. FYI, the gamma of the monitors from SGI are between 2.2 and 2.4.

Gamma correction means "pre-correcting" the pixel values by the inverse of this function, in other words p' = p^(1/gamma). (Here, as before, the "^" denotes exponentiation.)

There are basically two ways to deal with the problem.

First, you could correct for this nonlinearity at display time. This can be done either by changing the hardware lookup table (this is easy on an SGI), or in software (for example, using the -gamma switch on "xv"). This is a good general solution, but has problems because you
lose usable color buckets in the low intensity region, and makes certain quantization artifacts more noticable.

The other method is to have the renderer gamma correct *before* quantization (see the RiExposure() function). This means that the renderer output is already gamma corrected for a *specific* display device. This makes best use of the color buckets, so you have highest
fidelity for that monitor, but you're out of luck if later you want to display that file on another CRT.

How to find gamma on your monitor:

First, make the room dark and crank up the monitor contrast and brightness. Lower the brightness gradually until the "background" is no longer noticable (when it just fades from view, stop turning the knob). Then set the contrast to the highest it can get without
causing any distortion or other artifacts.

Now look at the file ftp://hobbes.lbl.gov/xfer/gamma.tif.Z, which is from Greg Ward. This displays a scale that lets you know the gamma of your monitor. Whichever labeled "swatch" on the right matches the left side, that is your gamma.

This procedure needs to be done separately for every monitor you use.

I happen to work on SGI's, and I know the gamma of each monitor of the machines I use. I set the hardware lookup to pre-correct the table, so that from the software's point of view, the display response is linear. I display static images using my "showsgi" software that comes with BMRT, and it has the ability to set the lookup table at display time using the -g command line switch. Other people do things differently, your milage may vary.

Larry Gritz, gr...@seas.gwu.edu Dept. of EE & CS
The George Washington University 801 22nd St. NW, Rm. T-624G
(202) 994-0460 (voice) -0227 (fax) Washington, DC 20052