HISTOGRAM EQUALIZATION - VIP-Tomographic

HISTOGRAM EQUALIZATION
This method usually increases the global contrast of many images, especially when the usable
data of the image is represented by close contrast values. Through this adjustment, the
intensities can be better distributed on the histogram. This allows for areas of lower local
contrast to gain a higher contrast without affecting the global contrast. Histogram equalization
accomplishes this by effectively spreading out the most frequent intensity values.
The method is useful in images with backgrounds and foregrounds that are both bright or both
dark. In particular, the method can lead to better views of bone structure in x-ray images, and
to better detail in photographs that are over or under-exposed. A key advantage of the method
is that it is a fairly straightforward technique and an invertible operator. So in theory, if the
histogram equalization function is known, then the original histogram can be recovered. The
calculation is not computationally intensive. A disadvantage of the method is that it is
indiscriminate. It may increase the contrast of background noise, while decreasing the usable
signal.
In scientific imaging where spatial correlation is more important than intensity of signal (such as
separating DNA fragments of quantized length), the small signal to noise ratio usually hampers
visual detection. Histogram equalization provides better detectability of fragment size
distributions, with savings in DNA replication, toxic fluorescent markers and strong UV source
requirements, whilst improving chemical and radiation risks in laboratory settings, and even
allowing the use of otherwise unavailable techniques for reclaiming those DNA fragments
unaltered by the partial fluorescent marking process.
IMPLEMENTATION *
Consider a discrete grayscale image {x} and let ni be the number of occurrences of gray level i.
The probability of an occurrence of a pixel of level i in the image is
L being the total number of gray levels in the image, n being the total number of pixels in the
image, and px being in fact the image's histogram, normalized to [0,1].
Let us also define the cumulative distribution function corresponding to px as
,
which is also the image's accumulated normalized histogram.
We would like to create a transformation of the form y = T(x) to produce a new image {y}, such
that its CDF will be linearized across the value range, i.e.
for some constant K. The properties of the CDF allow us to perform such a transform (see it is
defined as
*Acharya and Ray, Image Processing: Principles and Applications, Wiley-Interscience 2005 ISBN 0-47171998-6
SOME INSIGHT INTO HISTOGRAM EQUALIZATION
Here we want to convert the image so that it has a particular histogram as specified. First
consider equalization transform of the given image
If the desired image
:
were available, it could also be equalized:
where Pz (u) is the desired histogram. The inverse of the above transform is
Since images y and y’ have the same equalized histogram, they are actually the same image and
the overall transform from the given image
to the desired image
can be found as:
where both f and gcan be found from the histogram of the given image
and the desired
histogram, respectively.

Step 1: Find histogram of input image, and find histogram equalization mapping:

Step 2: Specify the desired histogram, and find histogram equalization mapping:

Step 3: Build lookup table:
setup a lookup entry
.
Example:
The histogram of the given image and the histogram desired are shown below:

Step 1: Equalize Px to get y=g(x) (save as previous example).
790


0.19
0.19
1023 0.25
0.44
850
0.21
0.65
985
0.24
0.89
448
0.11
1.00
Step 2: Equalize Pz,.
0/7 0.0
0.0
1/7 0.0
0.0
2/7 0.0
0.0
3/7 0.15
0.15
4/7 0.20
0.35
5/7 0.30
0.65
6/7 0.20
0.85
7/7 0.15
1.0
Step 3: Obtain overal mapping,

This is the histogram of the resulting image:

In the following example, the desired histogram is a triangle with linear increase in the lower
half of the the gray level range, and linear decrease in the upper half. Again the cumulative
histogram shows indeed the density histogram is such a triangle.
HISTOGRAM EQUALIZATION IN MATLAB
J = histeq(I, hgram) transforms the intensity image I so that the histogram of the output
intensity image J with length(hgram) bins approximately matches hgram. The vector hgram
should contain integer counts for equally spaced bins with intensity values in the appropriate
range: [0, 1] for images of class double, [0, 255] for images of class uint8, and [0, 65535] for
images of class uint16. histeq automatically scales hgram so that sum(hgram) = prod(size(I)).
The histogram of J will better match hgram when length(hgram) is much smaller than the
number of discrete levels in I.
J = histeq(I, n) transforms the intensity image I, returning in J an intensity image with n discrete
gray levels. A roughly equal number of pixels is mapped to each of the n levels in J, so that the
histogram of J is approximately flat. (The histogram of J is flatter when n is much smaller than
the number of discrete levels in I.) The default value for n is 64.