Professional Documents
Culture Documents
Lecture 6
Histogram and Histogram
Equalization
Spring 2016
Histograms
Histogram of an image with gray level (0 to L-1):
A discrete function h(rk) = nk , where rk is the kth gray level and nk is
the number of pixels in the image having gray level rk .
How a histogram is obtained?
For B-bit image, initialize 2B counters with 0
Loop over all pixels x,y
When encountering gray level f(x,y)=i, increment counter # i
Normalized histogram:
A discrete function p(rk) = nk/n , where n is the total number of
pixels in the image. p(rk) estimates probability of occurrence of
gray-level rk
2/23/2016
CIIT, Islamabad
Histogram: application
Distribution of gray-levels can be judged by measuring a histogram
2/23/2016
CIIT, Islamabad
Example Histogram
2/23/2016
CIIT, Islamabad
Example Histogram
2/23/2016
CIIT, Islamabad
Histogram Examples
2/23/2016
CIIT, Islamabad
Histogram equalization
The idea of histogram equalization is that the pixels should
be distributed evenly over the whole intensity range, i.e. the
aim is to transform the image so that the output image has a
flat histogram.
We must find a transformation T that maps grey values r in the input image
F to grey values s = T(r) in the transformed image .
It is assumed that
r = T-1(s).
2/23/2016
CIIT, Islamabad
s = T (r)
to be applied to each pixel of the input image f(x,y), such that a
uniform distribution of gray levels in the entire range results for
the output image g(x,y).
0 r 1 and 0 s 1
T(r) is single valued i.e., there exists r= T-1(r)
CIIT, Islamabad
CIIT, Islamabad
10
2/23/2016
CIIT, Islamabad
11
where
pr ( r j )
nj
n
L 1
j 0,........, L 1 and n n j
j 0
2/23/2016
CIIT, Islamabad
12
CIIT, Islamabad
Output image
13
Output image
Equalized histogram
Equalized histogram
high contrast image
2/23/2016
Output image
CIIT, Islamabad
14
Output image
Equalized histogram
Equalized histogram
Bright input image
2/23/2016
Output image
CIIT, Islamabad
15
CIIT, Islamabad
16
2/23/2016
CIIT, Islamabad
17
2/23/2016
CIIT, Islamabad
18
2/23/2016
CIIT, Islamabad
19
2/23/2016
CIIT, Islamabad
20
CIIT, Islamabad
21
Local enhancement
Histogram using a local neighborhood, for example
7*7 neighborhood
2/23/2016
CIIT, Islamabad
22
2/23/2016
CIIT, Islamabad
23
Color processing
1.can apply histogram equalization to color images
2. don't want to apply it using the RGB color model
- equalizing R, G, and B bands independently
causes color shifts
3. must convert to a color model that separates
intensity information from color information (e.g.
HSI)
2/23/2016
CIIT, Islamabad
24