Histogram
The histogram of a digital image with intensity levels in the range [0, L – 1] is
a discrete function h( rk ) = nk , where rk is the kth intensity value and nk is the
number of pixels in the image with intensity rk .
The horizontal axis of each histogram plot corresponds to intensity values, rk.
The vertical axis corresponds to values of h( rk ) = nk or p( rk )=nk /MN if the
values are normalized. The total number of pixels in the image is denoted by the
product MN, where, M and N are the row and column dimensions of the image.
Thus, histograms may be viewed graphically simply as plots of h( rk ) = nk versus
rk or p( rk ) = nk /MN versus rk
Histogram equalization:
Histogram equalization assigns the intensity values of pixels in the input
image such that the output image contains a uniform distribution of intensities. It
improves contrast and obtain a uniform histogram. This technique can be used on
a whole image or just on a part of an image.
Consider for a moment continuous intensity values and let the variable r
denote the intensities of an image to be processed. We assume that r is in the range
[0, L - 1], with r = 0 representing black and r = L - 1 representing white. For r
satisfying these conditions, we focus attention on transformations (intensity
mappings) of the form
that produce an output intensity level s for every pixel in the input image having
intensity r. We assume that:
In some formulations, we use the inverse
in which case we change condition (a) to
(a’ )T(r) is a strictly monotonically increasing function in the interval 0≤r≤ L-1.
The requirement in condition (a) that T(r) be monotonically increasing
guarantees that output intensity values will never be less than corresponding input
values, thus preventing artifacts created by reversals of intensity. Condition (b)
guarantees that the range of output intensities is the same as the input. Finally,
condition (a‘ ) guarantees that the mappings from s back to r will be one-to-one,
thus preventing ambiguities.
The intensity levels in an image may be viewed as random variables in the
interval [0, L - 1]. A fundamental descriptor of a random variable is its probability
density function (PDF).
Let pr(r) and ps(s) denote the PDFs of r and s, respectively, where the
subscripts on p are used to indicate that p r and p s are different functions in
general. A fundamental result from basic probability theory is that if p r (r) and
T(r) are known, and T(r) is continuous and differentiable over the range of values
of interest, then the PDF of the transformed (mapped) variable s can be obtained
using the simple formula
…………………….(3)
Thus, we see that the PDF of the output intensity variable, s, is determined by
the PDF of the input intensities and the transformation function used.
A transformation function of particular importance in image processing has
the form
…………………….(4)
where w is a dummy variable of integration.
The right side of this equation is recognized as the cumulative distribution
function (CDF) of random variable r. Because PDFs always are positive, and the
integral of a function is the area under the function, it follows that the
transformation function of Eq. (4) satisfies condition (a) because the area under the
function cannot decrease as r increases. When the upper limit in this equation is r
= (L - 1), the integral evaluates to 1 (the area under a PDF curve always is 1), so
the maximum value of s is (L - 1) and condition (b) is also satisfied.
For discrete values, we deal with probabilities (histogram values) and
summations instead of probability density functions and integrals. As mentioned
earlier, the probability of occurrence of intensity level rk in a digital image is
approximated by
where MN is the total number of pixels in the image, nk is the number of
pixels that have intensity rk , and L is the number of possible intensity levels in the
image (e.g., 256 for an 8-bit image).
The discrete form of the transformation in Eq. (4) is
Thus, a processed (output) image is obtained by mapping each pixel in the
input image with intensity rk into a corresponding pixel with level sk in the output
image, using above eqn.
The transformation (mapping) T( rk ) in this equation is called a histogram
equalization or histogram linearization transformation. This transformation can be
shown to be satisfying conditions (a) and (b) stated previously.