1. Piecewise-Linear Transformation Functions

These are functions that manipulate an image's contrast by mapping input pixel values to output pixel values using linear segments. The main types covered are contrast stretching, intensity-level slicing, and bit-plane slicing.

Intensity-Level Slicing

Bit-Plane Slicing


2. Histogram Processing

A histogram is a fundamental graph indicating the number of times each gray level occurs, showing the overall distribution of grey levels in an image.

Four Basic Image Types Based on Histograms


3. Histogram Equalization

Histogram equalization is a mathematical technique used for adjusting image intensities to automatically enhance overall contrast. It works by mapping each pixel with level rk in the input image into a corresponding pixel with level Sk in the output image, effectively spreading out the most frequent intensity values.

The Core Formula

Sk=T(rk)=(L1)j=0kpr(rj)

Calculation Example

Suppose we have a 3-bit image (L=8) with a total of 4096 pixels (MN=4096).

Pasted image 20260401223128.png

  1. Find Probabilities: Divide the count of pixels for each level (nk) by the total pixels (4096) to get pr(rk).

    • For r0=0: 790/4096=0.19.
    • For r1=1: 1023/4096=0.25.
    • For r2=2: 850/4096=0.21.
  2. Apply Formula: Multiply the max intensity level (L1, which is 7) by the cumulative sum of probabilities up to that level.

    • s0=7×(0.19)=1.33 (rounds to 1).
    • s1=7×(0.19+0.25)=3.08 (rounds to 3).
    • s2=7×(0.19+0.25+0.21)=4.55 (rounds to 5).
  3. Result: The original clustered gray levels (0, 1, 2) are now stretched out into new mapping values (1, 3, 5), creating a more uniform distribution and higher contrast.

Comparison between contrast stretching and histogram equalization

While both contrast stretching and histogram equalization are techniques used to improve the contrast of an image, they achieve this goal using entirely different mathematical approaches.

1. Contrast Stretching (Min-Max Stretching)

Contrast stretching is a linear (or piecewise-linear) transformation. It works by taking the narrow range of intensity values present in a low-contrast image and pulling them apart to fill the entire available dynamic range (e.g., from 0 to 255 in an 8-bit image).

2. Histogram Equalization

Histogram equalization is a non-linear transformation. Instead of just stretching the boundaries, it mathematically redistributes the pixel intensities so that they are as evenly distributed as possible across the entire range.

Feature Contrast Stretching Histogram Equalization
Transformation Type Linear (or Piecewise-Linear) Non-linear
Primary Goal Expands the existing range of pixels to fill the max/min limits. Flattens the histogram to distribute pixels evenly.
Effect on Histogram Keeps the relative shape, but makes it wider. Completely alters the shape, aiming for a uniform distribution.
Visual Result Usually looks natural, simply correcting "washed out" images. Maximizes contrast heavily, which can sometimes look artificial or amplify noise.
Complexity Computationally simple (relies on min/max values). Computationally more complex (requires calculating probabilities and cumulative sums).