SlideShare a Scribd company logo
DIGITAL IMAGE PROCESSING
IMAGE ENHANCEMENT
Histogram Processing
by
Dr. K. M. Bhurchandi
Histogram Processing
Histogram:
It is a plot of frequency of occurrence of an event.
freq. of
occurrence
0 1 2 3 event
2
Histogram Processing
 Histogram of images provide a global description of their
appearance.
 Enormous information is obtained.
 It is a spatial domain technique.
 Histogram of an image represents relative frequency of
occurrence of various gray levels.
 Histogram can be plotted in two ways:
3
Histogram Processing
 First Method:
 X-axis has gray levels & Y-axis has No. of pixels in each gray
levels.
nk
Gray Level No. of Pixels (nk) 40
0 40 30
1 20
2 10
3 15 20
4 10
5 3
6 2 10
0 1 2 3 4 5 6
Gray Levels
4
Histogram Processing
 Second Method:
 X-axis has gray levels & Y-axis has probability of occurrence of
gray levels.
P(µk) = nk / n; where, µk – gray level
nk – no. of pixels in kth gray level
n – total number of pixels in an image
Prob. Of Occurrence 1
0.8
Gray Level No. of Pixels (nk) P(µk) 0.7
0 40 0.4 0.6
1 20 0.2 0.5
2 10 0.1 0.4
3 15 0.15 0.3
4 10 0.1 0.2
5 3 0.03 0.1
6 2 0.02
n = 100 1 0 1 2 3 4 5 6 µk
5
Histogram Processing
 Advantage of 2nd method: Maximum value plotted will always be 1.
 White – 1, Black – 0.
 Great deal of information can be obtained just by looking at histogram.
 Types of Histograms:
P(µk) P(µk)
0 rk 0 rk
P(µk) P(µk)
0 rk 0 rk
6
Histogram Processing
 Advantage of 2nd method: Maximum value plotted will always be 1.
 White – 1, Black – 0.
 Great deal of information can be obtained just by looking at histogram.
 Types of Histograms:
P(µk) Dark Image P(µk) Bright Image
0 rk 0 rk
P(µk) Low Contrast Image P(µk) Equalized Image
0 rk 0 rk
7
Histogram Processing
 The last graph represent the best image.
 It is a high contrast image.
 Our aim would be to transform the first 3 histograms into the 4th type.
 In other words we try to increase the dynamic range of the image.
 Normalized histogram is nothing but PDF (Probability Density Function) of
an image.
8
Histogram Stretching
1) Linear stretching:
 Here, we don’t alter the basic shape.
 We use basic equation of a straight line having a slope.
(Smax - Smin)/(rmax - rmin)
Where, Smax – max gray level of output image
Smin – min gray level of output image
rmax – max gray level of input image
rmin – min gray level of input image
0 min max 0 min max
9
Histogram Processing
𝑆 = 𝑇 𝑟 =
𝑆𝑚𝑎𝑥 − 𝑆𝑚𝑖𝑛
𝑟𝑚𝑎𝑥 − 𝑟𝑚𝑖𝑛
𝑟 − 𝑟𝑚𝑖𝑛 + 𝑆𝑚𝑖𝑛
Smax
Smin
rmin rmax
10
Histogram Processing
Ex. 1) Perform Histogram Stretching so that the new image has a dynamic
range of 0 to 7 [0, 7].
Gray Levels 0 1 2 3 4 5 6 7
No. of Pixels 0 0 50 60 50 20 10 0
11
Histogram Processing
Ex. 1) Perform Histogram Stretching so that the new image has a dynamic
range of 0 to 7 [0, 7].
Gray Levels 0 1 2 3 4 5 6 7
No. of Pixels 0 0 50 60 50 20 10 0
Soln:- rmin = 2; rmax = 6; smin = 0; smax = 7;
slope = ((smax – smin)/(rmax - rmin)) = ((7 - 0)/(6 - 2)) = 7 / 4 = 1.75.
S = (7 / 4)(r - 2) + 0; r (7 / 4)(r - 2) = S
S = (7 / 4)(r - 2)
2 0 = 0
3 7/4 = 1.75 = 2
4 7/2 = 3.5 = 4
5 21/4 = 5.25 = 5
6 7 = 7
12
Histogram Processing
Ex. 1) Perform Histogram Stretching so that the new image has a dynamic
range of 0 to 7 [0, 7].
Gray Levels 0 1 2 3 4 5 6 7
No. of Pixels 50 0 60 0 50 20 0 10
60 60
50 50
40 40
30 30
20 20
10 10
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
Original Histogram Stretched Histogram
13
Histogram Processing
Ex. 2) Perform Histogram Stretching so that the new image has a dynamic
range of 0 to 7 .
Gray Levels 0 1 2 3 4 5 6 7
No. of Pixels 100 90 85 70 0 0 0 0
14
Histogram Processing
Ex. 2) Perform Histogram Stretching so that the new image has a dynamic
range of 0 to 7 .
Gray Levels 0 1 2 3 4 5 6 7
No. of Pixels 100 0 90 0 0 85 0 70
Dynamic range increases
BUT
No. of pixels at each gray level remains constant.
15
Histogram Equalization
2) Histogram Equalization:
o Linear stretching is a good technique but not perfect since the shape
remains the same.
o Most of the time we need a flat histogram.
o It can’t be achieved by Histogram Stretching.
o Thus, the technique of Histogram Equalization came into use.
o Perfect image is one where all gray levels have equal number of pixels.
o Here, our objective is not only to spread the dynamic range but also to
have equal pixels at all gray levels.
o It is used to enhance visual content of image.
16
Histogram Equalization
nk Normal Histogram
r
nk Equalized Histogram nk Linearly Stretched Histogram
S S
17
Histogram Equalization
o We have to search for a transform that converts any random histogram
into flat histogram.
o S = T(r)
o We have to find ‘T’ which produces equal values in each gray levels.
o The Transform should satisfy following 2 conditions:
(i) T(r) must be single value & monotonically increasing in the interval,
0 ≤ r ≤ 1.
(ii) 0 ≤ T(r) ≤ 1 for 0 ≤ r ≤ 1
0 ≤ S ≤ 1 for 0 ≤ r ≤ 1
Here, range of r is [0, 1] (Normalized range) instead of [0, 255].
18
Histogram Equalization
These two conditions mean:
1) If T(r) is not single value:
S T(r) S T(r)
S2
S1 S1
r1 r2 r r1 r2 r
fig. (a) fig. (b)
19
Histogram Equalization
 In fig.(a) r1 & r2 are mapped as single gray level i.e. S1.
 Two different gray levels occupy same in modified image.
 Big Drawback, If reconstruction is required.
 Hence, transformation has to be single value.
 This preserves order from black to white.
 A gray level transformation with single value and monotonically
