VOOZH about

URL: https://www.geeksforgeeks.org/python/python-intensity-transformation-operations-on-images/

⇱ Python - Intensity Transformation Operations on Images - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Python - Intensity Transformation Operations on Images

Last Updated : 8 Jun, 2026

Intensity transformations are image processing techniques that modify pixel intensity values to enhance image appearance, improve contrast, or highlight specific features. These operations are performed directly on image pixels in the spatial domain.

  • Enhance image brightness, contrast, and visibility.
  • Support tasks such as image enhancement, thresholding, and feature extraction.

Types of Intensity Transformations

The following grayscale image will be used throughout the article to demonstrate different intensity transformation techniques.

👁 samplecamera
Input Image

1. Image Negatives

Image negative transformation inverts the intensity values of an image, producing a photographic negative effect. It is commonly used to enhance details that are difficult to observe in dark regions of an image.

  • Each pixel intensity is transformed using , where is the input intensity and is the output intensity.
  • Dark regions become bright and bright regions become dark, helping reveal hidden details in low-intensity areas.

Output:

👁 Output

2. Log Transformation

Log transformation expands low-intensity pixel values while compressing higher-intensity values, making details in darker regions of an image more visible.

  • Log transformation follows the relation , where is the input intensity, is the output intensity, and is a scaling constant.
  • It maps a narrow range of dark pixel values to a wider range, improving visibility in low-light areas.

Output:

👁 Image

3. Power-Law (Gamma) Transformation

Power-law transformation, also known as gamma transformation, adjusts image brightness using a power-law relationship between input and output pixel intensities. It is widely used for image enhancement and display correction.

  • Gamma transformation follows the relation , where is a constant and controls the brightness of the output image.
  • Values of brighten the image, while values of darken the image.

Output:

Gamma = 0.1:

👁 Image

Gamma = 0.5:

👁 Image

Gamma = 1.2:

👁 Image

Gamma = 2.2:

👁 Image

Note:

  • Gamma = 0.1, 0.5: Produces brighter images by increasing low-intensity pixel values.
  • Gamma = 1.2, 2.2: Produces darker images by reducing pixel intensities.

4. Piecewise-Linear Transformation Functions

Contrast stretching is a piecewise-linear transformation that improves image contrast by expanding the range of intensity values. It enhances the visibility of details in images with poor contrast.

  • Contrast stretching increases the difference between dark and bright regions, making image features more distinguishable.
  • The transformation preserves the relative ordering of pixel intensities while expanding their range.

Contrast Formula:

Output:

👁 Image
Comment