Lecture 7 - Histogram Equalization and Histogram Matching.pdf
1.
Histogram Processing
„ Histogramof a digital image with gray levels in
the range [0,L-1] is a discrete function
h(r
h(rk
k) =
) = n
nk
k
„ Where
„ rk : the kth gray level
„ nk : the number of pixels in the image having gray
level rk
„ h(rk) : histogram of a digital image with gray levels rk
2.
Normalized Histogram
„ dividingeach of histogram value at gray level r
rk
k
by the total number of pixels in the image, n
n
p(r
p(rk
k) =
) = n
nk
k / n
/ n
„ For k = 0,1,…,L-1
„
„ p(r
p(rk
k)
) gives an estimate of the probability of
occurrence of gray level r
rk
k
„ The sum of all components of a normalized
histogram is equal to 1
3.
Histogram Processing
„
„ Usedeffectively for image enhancement
„ Information inherent in histograms also
is useful in image compression and
segmentation
„ Data-dependent pixel-based image
enhancement method.
4.
Example rk
h(rk) orp(rk)
Dark image
Bright image
Components of
histogram are
concentrated on the
low side of the gray
scale.
Components of
histogram are
concentrated on the
high side of the gray
scale.
5.
Example
Low-contrast image
High-contrast image
histogramis narrow
and centered toward
the middle of the
gray scale
histogram covers broad
range of the gray scale
and the distribution of
pixels is not too far from
uniform, with very few
vertical lines being much
higher than the others
Histogram Equalization:
Implementation
1. Obtainthe histogram of the input image.
2. For each input gray level k, compute the
cumulative sum.
3. For each gray level k, scale the sum by
(max gray level)/(number of pixels).
4. Discretize the result obtained in 3.
5. Replace each gray level k in the input
image by the corresponding level
obtained in 4.
Note
„ It isclearly seen that
„ If the cumulative numbers of gray levels are
slightly different, they will be mapped to
little different or same gray levels as we
may have to approximate the processed gray
level of the output image to integer number
„
„ Thus the discrete transformation function
can’t guarantee the one to one mapping
relationship
13.
Histogram Equalization
„ Agray-level transformation method that forces the
transformed gray level to spread over the entire
intensity range.
„ Fully automatic,
„ Data dependent,
„ Contrast enhanced.
„ Usually, the discrete-valued histogram equalization
algorithm does not yield exact uniform distribution of
histogram.
„ In practice, one may prefer “histogram specification”.
14.
Histogram Matching
(Specification)
„ Histogramequalization has a disadvantage
which is that it can generate only one type
of output image.
„ With Histogram Specification, we can
specify the shape of the histogram that
we wish the output image to have.
„ It doesn’t have to be a uniform histogram
15.
Procedure Conclusion
Indirect Method:
1.Obtain the transformation function T(r) by
calculating the histogram equalization of the
input image
2. Obtain the transformation function G(z) by
calculating histogram equalization of the
desired density function
)
(r
T
s =
)
(z
G
v =
16.
Procedure Conclusion
3. Setv = s to obtain the inversed
transformation function G-1
4. Obtain the output image by applying the
processed gray-level from the inversed
transformation function to all the
pixels in the input image
z = G-1(s) = G-1[T(r)]
17.
Histogram Matching: Example
„Consider an 8-level image with
the shown histogram
„ Match it to the image with the
histogram
Histogram Matching: Example
3.Set v = s to obtain the composite
transform z = G-1(s) = G-1[T(r)]
In other words: Find z such that v is closest to s
21.
Example
Image of Marsmoon
Image is dominated by large, dark areas,
resulting in a histogram characterized by
a large concentration of pixels in pixels in
the dark end of the gray scale
22.
Image Equalization
Result image
afterhistogram
equalization
Transformation function
for histogram equalization
Histogram of the result image
The histogram equalization doesn’t make the result image look better. As a
consequence, the output image is light and has a washed-out appearance.
23.
Histogram Equalization
Histogram Specification
Solvethe problem
•Since the problem with the
transformation function of the
histogram equalization was
caused by a large concentration
of pixels in the original image
with levels near 0
•a reasonable approach is to
modify the histogram of that
image so that it does not have
this property
24.
Result image andits histogram
Original image
The output image’s histogram
Notice that the output
histogram’s low end has
shifted right toward the
lighter region of the gray
scale as desired.
After histogram
Specification
25.
Note
„ Histogram specificationis a trial-and-
error process
„ There are no rules for specifying
histograms, and one must resort to
analysis on a case-by-case basis for any
given enhancement task.