You are on page 1of 26

Histogram

0 Distribution of gray-level values of all the pixels


Probability of occurrence of gray-level r
Number of pixels
(normalized)

Gray levels 

sum of all components of a normalized histogram is equal to 1

9/4/2018
Histograms
HISTOGRAMS

9/4/2018
HISTOGRAMS

9/4/2018
Histogram Equalization
0 Principle: to find the intensity transform such that
histogram of transformed image is uniform.

Histogram

Equalization

9/4/2018
Histogram Equalization
0 Principle: to find the intensity transform such that
histogram of transformed image is uniform.
s = T(r)
such that,
1. T(r) is single-valued and monotonically increasing in
interval 0 ≤ r ≤ 1, so that inverse transformation exists
and increasing order from black to white is preserved, i.e.
output intensity value is never less than input value.
2. 0 ≤ T(r) ≤ 1 for 0 ≤ r ≤ 1, so that output gray levels lie in
the same range as input.

9/4/2018
Transform examples

9/4/2018
Mathematical Proof
0 Let, r, s be random variables in the range [0,L-1],
whose PDFs are pr(r) and ps(s) respectively, then

……(1)

0 Let the transform be given as

(L-1) CDF ……(2)

9/4/2018
Leibniz’s rule states that the derivative of a definite integral with respect to
its upper limit is simply the integrand evaluated at that limit. In other words,

Since, s = T(r)

(L-1)

(L-1)

uniform probability density function

NOTE: The resulting ps(s) always is uniform,


9/4/2018 independent of the form of pr(r)
For discrete values…

Thus,

9/4/2018
Histogram equalization:
Example

9/4/2018
rk Pr(rk) CDF CDF*(L-1) sk rk sk
0 0.19 0.19 1.33 1 0 1
1 0.25 0.44 3.08 3
1 3
2 0.21 0.65 4.55 5
2 5
3 0.16 0.81 5.67 6
4 0.08 0.89 6.23 6 3 6

5 0.06 0.95 6.65 7 4 6


6 0.03 0.98 6.86 7 5 7
7 0.02 1 7 7 6 7

7 7
sk Ps(sk)
0 0
1 Pr(0) = 0.19
2 0
3 Pr(1) = 0.25
4 0
5 Pr(2) = 0.21
6 Pr(3) +Pr(4) = 0.24
7 Pr(5) + Pr(6) + Pr(7) = 0.11

9/4/2018
Why does equalization of discrete
histogram not produce a perfectly flat
histogram?
Discrete histogram equalization basically performs the
remapping of histogram components of an image on
the intensity scale. To obtain a flat histogram, the pixel
intensities should be redistributed in such a way that
there are L groups on n/L pixels of same intensity,
where L is the number of allowed discrete intensity
levels and n is the number of pixels in input image. The
histogram equalization method has no provision for
this type of redistribution process hence discrete
histogram
9/4/2018
equalization does not yield a flat histogram.
What if we want the
distribution to be
something other than
uniform?

9/4/2018
Histogram Matching (Specification)

0 Histogram equalization has a disadvantage which is that it


can generates only one type of output image.
0 With Histogram Specification, we can specify the shape of the
histogram that we wish the output image to have.
0 It doesn’t have to be a uniform histogram

15
Histogram Specification
(Matching)
Input image Image with specified histogram
r  pr(r) z  pz(z)

Histogram equalization Histogram equalization


s=T(r) v=G(z)

Histogram equalized image Histogram equalized image


s  ps(s) v  pv(v)

T(r) =G(z)
 z = G-1(T(r))
Procedure Conclusion

 Obtain the transformation function T(r) by


calculating the histogram equalization of the
input image
r
s  T ( r )   pr ( w )dw
0
 Obtain the transformation function G(z) by
calculating histogram equalization of the
desired density function
z
G ( z )   pz ( t )dt  s
0 17
Procedure Conclusion

 Obtain the inversed transformation function G-1

z = G-1(s) = G-1[T(r)]

 Obtain the output image by applying the


processed gray-level from the inversed
transformation function to all the pixels in the
input image

18
Example: Histogram Matching
Suppose that a 3-bit image (L=8) of size 64 × 64 pixels (MN = 4096)
has the intensity distribution shown in the following table (on the
left). Get the histogram transformation function and make the output
image with the specified histogram, listed in the table on the right.

9/4/2018 19
0 Equalized Input Image 0 Equalized Image with
Specified HIstogram

rk Pr(rk) CDF CDF*(L-1) sk rk sk zk Pz(zk) CDF CDF*(L-1) vk zk vk


0 0.19 0.19 1.33 1 0 1 0 0 0 0 0 0 0

1 0.25 0.44 3.08 3 1 3 1 0 0 0 0 1 0

2 0.21 0.65 4.55 5 2 5 2 0 0 0 0 2 0


3 0.16 0.81 5.67 6 3 6 3 0.15 0.15 1.05 1 3 1
4 0.08 0.89 6.23 6 4 6 4 0.20 0.35 2.45 2 4 2
5 0.06 0.95 6.65 7 5 7 5 0.30 0.65 4.55 5 5 5
6 0.03 0.98 6.86 7 6 7 6 0.20 0.85 5.95 6 6 6
7 0.02 1 7 7 7 7 7 0.15 1 7 7 7 7

9/4/2018
rk sk zk vk
rk sk vk
0 1 0 0

1 3 1 0 0 T 1 0
2 5 2 0 1 3 0
3 6 3 1 2 5 0
4 6 4 2 3 G-16 1
5 7 5 5 4 6 2
6 7 6 6 5 7 5
7 7 7 7 6 7 6

7 7 7

9/4/2018
Example

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
Image of Mars moon 22
Image Equalization

Result image after


Transformation function for Histogram of the result histogram
equalization
histogram equalization image

 The histogram equalization doesn’t make the result image look better than the
original image.
 Consider the histogram of the result image, the net effect of this method is to
map a very narrow interval of dark pixels into the upper end of the gray scale of
the output image.
 As a consequence, the output image is light and has a washed-out appearance. 23
Solve the 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

Histogram Equalization Histogram Specification

24
Histogram Specification

0 (1) the transformation


function G(z) obtained
from
k
G ( z k )   pz ( z i )  sk
i 0

k  0 ,1,2 ,..., L  1

0 (2) the inverse


transformation G-1(s)

25
Result Image and its Histogram

The output image’s histogram


Original image After applied the
histogram Notice that the output histogram’s
equalization low end has shifted right toward
the lighter region of the gray scale
as desired. 26

You might also like