increasing is shown in fig.(b).
2) If condition (ii) is not satisfied then mapping will not be consistent with the
allowed range of pixel value.
 S will go beyond the valid range.
20
Histogram Equalization
 Since, the Transformation is single value & monotonically increasing, the
inverse Transformation exists.
r = T-1(S) ; 0 ≤ S ≤ 1
 Gray levels for continuous variables can be characterized by their
probability density Pr(r) & Ps(S).
 From Probability theory, we know that,
 If Pr(r) & Ps(S) are known & if T-1(S) satisfies condition (i) then the
probability density of the transferred gray level is
Ps(S) = Pr(r). |dr/ ds| ----(a)
Prob. Density (Transformed Image) = Prob. Density (Original Image)
x
inv. Slope of transformation
21
Histogram Equalization
 Now lets find a transform which would give us a flat histogram.
 Cumulative Density Function (CDF) is preferred.
 CDF is obtained by simply adding up all the PDF’s.
S = T(r)
r
S = (L - 1) ʃ Pr(w) dw
0
diff. wrt. r
ds / dr = (L - 1) Pr(r) ---------(b)
Equating eqn(a) & eqn(b), we get
Ps(s) = 1 / L - 1 ; 0 ≤ S ≤ L - 1
22
Histogram Equalization
 A bad Histogram becomes a flat histogram when we find the CDF.
Pr(r) Ps(s)
A 1/L-1
0 L - 1 f 0 L - 1 S
Non-Uniform Function Uniform Function
CDF
Pr(r) dr
23
Histogram Equalization
 NOTE: If an image has MxN pixels, then PDF is given by:
