The Mystery of Gamma Correction
The Hidden Curve
When you read an RGB value of (128, 128, 128) from an image file, you might assume it represents exactly half the brightness of (255, 255, 255). It doesn't. It represents roughly 21.5% of the physical light intensity — less than a quarter. This discrepancy is gamma encoding, and ignoring it is one of the most common mistakes in color computation.
Inspect an encoded value and its exact sRGB decoding. The stored value 128/255 is about 21.6% linear intensity; the Lab’s creative gamma control is a separate operation.
Try it yourself
- Move Encoded channel C and compare the measured linear value with both ramps.
- Choose Near black and move through the C = 0.04045 breakpoint.
Watch: C = 0.5 decodes to about 0.214. Near black, sRGB uses a linear segment; equal stored-value steps and equal light steps produce different ramps.
Why Gamma Exists
Gamma encoding has historical roots in CRT monitors, whose phosphors had a non-linear response to voltage — roughly a power curve of γ ≈ 2.2. Image files are encoded with the inverse curve (γ ≈ 1/2.2 ≈ 0.4545) so that the CRT's non-linearity cancels out and the image appears correct.
But there's a deeper reason gamma persists in the LCD era: it matches human vision. We're far more sensitive to differences in dark tones than bright tones. Gamma encoding allocates more of the 0–255 range to darks, where we can see the finest distinctions, and compresses the brights, where we're less discerning. It's a form of perceptual compression.
The Math Problem
When you calculate the average of two colors — say, blending (255, 0, 0) (red) and (0, 0, 0) (black) — doing it directly in gamma-encoded sRGB gives you (128, 0, 0). But physically, the correct midpoint requires linearizing first, averaging in linear space, then re-encoding:
Linear red = 1.0, linear black = 0.0. Average = 0.5. Re-encoded to sRGB ≈ (188, 0, 0). The difference is dramatic — the gamma-naive blend is visibly darker than it should be.
Linearization in Practice
The sRGB standard defines a precise transfer function (slightly more complex than a simple power curve, with a linear segment near black). To linearize:
For each channel, normalize to [0, 1], then apply: if V ≤ 0.04045, then V_linear = V / 12.92; otherwise V_linear = ((V + 0.055) / 1.055) ^ 2.4. The inverse (linear to sRGB) reverses this.
Operations intended to model the addition or averaging of light should use linear-light values before encoding the result for display. Other operations have different goals: perceptual color distances use spaces such as CIELAB, while an encoded-space adjustment can be an intentional artistic choice. State which model a calculation uses.
Gamma and Dithering
Floyd–Steinberg diffuses the difference between a sample and its quantized result. Computing that error in linear light aims to preserve a local average of physical light; computing it in encoded sRGB preserves a different numerical average and produces a different tonal result. Compare the two goals explicitly rather than treating gamma adjustment as interchangeable with sRGB decoding.
The Takeaway
Gamma is not an obscure technical detail — it's the single most impactful correction you can make to any color algorithm. The difference between gamma-naive and gamma-correct processing is often more visible than the difference between different algorithms entirely.
The gamma-expansion study shows the exact sRGB decoding function and compares equally spaced stored values with equally spaced light. The Lab’s Gamma adjustment is a separate creative power-curve control. Lab operations do not all share one color model: the indexed quantizer, for example, assigns colors by Euclidean distance in encoded RGB.
Related Concepts
Related Articles
Perceptual Color Spaces: CIELAB and Delta E
Where Euclidean RGB distance fails because it ignores human biology, CIELAB succeeds. How the ΔE formula measures color differences in a way that feels human.
Feb 6, 2026
Dithering: Creating Illusions with Mathematics
When you have only a handful of colors, clever pixel placement can trick the eye into seeing thousands. A deep dive into error-diffusion dithering and the algorithms behind the illusion.
Feb 10, 2026
Explore Related Sections
More about the work:
