Digital Image Processing (III) Histogram Equalization.

This is an automatically translated post by LLM. The original post is in Chinese. If you find any translation errors, please leave a comment to help me improve the translation. Thanks!

In digital image processing, histogram equalization is a common practice used to adjust brightness, contrast, and image sharpening. It involves statistical analysis of the histogram of different colors in an image, followed by remapping the colors based on this analysis to achieve the desired adjustments in contrast and sharpness.

1. Histogram of Digital Images

A histogram refers to the statistical analysis of all the pixel colors in an entire image, presenting the statistical data of different colors in the form of a histogram.

For example, consider the following two images:

Their corresponding histograms are:

From these figures, it can be observed that an image with high contrast has a wider distribution of colors, while an image with low contrast has colors concentrated in a specific region. In the second image, the pixel values are concentrated on a single color, resulting in image blurring.

Using image histograms, the color distribution of an image can be clearly understood, providing guidance on how to enhance images and improve contrast.

2. Histogram Equalization

Histogram equalization, as the name suggests, aims to equalize the color distribution in an image histogram. Specifically, it redistributes colors that were previously too concentrated in the histogram, spreading them out to occupy the appropriate pixel values. The specific method is as follows (using 3-bit 8-color as an example):

Consider a 64x64 pixel image (M=64, N=64, MN=4096) with 3 bits (L=8) representing colors, ranging from [0,L-1], i.e., [0,7]. By performing statistical analysis on the pixel values of the entire image, we obtain the following statistical data:

\(r_k\) \(n_k\) \(p_r(r_k)=n_k/MN\)