Pr(rk) = nk / MN;
Where, nk – no. of pixels with intensity rk
k = 0, 1, 2, …….., L-1
In continuous domain,
r
S = T(r) = (L-1)ʃ Pr(w) dw
0
In discrete domain,
k
Sk = T(rk) = (L - 1)Σ Pr(rj) (CDF)
j=0
24
Histogram Equalization
Prob. 1) Equalize the given histogram
Gray Levels (r) 0 1 2 3 4 5 6 7
No. of Pixels 790 1023 850 656 329 245 122 81
nk 1000
900
800
700
600
500
400
300
200
100
0 1 2 3 4 5 6 7 r 25
Histogram Equalization
Gray Levels
(rk)
No. of Pixels
nk
(PDF)
Pr(rk) = nk/n
(CDF)
Sk = Σ Pk(rk)
(L-1) Sk = 7 x Sk Rounding
off
0 790 0.19 0.19 1.33 1
1 1023 0.25 0.44 3.08 3
2 830 0.21 0.65 4.55 5
3 656 0.16 0.81 5.67 6
4 329 0.08 0.89 6.23 6
5 245 0.06 0.95 6.65 7
6 122 0.03 0.98 6.86 7
7 81 0.02 1 7 7
n = 4096 1
Equating Gray Levels to No. of Pixels:
0 -> 0 4 -> 0
1 -> 790 5 -> 850
2 -> 0 6 -> 985
3 -> 1023 7 -> 448 Total : 4096 Hence Verified!!!
26
Histogram Equalization
Equalized Histogram:
Gray Levels (S) 0 1 2 3 4 5 6 7
No. of Pixels 0 790 0 1023 0 850 985 448
Total: 4096
nk 1000
900
800
700
600
500
400
300
200
100
0 1 2 3 4 5 6 7 r 27
Histogram Equalization
Prob. 2) Equalize the given histogram
Gray Levels (r) 0 1 2 3 4 5 6 7
No. of Pixels 100 90 50 20 0 0 0 0
nk 100
90
80
70
60
50
40
30
20
10
0 1 2 3 4 5 6 7 r 28
Histogram Equalization
Prob. 3) Equalize the above histogram twice.
Gray Levels (r) 0 1 2 3 4 5 6 7
No. of Pixels 0 0 0 100 0 90 50 20
nk 100
90
80
70
60
50
40
30
20
10
0 1 2 3 4 5 6 7 r 29
Histogram Equalization
Prob. 3) Equalize the above histogram twice.
Gray Levels (r) 0 1 2 3
No. of Pixels 70 20 7 3
nk 100
90
80
70
60
50
40
30
20
10
0 1 2 3 r 30
Histogram Equalization
Prob. 1) What effect would setting to zero the lower order bit plane have on the
histogram of an image shown?
0 1 2 3
no. of
4 5 6 7 pixels
1
8 9 10 11
12 13 14 15
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
no. of levels
31
Histogram Equalization
Prob. 1) What effect would setting to zero the lower order bit plane have on the
histogram of an image shown?
0 1 2 3
4 5 6 7
8 9 10 11 0000 0001 0010 0011
12 13 14 15 0100 0101 0110 0111
1000 1001 1010 1011
1100 1101 1110 1111
32
Histogram Equalization
Prob. 1) What effect would setting to zero the lower order bit plane have on the
histogram of an image shown?
0 1 2 3
4 5 6 7
8 9 10 11 0000 0001 0010 0011
12 13 14 15 0100 0101 0110 0111
1000 1001 1010 1011 0000 0000 0000 0000
1100 1101 1110 1111 0100 0100 0100 0100
1000 1000 1000 1000
1100 1100 1100 1100
Setting lower order bit plane to zero.
33
Histogram Equalization
Prob. 1) What effect would setting to zero the lower order bit plane have on the
histogram of an image shown?
0 0 0 0
0 1 2 3
4 4 4 4
4 5 6 7
8 8 8 8
8 9 10 11 0000 0001 0010 0011
12 12 12 12
12 13 14 15 0100 0101 0110 0111
1000 1001 1010 1011 0000 0000 0000 0000
1100 1101 1110 1111 0100 0100 0100 0100
1000 1000 1000 1000
1100 1100 1100 1100
Setting lower order bit plane to zero.
34
Histogram Equalization
Prob. 1) What effect would setting to zero the lower order bit plane have on the
histogram of an image shown?
0 0 0 0
0 1 2 3
4 4 4 4
4 5 6 7
8 8 8 8
8 9 10 11
12 12 12 12
12 13 14 15
0000 0000 0000 0000
4
0100 0100 0100 0100
1000 1000 1000 1000
1100 1100 1100 1100
no. of
pixels
no. of levels
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
35
Histogram Equalization
Prob. 2) What effect would setting to zero the higher order bit plane have on the
histogram of an image shown? Comment on the image.
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
36
Histogram Equalization
Prob. 3) Given below is the slope transformation & the image. Draw the frequency
tables for the original & the new image. Assume Imin=0, Imax = 7
2 3 4 2
5 5 2 4
I
3 6 3 5 Imax
6 3 5 5
Imin
mmin mmax µ
37
Frequency Domain
2-D Discrete Fourier Transform & Its Inverse:
If f(x, y) is a digital image of size M X N then its Fourier Transform is given by:
M-1 N-1
F(u, v) = f(x, y) e -j2π(ux/M + vy/N) -----------(1)
x=0 y=0
for u = 0, 1, 2, ……., M-1 & v = 0, 1, 2, …….., N-1.
Given the transform F(u, v), we can obtain f(x, y) by using Inverse discrete
Fourier Transform (IDFT):
M-1 N-1
f(x, y) = (1/MN) Σ Σ F(u, v) e j2π(ux/M + vy/N) ------------(2)
u=0 v=0
for x = 0, 1, 2, ….M-1 & y = 0, 1, 2, ….., N-1
Eqn. (1) & (2) constitute the 2-D discrete Fourier transform pair.
38
Σ Σ
Frequency Domain
2-D convolution Theorem:
The expression of circular convolution is extended for 2-D is given below:
M-1 N-1
f(x, y)*h(x, y) = Σ Σ f(m, n)h(x-m, y-n) -----------(3)
m=0 n=0
for x = 0, 1, 2, ….M-1 & y = 0, 1, 2, …..N-1
The 2-D convolution theorem is given by the expressions
f(x, y) ¤ h(x, y) F(u, v) x H(u, v) --------------(4)
and conversely
f(x, y) x h(x, y) F(u, v) ¤ H(u, v) ---------------(5)
39
Frequency Domain
Prob 4) Find the convolution of an image x(m, n) & h(m, n) shown in the fig.
below: y(p, q) = x(m1, n1) ¤ h(m2, n2)
0 -1 1 1 1
-1 4 -1 1 -1
2x2 (m, n)
0 -1 0
3x3 (m, n)
40
Frequency Domain
Prob 4) Find the convolution of an image x(m, n) & h(m, n) shown in the fig.
below: y(p, q) = x(m1, n1) ¤ h(m2, n2)
0 -1 1 1 1
-1 4 -1 1 -1
origin 2x2 (m2, n2)
0 -1 0
3x3 (m1, n1)
p = m1 + m2 -1 q = n1 + n2 -1
= 3 + 2 -1 = 3 + 2 -1
= 4 columns = 4 rows
Resultant image dimension is 4x4.
41
Frequency Domain
x(m, n) h(m, n)
0 -1 1 1 1
-1 4 -1 1 -1
0 -1 0
h(m, -n) h(-m, -n)
1 1
-1 1 -1 1
1 1
42
Frequency Domain
x(m, n) h(-m, -n)
0 -1 1
-1 4 -1 -1 1
0 -1 0 1 1
y(0, 0)
4
43
Frequency Domain
x(m, n) h(1-m, -n)
0 -1 1
-1 4 -1 -1 1
0 -1 0 1 1
4 -6
y(1, 0)
44
Frequency Domain
x(m, n) h(2-m, -n)
0 -1 1
-1 4 -1 0 -1 1
0 -1 0 0 1 1
4 -6 1
y(2, 0)
45
Frequency Domain
x(m, n) h(3-m, -n)
0 -1 1
-1 4 -1 0 0 -1 1
0 -1 0 0 0 1 1
4 -6 1 0
y(3, 0)
46
Frequency Domain
x(m, n) h(-m, 1-n)
0 -1 1 -1 1
-1 4 -1 1 1
0 -1 0
2
4 -6 1
y(0, 1)
47
Frequency Domain
x(m, n) h(-m, 2-n)
0 -1 1 -1 1
-1 4 -1 1 1
0 -1 0 0 0
-1
2
4 -6 1
y(0, 2)
48
Frequency Domain
x(m, n) h(1-m, 1-n)
0 -1 1
-1 4 -1 -1 1
0 -1 0 1 1
y(1, 1) -1
2 5
4 -6 1
49
Frequency Domain
x(m, n) h(1-m, 2-n)
0 -1 1 -1 1
-1 4 -1 1 1
0 -1 0 0 0
y(1, 2) -1 0
2 5
4 -6 1
50
Frequency Domain
x(m, n) h(2-m, 1-n)
0 -1 1
-1 4 -1 0 -1 1
0 -1 0 0 1 1
y(2, 1) -1 0
2 5 -2
4 -6 1
51
Frequency Domain
x(m, n) h(2-m, 2-n)
0 -1 1 0 -1 1
-1 4 -1 0 1 1
0 -1 0 0 0 0
y(2, 2) -1 0 1
2 5 -2
4 -6 1
52
Frequency Domain
x(m, n) h(-1-m, -n)
0 -1 1 -1 1
-1 4 -1 1 1
0 -1 0
y(-1, 0) -1 0 1
2 5 -2
-1 4 -6 1
53
Frequency Domain
x(m, n) h(-1-m, 1-n)
0 -1 1 -1 1
-1 4 -1 1 1
0 -1 0
y(-1, 1) -1 0 1
-1 2 5 -2
-1 4 -6 1
54
Frequency Domain
x(m, n) h(-1-m, 2-n)
0 -1 1 -1 1
-1 4 -1 1 1
0 -1 0 0 0
y(-1, 2) 0 -1 0 1
-1 2 5 -2
-1 4 -6 1
55
Frequency Domain
x(m, n) h(-1-m, -1-n)
0 -1 1 -1 1
-1 4 -1 1 1
0 -1 0
y(-1, -1) 0 -1 0 1
-1 2 5 -2
-1 4 -6 1
0
56
Frequency Domain
x(m, n) h(-m, -1-n)
0 -1 1 -1 1
-1 4 -1 1 1
0 -1 0
y(0, -1) 0 -1 0 1
-1 2 5 -2
-1 4 -6 1
0 -1
57
Frequency Domain
x(m, n) h(1-m, -1-n)
0 -1 1 -1 1
-1 4 -1 1 1
0 -1 0
y(1, -1) 0 -1 0 1
-1 2 5 -2
-1 4 -6 1
0 -1 1
58
Frequency Domain
x(m, n) h(2-m, -1-n)
0 -1 1 0 -1 1
-1 4 -1 0 1 1
0 -1 0
y(2, -1) 0 -1 0 1
-1 2 5 -2
-1 4 -6 1
0 -1 1 0
59
Frequency Domain
x(m, n) h(-m, -n)
0 -1 1 -1 1
-1 4 -1 1 1
0 -1 0
y(m, n) 0 -1 0 1
-1 2 5 -2
-1 4 -6 1
0 -1 1 0
60

