 |
Understanding Color and Gamma |
Q: When you open a NEF in Capture NX,
you are seeing the RGB values recorded by the camera sensor, right? Actually,
no, you are not. First there is white balance correction, but most importantly
the RGB color space presented is a gamma corrrected color space.

Bayer Filter
|
How color is recorded by your camera: The sensor in your digital camera is a photon
(or light) detector. It can not directly see color. Instead, it uses Red, Green,
and Blue color filters over the entire sensor (usually in a
Bayer filter
configuration). When twice the amount of light hits the sensor, twice the value
is recorded. When half the amount of light hits the sensor, half the value
is recorded. This means that sensor inside your camera has a linear response
to light intensity.
How color is displayed on a CRT: No matter if you hook up a CRT display or a
LCD monitor to your computer, you expect see the same colors, right? Well, 'the
problem' is that the electron-gun used in a CRT used to display colors is a
non-linear device. This non-linear curve can be described by a 'gamma curve'.
Learn more about gamma correction at Wiki.
If you try to display linearly recorded color on a non-linear output device
like a CRT, you will not get linear output, and the result is a slightly
different (darker) color than intended.
Why non-linear? Go all the way back to the creation of TV, CRT (Cathode Ray Tube).
How would you fix the non-linear output issue? Add gamma correction into every TV
produced, driving up the cost for all TVs? Or have TV broadcaster's gamma encode
their signal, driving up the cost for a few broadcasters? The most cost effective
solution prevailed -- have TV broadbaster's implement the fix (gamma encoder).
The gamma decoder is then present in every TV as the gamma behavior of the
electron gun in the CRT.
TV Gamma Encoding: A TV signal is recorded by the video camera (linear color),
then gamma encoded, broadcast over the airwaves, and displayed by a TV/CRT, which
naturally performs gamma decoding (a byproduct of how the electron gun in a CRT works),
and outputs the signal, effectively reproducing the original linear color information.
PC Display Output is Gamma 2.2: Displays for PC's have standardized on the same
gamma used by the TV (NTSC) industry, a gamma of 2.2. This means that the internal RGB
color space (RGB 0..255 values) is a gamma encoded color space, not a linear color
space. Here is a series of linear RGB values vs gamma encoded linear values and you
can clearly the differences:
| Gamma 2.2 Encoding |
| |
0.0 |
0.1 |
0.2 |
0.3 |
0.4 |
0.5 |
0.6 |
0.7 |
0.8 |
0.9 |
1.0 |
| Linear encoding¹ |
|
|
|
|
|
|
|
|
|
|
|
| Gamma encoded² |
|
|
|
|
|
|
|
|
|
|
|
¹Displays output too dark (non-linear intensity) due to 'automatic' CRT gamma decoding
²Displays output correctly (linear intensity) due to CRT gamma decoding
For 'Linear Enoding' (linear on RGB scale), the output (gamma decoded) is too dark. To compensate,
if the linear RGB data is gamma encoded, the result is that the output (gamma decoded) turns into
a linear scale.
This PC gamma works incredibly well most of the time. Consider JPEG's, which
also are already gamma (2.2) encoded. To use, just uncompress to obtain the
RGB pixels, perform no other processing, and display. The end result is that
the gamma encoded pixel values are output on a PC display, which has a gamma
2.2 output, resulting in you seeing the original linear color photo.
Implications for digital cameras: Any digital camera that produces JPEG's
will produce RGB pixel values that are gamma encoded (not linear). So viewing on
any PC display will result in the original linear color information. The RAW
files produced by a digital camera will be in a proprietary format, likely still
in linear form.
Implications for Capture NX: So when NX opens a NEF (linear color) it
is applying gamma correction, which results in the (non-linear) RGB values that
you see, which when displayed on a CRT or LCD, are displayed via a gamma curve,
resulting in you seeing the original colors (linear).
The Implications for YOU: Hopefully a much better understanding of color.
So that when you see a RGB value of 128, you don't think it is at 50% output
intensity. Instead, you know that '128' is really an output of around 22%
output intensity. To obtain 50% output intensity requires a RGB value of
around '187'.
Interactive Gamma Calculator: To help you understand gamma
encoding and decoding, play around with the following interactive
gamma calculator. Just enter a value in any of the following three
edit boxes, then exit (press TAB, or click the mouse outside the edit box):
sRGB Gamma Encoding Curve: The sRGB color space has a more complex
gamma encoding curve, which is very close to the 2.2 gamma curve, but changes
the lower (black end) of the encoding curve.
Nikon's Gamma+Tone Encoding Curve: And to complicate things even more, camera
vendors appear to be using a custom (proprietary) Gamma+Tone encoding curve. Here
is the curve that approximates what Nikon uses (D300):
If NX101.com helps you, help this site by making a donation.
|