The Difference Between Linear and Logarithmic Color Space and why you Should Care

The Difference Between Linear and Logarithmic Color Space and why you Should Care

April 24, 2018
Andy Dill
Linear and Logarithmic color spaces, the Yin and Yang of color. Let's dive right in and discuss why you SHOULD care about the differences between these two color spaces and how you should be using each one.

Linear color would be better described as “Photometric Color”. It stores the actual values of light, as in “Number of photons hitting the sensor." Because of this, Linear color is stored in a floating point file, allowing for values below zero and above one. It’s not unusual for linear images to have values above ten or even fifty, and in the EXR format they’re capable of having values above sixty thousand.  

Somewhat confusingly, linear color is not linear as the user experiences it. Middle gray, for example is 0.18, not 0.5. This mirrors the real world where an 18% gray card is considered “middle gray," but it’s very different from most of our video experience where middle gray is 0.5.  

Linear color is built to mirror real life, and in real life, each perceptually even increase is a doubling of the number of photons hitting a sensor/your eye. This is how cameras work, where each step (or “stop” as the term goes) is a doubling or halving of the light. Open up 3 stops and you have eight times as much light hitting your sensor.

In the image below, I have exposed at even stops and metered the same area in both linear and logarithmic color space. You can see that the linear values drop by half with each darkening, while the log values change in a more expected manner with around .06 of a change per stop.
If the pixel values in linear color are exponential, then why the heck is the color space called “linear” and not “exponential?" The term “linear” refers to the transfer function, which is a basic x=y function.
In the image above, the linear function is in blue, the exponential function (how light behaves) is in red and the logarithmic function (how light is best stored) is in green.  

If we assume the x-axis is the value of a color and the y-axis is the stored value, you can see that the linear function doesn’t change the value. It’s a very inefficient way to store color, since each perceptual increase is a doubling of value. This leads to both high values and a lot of wasted space in the brighter areas of the image. 

A shadow going from 0.1 to 0.2 is a huge step, but to get the same increase out of a value of 0.6 you need to go all the way up to 1.2 even though the visual difference is the same. You need six times the amount of data to fill in the hole between 0.6 and 1.2 that you do to fill in between 0.1 and 0.2. Hence, the reason why this is inefficient.

This is a good time for logarithmic color to make its entrance in the conversation. Without diving into the math side of color space, just think of logarithmic color as the inverse of linear color. Where linear color requires a doubling of pixel value to yield an even increase, logarithmic color requires an even increase to yield the same. 

In linear color, adding “0.3” to the brightness of your image will be less and less effective the brighter the image gets, but in log color it will be equally effective as many times as you want to add that value. Because of this, most color grading work is done in logarithmic color space: it gives the most even control across the image.

Linear color space, on the other hand, is the best for most other VFX operations because it allows you to manipulate the pixel values as they would exist in the real world.

Linear and Logarithmic color space is a weird concept, especially since most of us are used to working in a video color space, which is a mix between the two that I haven’t even gotten to touch on. I will be sure to write a post that deals with video in the coming months.

First time here? ActionVFX creates action stock footage for VFX and filmmaking. (We also have some great free stuff!)

Remember to connect with us on our social networks to stay updated on our latest news, giveaways, announcements and more!