Encoded values and light
The relation between a pixel value and the light intensity it stands for is roughly a power law, with an exponent called gamma:
The sRGB standard, used by nearly all images and displays, replaces the power law with a short linear segment near black and an exponent of 2.4 elsewhere. Overall it is very close to :
Why encode?
Our perception of brightness is far from linear: we notice small differences between dark tones much more easily than between bright ones. Encoding with spreads the 256 levels of an 8-bit image roughly evenly in perceived brightness, with many levels for dark tones and fewer for bright ones. With 8 bits of linear intensity, dark gradients would show visible bands, while many of the bright levels would be wasted. Historically the curve also matched the response of CRT displays.
Medium gray
Alternating black and white lines emit exactly half the light of white. The gray value that looks the same is not 128, but
Conversely, 128 is only of the light. The comparison only works if the lines are displayed at one line per screen pixel and your display follows sRGB; if you see moiré, set the page zoom to 100 %.
Linear vs encoded
Light adds up linearly. Any operation that mixes light (blurring, resizing, anti-aliasing, blending two images, computing a camera's exposure) must therefore work on linear intensities:
Averaging encoded values is too dark: black and white give 128 instead of 188. Between red and green the mix gets a dark, muddy band, and small bright lights lose most of their energy when blurred. The table in the values panel shows these averages.
Adjusting gamma
Raising values to a power is also a common tone adjustment: brightens the shadows, darkens them. Applied to each channel separately, it changes the ratios between R, G and B, so colors shift and saturation changes. Applied to the luma only, the three channels are scaled by the same factor and the colors keep their hue:
Channels that would exceed 1 are clipped. This is often described as applying gamma to the luminance only. Strictly, a weighted sum of encoded values like is the luma; luminance would be computed from linear light, on decoded values.
Try this
- Move the pixel value until its square matches the surround. You will likely end up near 186, which the curve maps to about 0.5.
- Set and read the light intensity from the curve: about 0.22.
- Blur the colored lights. In encoded values, red and green stripes blend into a dark band and the white lines almost vanish; in linear light the average is a bright yellow and the lines stay visible as a glow.
- Look at the blue and yellow checkerboard: encoded blurring makes it a dull gray, linear blurring a lighter gray.
- Blur the landscape with a small σ. Both versions look similar in smooth areas; the differences appear at high-contrast edges such as the fence.
- Set and compare the gamma adjustments: per channel washes out the colors, luma only keeps them saturated.
- Try on the landscape. Per channel makes the colors more saturated, because the weaker channels drop faster than the strongest one.