Gamma, Gamma Encoding & Decoding
Gamma – now there’s a term I see cause so much confusion and misunderstanding.
So many people use the term without knowing what it means.
Others get gamma mixed up with contrast, which is the worst mistake anyone could ever make!
Contrast controls the spatial relationship between black and white; in other words the number of grey tones. Higher contrast spreads black into the darker mid tones and white into the upper mid tones. In other words, both the black point and white point are moved.
The only tones that are not effected by changes in image gamma are the black point and white point – that’s why getting gamma mixed up with contrast is the mark of a “complete idiot” who should be taken outside and summarily shot before they have chance to propagate this shocking level of misunderstanding!
What is Gamma?
Any device that records an image does so with a gamma value.
Any device which displays/reproduces said image does so with a gamma value.
We can think of gamma as the proportional distribution of tones recorded by, or displayed on, a particular device.
Because different devices have different gamma values problems would arise were we to display an image that has a gamma of X on a display with a gamma of Y:
Ever wondered what a RAW file would look like displayed on a monitor without any fancy colour & gamma managed software such as LR or ACR?
The right hand image looks so dark because it has a native gamma of 1.0 but is being displayed on a monitor with a native gamma of 2.2
RAW file Gamma
To all intents and purposes ALL RAW files have a gamma of 1.0
Digital camera sensors work in a linear fashion:
If we have “X” number of photons striking a sensor photosite then “Y” amount of electrons will be generated.
Double the number of photons by doubling the amount of light, then 2x “Y” electrons will be generated.
Halve the number of photons by reducing the light on the scene by 50% then 0.5x “Y” electrons will be generated.
We have two axes on the graph; the horizontal x axis represents the actual light values in the scene, and the vertical y axis represents the output or recorded tones in the image.
So, if we apply Lab L* values to our graph axes above, then 0 equates to black and 1.0 equates to white.
The “slope” of the graph is a straight line giving us an equal relationship between values for input and output.
It’s this relationship between input and output values in digital imaging that helps define GAMMA.
In our particular case here, we have a linear relationship between input and output values and so we have LINEAR GAMMA, otherwise known as gamma 1.0.
Now let’s look at a black to white graduation in gamma 1.0 in comparison to one in what’s called an encoding gamma:
The upper gradient is basically the way our digital cameras see and record a scene.
There is an awful lot of information about highlights and yet the darker tones and ‘shadow’ areas are seemingly squashed up together on the left side of the gradient.
Human vision does not see things in the same way that a camera sensor does; we do not see linearly.
If the amount of ambient light falling on a scene suddenly doubles we will perceive the increase as an unquantifiable “it’s got brighter”; whereas our sensors response will be exactly double and very quantifiable.
Our eyes see a far more ‘perceptually even’ tonal distribution with much greater tonal separation in the darker tones and a more compressed distribution of highlights.
In other words we see a tonal distribution more like that contained in the gamma encoded gradient.
Gamma encoding can be best illustrated with another graph:
Now sadly this is where things often get misunderstood, and why you need to be careful about where you get information from.
The cyan curve is NOT gamma 2.2 – we’ll get to that shortly.
Think of the graph above as the curves panel in Lightroom, ACR or Photoshop – after all, that’s exactly what it is.
Think of our dark, low contrast linear gamma image as displayed on a monitor – what would we need to do to the linear slope to improve contrast and generally brighten the image?
We’d bend the linear slope to something like the cyan curve.
The cyan curve is the encoding gamma 1/2.2.
There’s a direct numerical relationship between the two gamma curves; linear and 1/2.2. and it’s a simple power law:
- VO = VIγ where VO = output value, VI = input value and γ = gamma
Any input value (VI) on the linear gamma curve to the power of γ equals the output value of the cyan encoding curve; and γ as it works out equals 0.4545
- VI 0 = VO 0
- VI 0.25 = VO 0.532
- VI 0.50 = VO 0.729
- VI 0.75 = VO 0.878
- VI 1.0 = VO 1.0
Now isn’t that bit of maths sexy………………..yeah!
Basically the gamma encoding process remaps all the tones in the image and redistributes them in a non-linear ratio which is more familiar to our eye.
Note: the gamma of human vision is not really gamma 1/2.2 – gamma 0.4545. It would be near impossible to actually quantify gamma for our eye due to the behavior of the iris etc, but to all intents and purposes modern photographic principles regard it as being ‘similar to’..
So the story so far equates to this:
But things are never quite so straight forward are they…?
Firstly, if gamma < 1 (less than 1) the encoding curve goes upwards – as does the cyan curve in the graph above.
But if gamma > 1 (greater than 1) the curve goes downwards.
A calibrated monitor has (or should have) a calibrated device gamma of 2.2:
As you can now see, the monitor device gamma of 2.2 is the opposite of the encoding gamma – after all, the latter is the reciprocal of the former.
So what happens when we apply the decoding gamma/monitor gamma of 2.2 to our gamma encoded image?
That’s right, we end up back where we started!
Now, are you thinking:
- Don’t understand?
- We are back with our super dark image again?
Welcome to the worlds biggest Bear-Trap!
The “Learning Gamma Bear Trap”
Hands up those who are thinking this is what happens:
If your arm so much as twitched then you are not alone!
I’ll admit to being naughty and leading you to edge of the pit containing the bear trap – but I didn’t push you!
While you’ve been reading this post have you noticed the occasional random bold and underlined text?
Them’s clues folks!
The super dark images – both seascape and the rope coil – are all “GAMMA 1.0 displayed on a GAMMA 2.2 device without any management”.
That doesn’t mean a gamma 1.0 RAW file actually LOOKS like that in it’s own gamma environment!
That’s the bear trap!
Our RAW file actually looks quite normal in its own gamma environment (2nd from left) – but look at the histogram and how all those darker mid tones and shadows are piled up to the left.
Gamma encoding to 1/2.2 (gamma 0.4545) redistributes and remaps those all the tones and lightens the image by pushing the curve up BUT leaves the black and white points where they are. No tones have been added or taken away, the operation just redistributes what’s already there. Check out the histogram.
Then the gamma decode operation takes place and we end up with the image on the right – looks perfect and ready for processing, but notice the histogram, we keep the encoding redistribution of tones.
So, are we back where we started? No.
Luckily for us gamma encoding and decoding is all fully automatic within a colour managed work flow and RAW handlers such as Lightroom, ACR and CapOnePro etc.
Image gamma changes are required when an image is moved from one RGB colour space to another:
- ProPhoto RGB has a gamma of 1.8
- Adobe RGB 1998 has a gamma of 2.2
- sRGB has an oddball gamma that equates to an average of 2.2 but is nearly 1.8 in the deep shadow tones.
- Lightrooms working colour space is ProPhoto linear, in other words gamma 1.0
- Lightrooms viewing space is MelissaRGB which equates to Prophoto with an sRGB gamma.
Image gamma changes need to occur when images are sent to a desktop printer – the encode/decode characteristics are actually part and parcel of the printer profile information.
Gamma awareness should be exercised when it comes to monitors:
- Most plug & play monitors are set to far too high a gamma ‘out the box’ – get it calibrated properly ASAP; it’s not just about colour accuracy.
- Laptop screen gamma changes with viewing position – God they are awful!
Anyway, that just about wraps up this brief explanation of gamma; believe me it is brief and somewhat simplified – but hopefully you get the picture!
Become a patron from as little as $1 per month, and help me produce more free content. Patrons gain access to a variety of FREE rewards, discounts and bonuses. |