Gamma, Linear Color Space and HDR
|Table of contents|
Part I: Gamma
We’re all computer users whose primary interface for viewing images is the monitor. Everything about monitors, including their aspect ratio, comes from their ancestors: old television
Gamma, Linear Color Space and HDR
|Table of contents|
Part I: Gamma
We’re all computer users whose primary interface for viewing images is the monitor. Everything about monitors, including their aspect ratio, comes from their ancestors: old television sets.
Old television sets were bad - it took a lot of voltage to make them bright. That’s the thing to remember - that images on a monitor are “darker than they should be”, which we’ll need to know later in order to debug what’s going wrong.Monitors have a gamma of about 2.5, which looks like the graph shown here
But when we watch videos, look at pictures, and work on our computer, the images look the way we think they should, don’t they?
For display on television sets, video cameras compensate by producing images that are slightly “brighter”, so the result is a gamma of about 2.2.
On Windows, the sRGB standard (http://www.w3.org/Graphics/Color/sRGB) for the web (any operating system) is used to give you the experience of having a monitor with a gamma of 2.2. In other words, the monitor profile applies a very small gamma correction of about 1.1 to brighten things up a bit. Our eyes do not want a linear response, and it is pleasing to have an extra gamma applied to images. Linear images appear washed out and we have difficulty seeing the important details.
Since the images you usually worki with (photographs taken with a digital camera, for example) look the way you expect them to, they have obviously have been encoded with a gamma correction that compensates for the darkening the monitor’s response.
What kind of encoding is used? Well, the digital camera captures data from its CCD in some device-specific format. It then copies the pixel values directly to the graphic card buffer, assuming that the graphic card is connected to a device that will respond to these values with a gamma curve of about 2.5, producing a jpeg image that is meant to be viewed on a computer monitor. In other words the jpeg images we work with are, like most other digital images, designed and encoded to be seen on a monitor. They are not linear.
However, when you render an image using a CG application, or paint something in PhotoShop (without any color management setup) no such color encoding happens. Shaders, compositing algorithms, paint brushes, and so on simply poke numerical values without considering what perceptual effect it will have when the image is displayed on a monitor. It's all pure and perfect math, and it doesn’t account for the "impure" way that digital cameras reproduce images.
These calculations all happen in linear space, which means that if a value needs to be twice as bright, the CG application multiplies the value by two, regardless of the fact that the result will in fact not be twice as bright when displayed on a monitor.
While 3D rendering done with Gouraud shading is, by definition, completely linear, things get muddier when you apply image textures to your 3D objects.
Part II : Gamma, Sometimes
In Part I we looked at the (now trendy) notion that the pictures we work with are encoded with a gamma curve to compensate for how the monitor works. However 3D renderers and compositing software calculate things in linear space, or to put it simply they just do the math and produce exact results in the simplest and most obvious way. They do not try to correct for the technological problem of monitor construction.
Some people will tell you should convert all of your images to linear before doing anything, and use a look up table to see the result. That statement should come with a big warning about Dealing With Absolutes (only the Sith do!)
Not all software ignores Gamma. On an editing station such as an Avid Media Composer or an Avid DS, the color correction process is in fact aware that video has a gamma of 2.5 and uses that fact to its advantage. The Avid station processes the data in YUV directly, which allows real-time. It also allows for more accuracy than you would get if you converted everything to RGB (especially 8-bit) and did the same color correction in another product. The user interface also accounts for how video data works.
In 3D rendering software, the various shaders are designed to make the result look good, not necessary mathematically correct. The whole solution was designed to give good-looking results in the environment that it was used.
In 2D compositing, clearly a lot of what we’ve been doing is not mathematically correct. For example, blurring an image with a gamma is not the same as blurring that image without the gamma and then applying a gamma for display. However, what effect we trying to achieve when we blur an image? Depth of field? A foggy environment? The blur is a hack with no equivalent in nature, and we’re used to how i