More Related Content

What's hot

Digital Image Fundamentals
Digital Image FundamentalsDigital Image Fundamentals
Digital Image Fundamentals
A B Shinde
 
Chapter 3 image enhancement (spatial domain)
Chapter 3 image enhancement (spatial domain)Chapter 3 image enhancement (spatial domain)
Chapter 3 image enhancement (spatial domain)
asodariyabhavesh
 
Chapter10 image segmentation
Chapter10 image segmentationChapter10 image segmentation
Chapter10 image segmentation
asodariyabhavesh
 
Image segmentation
Image segmentation Image segmentation
Image Enhancement in Spatial Domain
Image Enhancement in Spatial DomainImage Enhancement in Spatial Domain
Image Enhancement in Spatial Domain
A B Shinde
 
Region based segmentation
Region based segmentationRegion based segmentation
Region based segmentation
Inamul Hossain Imran
 
Image Enhancement using Frequency Domain Filters
Image Enhancement using Frequency Domain FiltersImage Enhancement using Frequency Domain Filters
Image Enhancement using Frequency Domain Filters
Karthika Ramachandran
 
Enhancement in spatial domain
Enhancement in spatial domainEnhancement in spatial domain
Enhancement in spatial domainAshish Kumar
 
Color Image Processing
Color Image ProcessingColor Image Processing
Color Image Processing
kiruthiammu
 
Image Enhancement in Spatial Domain
Image Enhancement in Spatial DomainImage Enhancement in Spatial Domain
Image Enhancement in Spatial Domain
DEEPASHRI HK
 
Homomorphic filtering
Homomorphic filteringHomomorphic filtering
Homomorphic filtering
Gautam Saxena
 
Histogram Processing
Histogram ProcessingHistogram Processing
Histogram Processing
Amnaakhaan
 
03 digital image fundamentals DIP
03 digital image fundamentals DIP03 digital image fundamentals DIP
03 digital image fundamentals DIP
babak danyal
 
Point processing
Point processingPoint processing
Point processing
panupriyaa7
 
5. gray level transformation
5. gray level transformation5. gray level transformation
5. gray level transformation
MdFazleRabbi18
 
Psuedo color
Psuedo colorPsuedo color
Psuedo color
Mariashoukat1206
 
Image Processing: Spatial filters
Image Processing: Spatial filtersImage Processing: Spatial filters
Image Processing: Spatial filters
A B Shinde
 
Image Representation & Descriptors
Image Representation & DescriptorsImage Representation & Descriptors
Image Representation & Descriptors
PundrikPatel
 
Simultaneous Smoothing and Sharpening of Color Images
Simultaneous Smoothing and Sharpening of Color ImagesSimultaneous Smoothing and Sharpening of Color Images
Simultaneous Smoothing and Sharpening of Color Images
Cristina Pérez Benito
 
Fundamentals and image compression models
Fundamentals and image compression modelsFundamentals and image compression models
Fundamentals and image compression models
lavanya marichamy
 

What's hot (20)

Digital Image Fundamentals
Digital Image FundamentalsDigital Image Fundamentals
Digital Image Fundamentals
 
Chapter 3 image enhancement (spatial domain)
Chapter 3 image enhancement (spatial domain)Chapter 3 image enhancement (spatial domain)
Chapter 3 image enhancement (spatial domain)
 
Chapter10 image segmentation
Chapter10 image segmentationChapter10 image segmentation
Chapter10 image segmentation
 
Image segmentation
Image segmentation Image segmentation
Image segmentation
 
Image Enhancement in Spatial Domain
Image Enhancement in Spatial DomainImage Enhancement in Spatial Domain
Image Enhancement in Spatial Domain
 
Region based segmentation
Region based segmentationRegion based segmentation
Region based segmentation
 
Image Enhancement using Frequency Domain Filters
Image Enhancement using Frequency Domain FiltersImage Enhancement using Frequency Domain Filters
Image Enhancement using Frequency Domain Filters
 
Enhancement in spatial domain
Enhancement in spatial domainEnhancement in spatial domain
Enhancement in spatial domain
 
Color Image Processing
Color Image ProcessingColor Image Processing
Color Image Processing
 
Image Enhancement in Spatial Domain
Image Enhancement in Spatial DomainImage Enhancement in Spatial Domain
Image Enhancement in Spatial Domain
 
Homomorphic filtering
Homomorphic filteringHomomorphic filtering
Homomorphic filtering
 
Histogram Processing
Histogram ProcessingHistogram Processing
Histogram Processing
 
03 digital image fundamentals DIP
03 digital image fundamentals DIP03 digital image fundamentals DIP
03 digital image fundamentals DIP
 
Point processing
Point processingPoint processing
Point processing
 
5. gray level transformation
5. gray level transformation5. gray level transformation
5. gray level transformation
 
Psuedo color
Psuedo colorPsuedo color
Psuedo color
 
Image Processing: Spatial filters
Image Processing: Spatial filtersImage Processing: Spatial filters
Image Processing: Spatial filters
 
Image Representation & Descriptors
Image Representation & DescriptorsImage Representation & Descriptors
Image Representation & Descriptors
 
Simultaneous Smoothing and Sharpening of Color Images
Simultaneous Smoothing and Sharpening of Color ImagesSimultaneous Smoothing and Sharpening of Color Images
Simultaneous Smoothing and Sharpening of Color Images
 
Fundamentals and image compression models
Fundamentals and image compression modelsFundamentals and image compression models
Fundamentals and image compression models
 

Similar to Histogram processing

Dip3
Dip3Dip3
Lect02.ppt
Lect02.pptLect02.ppt
Lect02.ppt
RaniaAzad
 
Histogram based enhancement
Histogram based enhancementHistogram based enhancement
Histogram based enhancement
liba manopriya.J
 
Histogram based Enhancement
Histogram based Enhancement Histogram based Enhancement
Histogram based Enhancement
Vivek V
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.ppt
SKILL2021
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.ppt
AkashVerma916093
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.ppt
nishashreyan1
 
