Gamma Correction
Glossary
What is Gamma Correction?
Gamma correction is a process used in digital imaging to adjust the brightness and contrast of an image or video. It aligns the brightness levels of an image with human visual perception, ensuring that details in shadows and highlights are visible.
Unlike simple brightness adjustments, gamma correction modifies the relationship between pixel values and displayed brightness using a mathematical curve, enhancing the overall visual quality.
How does gamma correction work?
Gamma correction addresses two key issues: how humans perceive light and how display devices reproduce it.
Our eyes do not perceive brightness linearly. Without adjustment, images captured with a camera (which records light linearly) would not appear natural to human viewers – even if it actually is. Dark areas will look too dark, and subtle variations in brightness may be lost.
Display devices do not produce light intensity linearly in response to voltage input either. Instead, their output follows a power-law curve. This is a holdover from the CRT era, as even modern displays – while more linear – are designed to mimic this behavior for compatibility with older standards.
Gamma correction solves both problems by:
- Encoding: By adjusting the linear data from the camera to match human perception. This ensures brightness levels are distributed in a way that looks natural to us.
- Decoding: By applying an inverse gamma correction on displays to adjust the signal so the non-linear output of the screen reproduces the intended brightness. Gamma correction relies on a gamma curve, a non-linear function that maps input pixel values to output brightness levels.
In this graph, the X-axis represents input values, while the Y-axis represents output pixel values after gamma correction.
What does this tell us? For each pixel in an image captured by a linear source (like a camera):
Corrected pixel intensity = Input pixel intensity ^ Gamma value (γ)
The gamma value is key to the transformation here and is represented by the γ (gamma) symbol:
- If this value is > 1, it suppresses lower light intensities, making the image darker – commonly used at the source during encoding to match the non-linear perception of human vision.
- If this value is < 1 (i.e., an inverse gamma correction), the formula will boost lower intensity values – commonly used during decoding gamma-encoded data on a screen for final display.
- If this value is = 1, no correction is applied.
Mathematically, this function is most effective at adjusting midtones (input around 0.3–0.7). Shadow (intensities near 0) and highlight (intensities near 1) details are preserved as is, as raising these values to any power results in only slight changes.
What is the difference between gamma correction and brightness adjustment?
Gamma correction adjusts brightness nonlinearly by redistributing light intensity, focusing on midtones while preserving the contrast between shadows and highlights. It ensures that details in darker and brighter regions remain intact, and this adjustment keeps in mind both human visual perception and display characteristics.
On the other hand, brightness adjustment applies a uniform, linear shift to all pixel values, which can wash out highlights or crush shadows and cause a loss of contrast and detail.
The key distinction lies in precision. Brightness adjustment is a blunt tool suitable for simple light-level changes but risks compromising the image. Gamma correction's selective impact makes it better suited for preserving an image's natural depth and contrast.
What are the applications of gamma correction?
Gamma correction is critical in multiple industries due to its ability to adjust brightness and contrast while preserving image details:
- Photography: Cameras capture light linearly, but images are gamma-encoded to match how humans perceive brightness. This ensures photos look natural on standard displays.
- Video Rendering: Light calculations are often performed in linear space in video production and computer graphics. However, gamma correction is applied when rendering the final video to make it perceptually correct for human eyes.
- Editing: Gamma correction adjusts midtones to enhance shadow details or prevent highlights from appearing washed out during editing.
- Display Calibration: Different monitors, TVs, and projectors have unique brightness curves. Gamma correction ensures uniform image quality by compensating for these variations. Gamma correction ensures that images and videos look consistent, natural, and true-to-life across devices and lighting conditions.
What happens if gamma correction is incorrect?
When gamma correction is incorrect, either because of gamma encoding not matching gamma decoding, or improper calibration, these issues can occur:
- Washed-Out Images: When the gamma value is set too low (e.g., gamma value < 1 when it should be = 2.2), midtones are overly brightened. The image appears flat, with highlights looking blown out, reducing perceived contrast.
- Overly Dark Images: Conversely, a high gamma value darkens the image. Shadows dominate the image, and important details in midtone ranges are lost, creating a murky or underexposed appearance.
- Color Shifts: Incorrect gamma affects each color channel differently, leading to unnatural tints or inaccurate color reproduction.
- Inconsistent Display Quality: Images or videos might look fine on one display but too dark or too bright on another, leading to a fragmented viewing experience that fails to reflect the creator's intent.
For professional photography and videography, these errors can ruin creative intent. For general users, it leads to dissatisfaction with display devices or media. This is why industries have standardized gamma values (like 2.2 for sRGB or 2.4 for Rec. 709), and both media and displays are calibrated using hardware tools or software to match standards.
Conclusion
By adjusting the non-linear relationship between light intensity and perceived brightness, gamma correction preserves contrast, enhances detail, and creates a more natural, visually accurate experience.
It is essential for maintaining consistent image quality across different devices, ensuring that content looks as intended, whether captured, edited, or viewed.