Histogram equalisation is a contrast enhancement technique that improves image quality by redistributing pixel intensity values across the full available range. It is especially useful for images with poor lighting or compressed intensity distribution.
- Expands intensity distribution to utilize the full dynamic range
- Reveals hidden details in regions with low contrast
A digital image is represented as a matrix of intensity values, where each pixel stores the brightness level at a specific location. These values range from black to white depending on the intensity scale.
0 \leq r \leq L - 1,\ \text{where } L = 2^m
Intensity Transformation
Intensity transformation is a basic image processing technique where pixel values of an image are mapped to new values using a mathematical function. This process is used to enhance image quality by adjusting brightness and contrast.
It is generally defined as:
s = T(r)
where:
- r = input pixel intensity
- s = output pixel intensity
- r ≥ 0
Different intensity transformation techniques are:
1. Image negation: This reverses the grayscales of an image, making dark pixels whiter and white pixels darker. This is completely analogous to the photographic negative, hence the name.
s = L - 1 - r
2. Log Transform: Here c is some constant. It is used for expanding the dark pixel values in an image.
s = c log(1+r)
3. Power-law Transform: Here c and γ are some arbitrary constants. This transform can be used for a variety of purposes by varying the value of γ.
s = c rγ
Histogram Equalization
The histogram of a digital image represents the distribution of pixel intensities across different gray levels. For an image with intensity levels ranging from 0 to (L−1), the histogram is defined as:
h(r_k) = n_k
where:
r_k = kth intensity leveln_k = number of pixels having intensityr_k
The histogram can also be normalized by dividing by the total number of pixels in the image. For an N × N image, the normalized histogram is defined as:
p( rk ) = nk/N2
This function represents the probability of occurrence of intensity level
∑ p( rk ) = 1
The histogram of an image provides important information about its grayscale distribution and contrast characteristics.
- If the histogram is concentrated toward the left, it indicates a dark image.
- If the histogram is concentrated toward the right, it indicates a bright image.
- A narrow histogram around the center indicates a low-contrast image.
- A widely spread histogram indicates a high-contrast image.
In image processing, image contrast is often enhanced using histogram equalization.
Histogram equalization redistributes pixel intensities across the full range to produce a more uniform histogram. This improves overall contrast and reveals hidden details in the image.
Mathematical Derivation of Transformation Function
To design histogram equalization mathematically, we model intensity levels as a continuous random variable
Let the transformation be:
s = T(r)
with constraints:
T(r) is strictly increasing.0 \le T(r) \le L-1
These conditions ensure
The cumulative distribution function (CDF) of output intensity is:
F_S(x) = P(s \le x) = P(r \le T^{-1}(x))
From this, the transformation function that produces a uniform distribution is:
s = (L-1)\int_{0}^{r} p_r(x)\,dx
For discrete images, this becomes:
s_k = (L-1)\sum_{j=0}^{k} p(r_j)
This transformation redistributes intensity values to achieve a uniform histogram.
Example 1: Displaying the histogram of the original image to visualize the distribution of pixel intensity values.
% Histogram Equalization in MATLAB
% reading image
I = imread("GFG.jfif");
figure
subplot(1,3,1)
imshow(I)
subplot(1,3,2:3)
imhist(I)
Output:

Example 2: Plots the histogram of the input image to analyze the frequency distribution of pixel intensity levels.
% Histogram Equalization in MATLAB using function
% histogram equalization
J = histeq(I);
figure
subplot(1,3,1)
imshow(J)
subplot(1,3,2:3)
imhist(J)
Output:
