||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 is a gamma-corrected color space.
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
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 instead
will be much a much darker color than intended.
Why non-linear? Go all the way back to the creation of TV and the CRT (Cathode Ray Tube).
The CRT is a non-linear display. How would you fix the problem that CRT's display
in a non-linear manner? Would you add gamma correction into every TV
produced, driving up the cost for all TVs? Or would you have TV broadcaster's
gamma encode their TV signal, driving up the cost for a few broadcasters? The most
cost effective solution prevailed -- have TV broadcaster's implement the fix (gamma
encoder). The gamma decoder is then present in every TV as the physical gamma behavior
of the electron gun in the CRT. And for compatibility, this legacy remains in how
LCD monitors display color.
TV Gamma Encoding: A TV signal is recorded by the video camera (linear color). If
transmitted as-is to TV sets, the gamma behavior of each TV would result in a picture way too
dark. So, the video camera signal is gamma encoded, broadcast over the airwaves, displayed
by a TV/CRT, which physically performs gamma decoding (a byproduct of how
the electron gun in a CRT works), and outputs the signal, effectively reproducing
the original linear video camera signal.
PC Display Output is Gamma 2.2: Displays for PC's (sRGB color space) 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:
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.
¹Displays output too dark (non-linear intensity) due to 'automatic' CRT gamma decoding
|Linear vs Gamma 2.2 encoded (corrected) signals|
|Video signal/voltage (0-1)
|Linear encoding¹ (0-255)
|Gamma encoded² (0-255)
²Displays output correctly (linear intensity) due to CRT gamma decoding
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
Interactive sRGB Gamma Calculator: To help you understand gamma
encoding and decoding, play around with the following interactive
sRGB gamma calculator
(sRGB Color Space Information).
Just enter a value (0-255) into 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.