Part IA Michaelmas Term
Display Encoding and Gamma
The Purpose of Gamma
Display encoding serves two purposes:
- Historical: CRT monitors had non-linear response: where
- Perceptual: Human vision is approximately logarithmic; gamma encoding distributes quantisation noise uniformly
Gamma Correction Equations
Forward (Encode for Display)
Inverse (Decode from Storage)
Typical value: for sRGB.
Why Not Linear?
Quantisation Analysis
Without gamma encoding:
- Need ~12 bits per channel for visually uniform quantisation
- Dark regions have visible banding
With gamma encoding:
- 8 bits often sufficient
- More codes allocated to darker values (where eye is sensitive)
Perceptual Uniformity
Gamma encoding approximately matches human lightness perception:
- Weber’s law: constant
- Logarithmic response gives uniform perceptual steps
sRGB Transfer Function
sRGB uses a piecewise function (not pure gamma):
Encoding (Linear → sRGB)
Decoding (sRGB → Linear)
Why Piecewise?
- Linear segment near zero avoids numerical issues
- Better approximation of CRT behaviour
- Matches perceptual uniformity more closely
EOTF and OETF
EOTF (Electro-Optical Transfer Function)
Converts digital signal to display light output:
| Standard | EOTF |
|---|---|
| sRGB/CRT | |
| HDR (PQ) | Complex piecewise function |
| HDR (HLG) | Hybrid log-gamma |
OETF (Opto-Electronic Transfer Function)
Converts light to digital signal (inverse of EOTF):
| Standard | OETF |
|---|---|
| sRGB | (approximately) |
| Camera log | Various (LogC, S-Log, V-Log) |
sRGB in OpenGL
OpenGL can automate sRGB conversion:
glEnable(GL_FRAMEBUFFER_SRGB);
- When enabled, fragments are automatically gamma-encoded
- sRGB textures are linearised on sampling
- Ensures correct gamma handling throughout pipeline
Practical Considerations
Common Mistakes
| Mistake | Consequence |
|---|---|
| Applying gamma twice | Image too dark |
| Not applying gamma | Image too bright, banding |
| Mixing linear and gamma | Incorrect blending |
Colour Space Awareness
| Operation | Require |
|---|---|
| Blending | Linear |
| Filtering | Linear |
| Lighting | Linear |
| Storage | Gamma-encoded |
| Display | Gamma-encoded |
Summary
- Gamma correction encodes linear values for efficient storage
- sRGB uses a piecewise function for better accuracy
- All rendering computations must use linear values
- OpenGL’s GL_FRAMEBUFFER_SRGB automates conversion
Past Paper Questions
2024 Paper 3 Question 3: Why is gamma correction needed? What would happen without it?
2023 Paper 3 Question 4: Explain the sRGB transfer function. Why is it piecewise?
2022 Paper 3 Question 3: What operations require linear colour values?