05 histogram processing DIP
05 histogram processing DIP05 histogram processing DIP
05 histogram processing DIP
babak danyal
 
annotated-chap-3-gw.ppt
annotated-chap-3-gw.pptannotated-chap-3-gw.ppt
annotated-chap-3-gw.ppt
TharshninipriyaRajas
 
Lec_2_Digital Image Fundamentals.pdf
Lec_2_Digital Image Fundamentals.pdfLec_2_Digital Image Fundamentals.pdf
Lec_2_Digital Image Fundamentals.pdf
nagwaAboElenein
 
Lec_3_Image Enhancement_spatial Domain.pdf
Lec_3_Image Enhancement_spatial Domain.pdfLec_3_Image Enhancement_spatial Domain.pdf
Lec_3_Image Enhancement_spatial Domain.pdf
nagwaAboElenein
 
Histogram problem Ppt.pptx
Histogram problem Ppt.pptxHistogram problem Ppt.pptx
Histogram problem Ppt.pptx
DarshanAher5
 
G Intensity transformation and spatial filtering(1).ppt
G Intensity transformation and spatial filtering(1).pptG Intensity transformation and spatial filtering(1).ppt
G Intensity transformation and spatial filtering(1).ppt
deekshithadasari26
 
Ch 3. Image Enhancement in the Spatial Domain_okay.ppt
Ch 3. Image Enhancement in the Spatial Domain_okay.pptCh 3. Image Enhancement in the Spatial Domain_okay.ppt
Ch 3. Image Enhancement in the Spatial Domain_okay.ppt
nurulrahat02
 
Lect 03 - first portion
Lect 03 - first portionLect 03 - first portion
Lect 03 - first portion
Moe Moe Myint
 
Image processing second unit Notes
Image processing second unit NotesImage processing second unit Notes
Image processing second unit Notes
AAKANKSHA JAIN
 
Computer vision 3 4
Computer vision 3 4Computer vision 3 4
Computer vision 3 4
sachinmore76
 
SpatialEnhancement of course CE7491 of NTU
SpatialEnhancement of course CE7491 of NTUSpatialEnhancement of course CE7491 of NTU
SpatialEnhancement of course CE7491 of NTU
lyumingzhi
 

Similar to Histogram processing (20)

Dip3
Dip3Dip3
Dip3
 
Lect02.ppt
Lect02.pptLect02.ppt
Lect02.ppt
 
Histogram based enhancement
Histogram based enhancementHistogram based enhancement
Histogram based enhancement
 
Histogram based Enhancement
Histogram based Enhancement Histogram based Enhancement
Histogram based Enhancement
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.ppt
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.ppt
 
ModuleII.ppt
ModuleII.pptModuleII.ppt
ModuleII.ppt
 
05 histogram processing DIP
05 histogram processing DIP05 histogram processing DIP
05 histogram processing DIP
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
 
annotated-chap-3-gw.ppt
annotated-chap-3-gw.pptannotated-chap-3-gw.ppt
annotated-chap-3-gw.ppt
 
Lec_2_Digital Image Fundamentals.pdf
Lec_2_Digital Image Fundamentals.pdfLec_2_Digital Image Fundamentals.pdf
Lec_2_Digital Image Fundamentals.pdf
 
Lec_3_Image Enhancement_spatial Domain.pdf
Lec_3_Image Enhancement_spatial Domain.pdfLec_3_Image Enhancement_spatial Domain.pdf
Lec_3_Image Enhancement_spatial Domain.pdf
 
Histogram problem Ppt.pptx
Histogram problem Ppt.pptxHistogram problem Ppt.pptx
Histogram problem Ppt.pptx
 
G Intensity transformation and spatial filtering(1).ppt
G Intensity transformation and spatial filtering(1).pptG Intensity transformation and spatial filtering(1).ppt
G Intensity transformation and spatial filtering(1).ppt
 
Ch 3. Image Enhancement in the Spatial Domain_okay.ppt
Ch 3. Image Enhancement in the Spatial Domain_okay.pptCh 3. Image Enhancement in the Spatial Domain_okay.ppt
Ch 3. Image Enhancement in the Spatial Domain_okay.ppt
 
03raster 1
03raster 103raster 1
03raster 1
 
Lect 03 - first portion
Lect 03 - first portionLect 03 - first portion
Lect 03 - first portion
 
Image processing second unit Notes
Image processing second unit NotesImage processing second unit Notes
Image processing second unit Notes
 
Computer vision 3 4
Computer vision 3 4Computer vision 3 4
Computer vision 3 4
 
SpatialEnhancement of course CE7491 of NTU
SpatialEnhancement of course CE7491 of NTUSpatialEnhancement of course CE7491 of NTU
SpatialEnhancement of course CE7491 of NTU
 

More from Visvesvaraya National Institute of Technology, Nagpur, Maharashtra, India (9)

Wavelet transform
Wavelet transformWavelet transform
Wavelet transform
 
Spatial filtering
Spatial filteringSpatial filtering
Spatial filtering
 
Radon transform numerical & Fourier slice theorem
Radon transform numerical & Fourier slice theoremRadon transform numerical & Fourier slice theorem
Radon transform numerical & Fourier slice theorem
 
Pixel relationships
Pixel relationshipsPixel relationships
Pixel relationships
 
Morphological image processing
Morphological image processingMorphological image processing
Morphological image processing
 
Mathematical tools in dip
Mathematical tools in dipMathematical tools in dip
Mathematical tools in dip
 
Image transforms
Image transformsImage transforms
Image transforms
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Image restoration and reconstruction
Image restoration and reconstructionImage restoration and reconstruction
Image restoration and reconstruction
 

Recently uploaded

Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 

Recently uploaded (20)

Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 

