Practical 4: Gamma Correction & Power Law Transformations

Open In Colab Run this practical in Google Colab

1. Aim

Objective

To understand and implement power law (gamma) transformations for image contrast enhancement.

2. Description / Theory
Theory: The power law transformation \(s = c \cdot r^\gamma\) is one of the most important intensity transformations.
  • \(\gamma < 1\): Enhances dark regions (brightening)
  • \(\gamma > 1\): Compresses bright regions (darkening)
  • \(\gamma = 1, c = 1\): Identity (no change)
$$s = c \cdot r^\gamma$$
3. Code

Part 1: Apply Gamma Correction

Adjust the gamma slider and see the transformation result with histogram comparison.

Part 2: Gamma Series Comparison

Compare the effect of multiple gamma values (0.3, 0.5, 1.0, 1.5, 2.5, 5.0) on the selected image.

Transformation Curves

Visualize how different γ values map input intensities to output intensities.

Part 3: Log Transformation

Apply \(s = c \cdot \log(1 + r)\) and compare with gamma correction (γ = 0.4).

Part 4: Contrast Enhancement

Enhance dark images with γ < 1 or compress bright images with γ > 1.

4. Output 5. Analysis / Conclusion

Analysis Questions

  1. For a dark image, which gamma value produces the best visual enhancement? Why does γ < 1 brighten dark regions?
  2. Compare log transformation with γ = 0.4 on the same image. Which produces better results and why?
  3. How does gamma correction relate to display devices? If a monitor has γ = 2.5, what pre-correction gamma should be applied?