Transfer curves, linear space and gamma¶
When the human eye perceives colors, it distinguishes better the contrasts in the weak intensities, in shadows, than in strong lights; in other words, the response to light intensity isn’t linear (proportional)1: a light that we perceive at “half” the intensity of another light isn’t really and physically half as intense, but rather four times less intense. cf. chapter Perception of light and colors by the human eye.
To optimize the amount of data and the quality of images in video, and later in digital images, instead of representing light in a physical way, non-linear transfer curves are used, which are called a gamma correction2 in its simplest form3, and which simulate this non-linear perception of human vision and allow to store the values as they are perceived.
Color spaces therefore each define their own transfer curve, but it’s often possible to linearize the spaces when used as working spaces in applications, to get closer to physical light during the work (and simplify calculations).
The advantage of non-linear spaces is therefore twofold: as spaces for storage and display, they make it possible to limit the quantity of data without any visible loss of quality; as working spaces, they make it possible to work with intuitive values and color selectors, which work in the same way as our perception of colors. In digital painting, blending colors with these spaces may look closer to actual paint where blending tends to darken the color mix.
The selection of dark colors is much more difficult in linear, while with a gamma the scale of brightness seems more regular and logical.
However, linear spaces also have their advantages: they simplify calculations (for developers and for improved performance), and by simulating real and physical light, they allow 3D rendering engines to efficiently generate realistic images. In two dimensions and digital painting too, linear spaces allow better calculations of color blending (the different types of transparency) and solve the fringe issues that may appear around some color combinations, allowing more realistic, more logical blends in terms of light, more precise and less darkened.
Notice how the colors blend more naturally in linear, especially the blue in the red that shifts towards magenta, and especially how the blends don’t darken or desaturate the colors.
Note
It is important to note that choosing a linear space to store (and work with) images imposes a higher color depth, in order to keep the quality when converting to non-linear display and broadcast spaces.
-
It’s called “linear” because the graphical representation of the mathematical function associating to a given physical intensity its human perception would be an affine proportional function, represented by a straight line. ↩
-
In reality, gamma correction was created to compensate for the fact that the light intensity generated by the first CRT screens wasn’t linear either. But in digital computing, gamma correction is used to optimize data storage and bandwidth. The fact that this modern gamma correction is close to the one used with old CRT screens is both a coincidence and the result of engineering that aimed to simplify the process. ↩
-
The gamma correction
γ
isn’t the mathematical Gamma functionΓ
, but a simple function using a power (often close to the square, the most common gamma varying around the power of2
). ↩