Histogram processing

  • 1. DIGITAL IMAGE PROCESSING IMAGE ENHANCEMENT Histogram Processing by Dr. K. M. Bhurchandi
  • 2. Histogram Processing Histogram: It is a plot of frequency of occurrence of an event. freq. of occurrence 0 1 2 3 event 2
  • 3. Histogram Processing  Histogram of images provide a global description of their appearance.  Enormous information is obtained.  It is a spatial domain technique.  Histogram of an image represents relative frequency of occurrence of various gray levels.  Histogram can be plotted in two ways: 3
  • 4. Histogram Processing  First Method:  X-axis has gray levels & Y-axis has No. of pixels in each gray levels. nk Gray Level No. of Pixels (nk) 40 0 40 30 1 20 2 10 3 15 20 4 10 5 3 6 2 10 0 1 2 3 4 5 6 Gray Levels 4
  • 5. Histogram Processing  Second Method:  X-axis has gray levels & Y-axis has probability of occurrence of gray levels. P(µk) = nk / n; where, µk – gray level nk – no. of pixels in kth gray level n – total number of pixels in an image Prob. Of Occurrence 1 0.8 Gray Level No. of Pixels (nk) P(µk) 0.7 0 40 0.4 0.6 1 20 0.2 0.5 2 10 0.1 0.4 3 15 0.15 0.3 4 10 0.1 0.2 5 3 0.03 0.1 6 2 0.02 n = 100 1 0 1 2 3 4 5 6 µk 5
  • 6. Histogram Processing  Advantage of 2nd method: Maximum value plotted will always be 1.  White – 1, Black – 0.  Great deal of information can be obtained just by looking at histogram.  Types of Histograms: P(µk) P(µk) 0 rk 0 rk P(µk) P(µk) 0 rk 0 rk 6
  • 7. Histogram Processing  Advantage of 2nd method: Maximum value plotted will always be 1.  White – 1, Black – 0.  Great deal of information can be obtained just by looking at histogram.  Types of Histograms: P(µk) Dark Image P(µk) Bright Image 0 rk 0 rk P(µk) Low Contrast Image P(µk) Equalized Image 0 rk 0 rk 7
  • 8. Histogram Processing  The last graph represent the best image.  It is a high contrast image.  Our aim would be to transform the first 3 histograms into the 4th type.  In other words we try to increase the dynamic range of the image.  Normalized histogram is nothing but PDF (Probability Density Function) of an image. 8
  • 9. Histogram Stretching 1) Linear stretching:  Here, we don’t alter the basic shape.  We use basic equation of a straight line having a slope. (Smax - Smin)/(rmax - rmin) Where, Smax – max gray level of output image Smin – min gray level of output image rmax – max gray level of input image rmin – min gray level of input image 0 min max 0 min max 9
  • 10. Histogram Processing 𝑆 = 𝑇 𝑟 = 𝑆𝑚𝑎𝑥 − 𝑆𝑚𝑖𝑛 𝑟𝑚𝑎𝑥 − 𝑟𝑚𝑖𝑛 𝑟 − 𝑟𝑚𝑖𝑛 + 𝑆𝑚𝑖𝑛 Smax Smin rmin rmax 10
  • 11. Histogram Processing Ex. 1) Perform Histogram Stretching so that the new image has a dynamic range of 0 to 7 [0, 7]. Gray Levels 0 1 2 3 4 5 6 7 No. of Pixels 0 0 50 60 50 20 10 0 11
  • 12. Histogram Processing Ex. 1) Perform Histogram Stretching so that the new image has a dynamic range of 0 to 7 [0, 7]. Gray Levels 0 1 2 3 4 5 6 7 No. of Pixels 0 0 50 60 50 20 10 0 Soln:- rmin = 2; rmax = 6; smin = 0; smax = 7; slope = ((smax – smin)/(rmax - rmin)) = ((7 - 0)/(6 - 2)) = 7 / 4 = 1.75. S = (7 / 4)(r - 2) + 0; r (7 / 4)(r - 2) = S S = (7 / 4)(r - 2) 2 0 = 0 3 7/4 = 1.75 = 2 4 7/2 = 3.5 = 4 5 21/4 = 5.25 = 5 6 7 = 7 12
  • 13. Histogram Processing Ex. 1) Perform Histogram Stretching so that the new image has a dynamic range of 0 to 7 [0, 7]. Gray Levels 0 1 2 3 4 5 6 7 No. of Pixels 50 0 60 0 50 20 0 10 60 60 50 50 40 40 30 30 20 20 10 10 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 Original Histogram Stretched Histogram 13
  • 14. Histogram Processing Ex. 2) Perform Histogram Stretching so that the new image has a dynamic range of 0 to 7 . Gray Levels 0 1 2 3 4 5 6 7 No. of Pixels 100 90 85 70 0 0 0 0 14
  • 15. Histogram Processing Ex. 2) Perform Histogram Stretching so that the new image has a dynamic range of 0 to 7 . Gray Levels 0 1 2 3 4 5 6 7 No. of Pixels 100 0 90 0 0 85 0 70 Dynamic range increases BUT No. of pixels at each gray level remains constant. 15
  • 16. Histogram Equalization 2) Histogram Equalization: o Linear stretching is a good technique but not perfect since the shape remains the same. o Most of the time we need a flat histogram. o It can’t be achieved by Histogram Stretching. o Thus, the technique of Histogram Equalization came into use. o Perfect image is one where all gray levels have equal number of pixels. o Here, our objective is not only to spread the dynamic range but also to have equal pixels at all gray levels. o It is used to enhance visual content of image. 16
  • 17. Histogram Equalization nk Normal Histogram r nk Equalized Histogram nk Linearly Stretched Histogram S S 17
  • 18. Histogram Equalization o We have to search for a transform that converts any random histogram into flat histogram. o S = T(r) o We have to find ‘T’ which produces equal values in each gray levels. o The Transform should satisfy following 2 conditions: (i) T(r) must be single value & monotonically increasing in the interval, 0 ≤ r ≤ 1. (ii) 0 ≤ T(r) ≤ 1 for 0 ≤ r ≤ 1 0 ≤ S ≤ 1 for 0 ≤ r ≤ 1 Here, range of r is [0, 1] (Normalized range) instead of [0, 255]. 18
  • 19. Histogram Equalization These two conditions mean: 1) If T(r) is not single value: S T(r) S T(r) S2 S1 S1 r1 r2 r r1 r2 r fig. (a) fig. (b) 19
  • 20. Histogram Equalization  In fig.(a) r1 & r2 are mapped as single gray level i.e. S1.  Two different gray levels occupy same in modified image.  Big Drawback, If reconstruction is required.  Hence, transformation has to be single value.  This preserves order from black to white.  A gray level transformation with single value and monotonically increasing is shown in fig.(b). 2) If condition (ii) is not satisfied then mapping will not be consistent with the allowed range of pixel value.  S will go beyond the valid range. 20
  • 21. Histogram Equalization  Since, the Transformation is single value & monotonically increasing, the inverse Transformation exists. r = T-1(S) ; 0 ≤ S ≤ 1  Gray levels for continuous variables can be characterized by their probability density Pr(r) & Ps(S).  From Probability theory, we know that,  If Pr(r) & Ps(S) are known & if T-1(S) satisfies condition (i) then the probability density of the transferred gray level is Ps(S) = Pr(r). |dr/ ds| ----(a) Prob. Density (Transformed Image) = Prob. Density (Original Image) x inv. Slope of transformation 21
  • 22. Histogram Equalization  Now lets find a transform which would give us a flat histogram.  Cumulative Density Function (CDF) is preferred.  CDF is obtained by simply adding up all the PDF’s. S = T(r) r S = (L - 1) ʃ Pr(w) dw 0 diff. wrt. r ds / dr = (L - 1) Pr(r) ---------(b) Equating eqn(a) & eqn(b), we get Ps(s) = 1 / L - 1 ; 0 ≤ S ≤ L - 1 22
  • 23. Histogram Equalization  A bad Histogram becomes a flat histogram when we find the CDF. Pr(r) Ps(s) A 1/L-1 0 L - 1 f 0 L - 1 S Non-Uniform Function Uniform Function CDF Pr(r) dr 23
  • 24. Histogram Equalization  NOTE: If an image has MxN pixels, then PDF is given by: Pr(rk) = nk / MN; Where, nk – no. of pixels with intensity rk k = 0, 1, 2, …….., L-1 In continuous domain, r S = T(r) = (L-1)ʃ Pr(w) dw 0 In discrete domain, k Sk = T(rk) = (L - 1)Σ Pr(rj) (CDF) j=0 24
  • 25. Histogram Equalization Prob. 1) Equalize the given histogram Gray Levels (r) 0 1 2 3 4 5 6 7 No. of Pixels 790 1023 850 656 329 245 122 81 nk 1000 900 800 700 600 500 400 300 200 100 0 1 2 3 4 5 6 7 r 25
  • 26. Histogram Equalization Gray Levels (rk) No. of Pixels nk (PDF) Pr(rk) = nk/n (CDF) Sk = Σ Pk(rk) (L-1) Sk = 7 x Sk Rounding off 0 790 0.19 0.19 1.33 1 1 1023 0.25 0.44 3.08 3 2 830 0.21 0.65 4.55 5 3 656 0.16 0.81 5.67 6 4 329 0.08 0.89 6.23 6 5 245 0.06 0.95 6.65 7 6 122 0.03 0.98 6.86 7 7 81 0.02 1 7 7 n = 4096 1 Equating Gray Levels to No. of Pixels: 0 -> 0 4 -> 0 1 -> 790 5 -> 850 2 -> 0 6 -> 985 3 -> 1023 7 -> 448 Total : 4096 Hence Verified!!! 26
  • 27. Histogram Equalization Equalized Histogram: Gray Levels (S) 0 1 2 3 4 5 6 7 No. of Pixels 0 790 0 1023 0 850 985 448 Total: 4096 nk 1000 900 800 700 600 500 400 300 200 100 0 1 2 3 4 5 6 7 r 27
  • 28. Histogram Equalization Prob. 2) Equalize the given histogram Gray Levels (r) 0 1 2 3 4 5 6 7 No. of Pixels 100 90 50 20 0 0 0 0 nk 100 90 80 70 60 50 40 30 20 10 0 1 2 3 4 5 6 7 r 28
  • 29. Histogram Equalization Prob. 3) Equalize the above histogram twice. Gray Levels (r) 0 1 2 3 4 5 6 7 No. of Pixels 0 0 0 100 0 90 50 20 nk 100 90 80 70 60 50 40 30 20 10 0 1 2 3 4 5 6 7 r 29
  • 30. Histogram Equalization Prob. 3) Equalize the above histogram twice. Gray Levels (r) 0 1 2 3 No. of Pixels 70 20 7 3 nk 100 90 80 70 60 50 40 30 20 10 0 1 2 3 r 30
  • 31. Histogram Equalization Prob. 1) What effect would setting to zero the lower order bit plane have on the histogram of an image shown? 0 1 2 3 no. of 4 5 6 7 pixels 1 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 no. of levels 31
  • 32. Histogram Equalization Prob. 1) What effect would setting to zero the lower order bit plane have on the histogram of an image shown? 0 1 2 3 4 5 6 7 8 9 10 11 0000 0001 0010 0011 12 13 14 15 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 32
  • 33. Histogram Equalization Prob. 1) What effect would setting to zero the lower order bit plane have on the histogram of an image shown? 0 1 2 3 4 5 6 7 8 9 10 11 0000 0001 0010 0011 12 13 14 15 0100 0101 0110 0111 1000 1001 1010 1011 0000 0000 0000 0000 1100 1101 1110 1111 0100 0100 0100 0100 1000 1000 1000 1000 1100 1100 1100 1100 Setting lower order bit plane to zero. 33
  • 34. Histogram Equalization Prob. 1) What effect would setting to zero the lower order bit plane have on the histogram of an image shown? 0 0 0 0 0 1 2 3 4 4 4 4 4 5 6 7 8 8 8 8 8 9 10 11 0000 0001 0010 0011 12 12 12 12 12 13 14 15 0100 0101 0110 0111 1000 1001 1010 1011 0000 0000 0000 0000 1100 1101 1110 1111 0100 0100 0100 0100 1000 1000 1000 1000 1100 1100 1100 1100 Setting lower order bit plane to zero. 34
  • 35. Histogram Equalization Prob. 1) What effect would setting to zero the lower order bit plane have on the histogram of an image shown? 0 0 0 0 0 1 2 3 4 4 4 4 4 5 6 7 8 8 8 8 8 9 10 11 12 12 12 12 12 13 14 15 0000 0000 0000 0000 4 0100 0100 0100 0100 1000 1000 1000 1000 1100 1100 1100 1100 no. of pixels no. of levels 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 35
  • 36. Histogram Equalization Prob. 2) What effect would setting to zero the higher order bit plane have on the histogram of an image shown? Comment on the image. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 36
  • 37. Histogram Equalization Prob. 3) Given below is the slope transformation & the image. Draw the frequency tables for the original & the new image. Assume Imin=0, Imax = 7 2 3 4 2 5 5 2 4 I 3 6 3 5 Imax 6 3 5 5 Imin mmin mmax µ 37
  • 38. Frequency Domain 2-D Discrete Fourier Transform & Its Inverse: If f(x, y) is a digital image of size M X N then its Fourier Transform is given by: M-1 N-1 F(u, v) = f(x, y) e -j2π(ux/M + vy/N) -----------(1) x=0 y=0 for u = 0, 1, 2, ……., M-1 & v = 0, 1, 2, …….., N-1. Given the transform F(u, v), we can obtain f(x, y) by using Inverse discrete Fourier Transform (IDFT): M-1 N-1 f(x, y) = (1/MN) Σ Σ F(u, v) e j2π(ux/M + vy/N) ------------(2) u=0 v=0 for x = 0, 1, 2, ….M-1 & y = 0, 1, 2, ….., N-1 Eqn. (1) & (2) constitute the 2-D discrete Fourier transform pair. 38 Σ Σ
  • 39. Frequency Domain 2-D convolution Theorem: The expression of circular convolution is extended for 2-D is given below: M-1 N-1 f(x, y)*h(x, y) = Σ Σ f(m, n)h(x-m, y-n) -----------(3) m=0 n=0 for x = 0, 1, 2, ….M-1 & y = 0, 1, 2, …..N-1 The 2-D convolution theorem is given by the expressions f(x, y) ¤ h(x, y) F(u, v) x H(u, v) --------------(4) and conversely f(x, y) x h(x, y) F(u, v) ¤ H(u, v) ---------------(5) 39
  • 40. Frequency Domain Prob 4) Find the convolution of an image x(m, n) & h(m, n) shown in the fig. below: y(p, q) = x(m1, n1) ¤ h(m2, n2) 0 -1 1 1 1 -1 4 -1 1 -1 2x2 (m, n) 0 -1 0 3x3 (m, n) 40
  • 41. Frequency Domain Prob 4) Find the convolution of an image x(m, n) & h(m, n) shown in the fig. below: y(p, q) = x(m1, n1) ¤ h(m2, n2) 0 -1 1 1 1 -1 4 -1 1 -1 origin 2x2 (m2, n2) 0 -1 0 3x3 (m1, n1) p = m1 + m2 -1 q = n1 + n2 -1 = 3 + 2 -1 = 3 + 2 -1 = 4 columns = 4 rows Resultant image dimension is 4x4. 41
  • 42. Frequency Domain x(m, n) h(m, n) 0 -1 1 1 1 -1 4 -1 1 -1 0 -1 0 h(m, -n) h(-m, -n) 1 1 -1 1 -1 1 1 1 42
  • 43. Frequency Domain x(m, n) h(-m, -n) 0 -1 1 -1 4 -1 -1 1 0 -1 0 1 1 y(0, 0) 4 43
  • 44. Frequency Domain x(m, n) h(1-m, -n) 0 -1 1 -1 4 -1 -1 1 0 -1 0 1 1 4 -6 y(1, 0) 44
  • 45. Frequency Domain x(m, n) h(2-m, -n) 0 -1 1 -1 4 -1 0 -1 1 0 -1 0 0 1 1 4 -6 1 y(2, 0) 45
  • 46. Frequency Domain x(m, n) h(3-m, -n) 0 -1 1 -1 4 -1 0 0 -1 1 0 -1 0 0 0 1 1 4 -6 1 0 y(3, 0) 46
  • 47. Frequency Domain x(m, n) h(-m, 1-n) 0 -1 1 -1 1 -1 4 -1 1 1 0 -1 0 2 4 -6 1 y(0, 1) 47
  • 48. Frequency Domain x(m, n) h(-m, 2-n) 0 -1 1 -1 1 -1 4 -1 1 1 0 -1 0 0 0 -1 2 4 -6 1 y(0, 2) 48
  • 49. Frequency Domain x(m, n) h(1-m, 1-n) 0 -1 1 -1 4 -1 -1 1 0 -1 0 1 1 y(1, 1) -1 2 5 4 -6 1 49
  • 50. Frequency Domain x(m, n) h(1-m, 2-n) 0 -1 1 -1 1 -1 4 -1 1 1 0 -1 0 0 0 y(1, 2) -1 0 2 5 4 -6 1 50
  • 51. Frequency Domain x(m, n) h(2-m, 1-n) 0 -1 1 -1 4 -1 0 -1 1 0 -1 0 0 1 1 y(2, 1) -1 0 2 5 -2 4 -6 1 51
  • 52. Frequency Domain x(m, n) h(2-m, 2-n) 0 -1 1 0 -1 1 -1 4 -1 0 1 1 0 -1 0 0 0 0 y(2, 2) -1 0 1 2 5 -2 4 -6 1 52
  • 53. Frequency Domain x(m, n) h(-1-m, -n) 0 -1 1 -1 1 -1 4 -1 1 1 0 -1 0 y(-1, 0) -1 0 1 2 5 -2 -1 4 -6 1 53
  • 54. Frequency Domain x(m, n) h(-1-m, 1-n) 0 -1 1 -1 1 -1 4 -1 1 1 0 -1 0 y(-1, 1) -1 0 1 -1 2 5 -2 -1 4 -6 1 54
  • 55. Frequency Domain x(m, n) h(-1-m, 2-n) 0 -1 1 -1 1 -1 4 -1 1 1 0 -1 0 0 0 y(-1, 2) 0 -1 0 1 -1 2 5 -2 -1 4 -6 1 55
  • 56. Frequency Domain x(m, n) h(-1-m, -1-n) 0 -1 1 -1 1 -1 4 -1 1 1 0 -1 0 y(-1, -1) 0 -1 0 1 -1 2 5 -2 -1 4 -6 1 0 56
  • 57. Frequency Domain x(m, n) h(-m, -1-n) 0 -1 1 -1 1 -1 4 -1 1 1 0 -1 0 y(0, -1) 0 -1 0 1 -1 2 5 -2 -1 4 -6 1 0 -1 57
  • 58. Frequency Domain x(m, n) h(1-m, -1-n) 0 -1 1 -1 1 -1 4 -1 1 1 0 -1 0 y(1, -1) 0 -1 0 1 -1 2 5 -2 -1 4 -6 1 0 -1 1 58
  • 59. Frequency Domain x(m, n) h(2-m, -1-n) 0 -1 1 0 -1 1 -1 4 -1 0 1 1 0 -1 0 y(2, -1) 0 -1 0 1 -1 2 5 -2 -1 4 -6 1 0 -1 1 0 59
  • 60. Frequency Domain x(m, n) h(-m, -n) 0 -1 1 -1 1 -1 4 -1 1 1 0 -1 0 y(m, n) 0 -1 0 1 -1 2 5 -2 -1 4 -6 1 0 -1 1 0 60