Professional Documents
Culture Documents
Lecture # 5
Spatial Enhancement-II
1
Image Enhancement
2
Histogram of a Grayscale Image
3
Histogram of a Grayscale Image
Black marks
pixels with
intensity g
Plot of histogram:
number of pixels with intensity g
4
Histogram of a Grayscale Image
Black marks
pixels with
intensity g
Plot of histogram:
number of pixels with intensity g
5
Histogram of a Grayscale Image
6
Histogram of a Color Image
IfIfIIisisaa3-band
3-bandimageimage
then
thenI(r,c,b)
I(r,c,b) isisan
aninteger
integer between
between00and
and255.
255.
II has
has33histograms:
histograms:
hhR(g) = # of pixels in I(:,:,1) with intensity value g
R(g) = # of pixels in I(:,:,1) with intensity value g
hhG(g)
(g)==##of
ofpixels
pixelsininI(:,:,2)
I(:,:,2) with
withintensity
intensityvalue
valuegg
G
hhB(g) = # of pixels in I(:,:,3) with intensity value g
B(g) = # of pixels in I(:,:,3) with intensity value g
7
Histogram of a Color Image
There
Thereisisone
onehisto-
histo-
gram
gramper
percolor
colorband
band
R,
R,G,
G,&&B.
B.Luminosity
Luminosity
histogram
histogramisisfrom
from11
band
band==(R+G+B)/3
(R+G+B)/3
8
Histogram: Example
Dark Image
Bright Image
9
Histogram: Example
Dark image
Components of
histogram are
concentrated on
the low side of
the gray scale
Bright image
Components of
histogram are
concentrated on
the high side of
the gray scale
10
HISTOGRAM INSIGHT INTO CONTRAST
11
Histogram: Example
12
Histogram: Example
14
Contrast Stretching
255
L 1
s T (r ) (r rmin )
r r
127
max min
0
0 rmin 127 rmax255
15
Contrast Stretching
16
Histogram Equalization
Histogram equalization re-assigns the intensity values of pixels in the input image
such that the output image contains a uniform distribution of intensities
17
HISTOGRAM EQUALIZATION
18
AERIAL PHOTOGRAPH OF THE PENTAGON
Then, This is
This is the
the probability
probability
1 that an
that an arbitrary
arbitrary pixel
pixel
pI g hI g
A from II has
from has value
value g.
g.
20
The Probability Distribution Function
of an Image
•• p(g)
p(g)isisthe
thefraction
fractionof
of pixels
pixelsin
inan
animage
imagethat
thathave
have
intensity
intensityvalue
value g.
g.
•• p(g)
p(g)isisthe
theprobability
probabilitythat
thataapixel
pixelrandomly
randomlyselected
selected
from
fromthethegiven
givenimage
imagehashasintensity
intensityvalue
value g.
g.
•• Whereas
Whereasthe thesum
sumofofthe
thehistogram
histogram h(g)
h(g)over
overall
all gg from
from
00to
to 255
255isis equal
equaltotothe
thenumber
numberof ofpixels
pixelsininthe
theimage,
image,
the
thesum
sumofof p(g)
p(g)over
overall
all gg isis 1.
1.
•• ppisisthe
the normalized
normalizedhistogram
histogram of
ofthe
theimage
image
21
The Cumulative Distribution Function
of an Image
Let q = I(r,c) be the value of a randomly
selected pixel from I. Let g be a specific gray
level. The probability that q ≤ g is given by
g
1 g
h
I
PI g pI hI 0
255
,
A 0
0
0
h
I
22
The Cumulative Distribution Function
of an Image
Let q = I(r,c) be the value of a randomly
selected pixel from I. Let g be a specific gray Alsocalled
Also calledCDF
CDF
level. The probability that q ≤ g is given by for“Cumulative
for “Cumulative
Distribution
Distribution
g
Function”.
Function”.
g
1 g
h
I
PI g pI hI 0
255
,
A 0
0
0
h
I
23
The Cumulative Distribution Function
of an Image
•• P(g)
P(g) isisthe
thefraction
fractionof
ofpixels
pixelsininananimage
imagethat
that have
haveintensity
intensity
values
values less
less than
thanor
orequal
equaltoto g.
g.
•• P(g)
P(g) isisthe
theprobability
probabilitythat
thataapixel
pixelrandomly
randomlyselected
selectedfrom
from
the
the given
givenbandbandhas
hasananintensity
intensityvalue
valueless
lessthan
thanor
or equal
equalto
to
g.
g.
•• P(g)
P(g) isisthe
thecumulative
cumulative(or
(orrunning)
running) sum
sum of
of p(g)
p(g) from
from00
through
through gginclusive.
inclusive.
•• P(0)
P(0) == p(0)
p(0) and
and P(255)
P(255)== 1;
1;
24
Histogram Equalization
Let PI
be the cumulative (probability) distribution function of I.
25
Histogram Equalization
TheCDF
The CDF(cumulative
(cumulative
distribution)isisthe
distribution) the
pdf
LUTfor
LUT forremapping.
remapping.
CDF
26
Histogram Equalization
TheCDF
The CDF(cumulative
(cumulative
distribution)isisthe
distribution) the
pdf
LUTfor
LUT forremapping.
remapping.
LUT
27
Histogram Equalization
TheCDF
The CDF(cumulative
(cumulative
distribution)isisthe
distribution) the
pdf
LUTfor
LUT forremapping.
remapping.
LUT
28
Histogram Equalization
29
Histogram Equalization
Luminosity
before
J r , c 255 PI I r , c .
after
30
HISTOGRAM EQUALIZATION
IMPLEMENTATION
0 0 0 0 0
1 1 1 1 4
4 5 6 6 6
8 8 8 8 9
31
HISTOGRAM EQUALIZATION
IMPLEMENTATION
0 0 0 0 0 2 2 2 2 2
1 1 1 1 4 4 4 4 4 5
4 5 6 6 6 5 5 7 7 7
8 8 8 8 9 9 9 9 9 9
Gray levels 0 1 2 3 4 5 6 7 8 9
Counts (h(rk)) 5 4 0 0 2 1 3 0 4 1
r0 r1 r2 r3 r4 r5 r6
sk =round(9•F(rk)) 2 4 5 5 7 9 9
s0 s1 s2 s3 s4 s5 s6
32
Histogram Equalization: Example
Equalized
EqualizedHistogram
Histogram
34
Histogram Equalization: Example
Equalized
EqualizedHistogram
Histogram
contrast
Lowcontrast
Low Contrast
HighContrast
High
Equalized
EqualizedHistogram
Histogram
35
HISTOGRAM MATCHING
(SPECIFICATION)
• HISTOGRAM EQUALIZATION DOES NOT ALLOW
INTERACTIVE IMAGE ENHANCEMENT AND
GENERATES ONLY ONE RESULT: AN
APPROXIMATION TO A UNIFORM HISTOGRAM.
• SOMETIMES THOUGH, WE NEED TO BE ABLE TO
SPECIFY PARTICULAR HISTOGRAM SHAPES
CAPABLE OF HIGHLIGHTING CERTAIN GRAY-LEVEL
RANGES.
36
HISTOGRAM SPECIFICATION
• THE PROCEDURE FOR HISTOGRAM-SPECIFICATION BASED
ENHANCEMENT IS:
k nj
s T (rk )
j 0 n
k
vk G z k p z z i s k
i 0
38
HISTOGRAM SPECIFICATION
39
MAPPINGS
40
HISTOGRAM SPECIFICATION
41
HISTOGRAM SPECIFICATION
k nk pr(rk) sk pz(zk) vk nk
0 790 0.19 0.19 0 0 0
1 1023 0.25 0.44 0 0 0
2 850 0.21 0.65 0 0 0
3 656 0.16 0.81 0.15 0.15 790
4 329 0.08 0.89 0.2 0.35 1023
5 245 0.06 0.95 0.3 0.65 850
6 122 0.03 0.98 0.2 0.85 985
7 81 0.02 1.0 0.15 1.0 448
43
GLOBAL/LOCAL HISTOGRAM EQUALIZATION
45
USE OF HISTOGRAM STATISTICS FOR IMAGE
ENHANCEMENT (Global)
• LET r REPRESENT A GRAY LEVEL IN THE IMAGE [0, L-1], AND LET p(ri )
DENOTE THE NORMALIZED HISTOGRAM COMPONENT
CORRESPONDING TO THE ith VALUE OF r.
• THE nth MOMENT OF r ABOUT ITS MEAN IS DEFINED AS
L 1 n
n r ri m p ri
i 0
• WHERE m IS THE MEAN VALUE OF r (AVERAGE GRAY LEVEL)
m i 0 ri p ri
L 1
46
USE OF HISTOGRAM STATISTICS FOR IMAGE
ENHANCEMENT (Global)
• THE SECOND MOMENT IS GIVEN BY
L 1 2
2 r ri m p ri
i 0
47
USE OF HISTOGRAM STATISTICS FOR IMAGE
ENHANCEMENT (Local)
• LET (x,y) BE THE COORDINATES OF A PIXEL IN AN
IMAGE, AND LET SX,Y DENOTE A NEIGBORHOOD OF
SPECIFIED SIZE, CENTERED AT (x,y)
• THE MEAN VALUE mSXY OF THE PIXELS IN SX,Y IS
ms xy r s ,t p rs ,t
s ,t
S xy
r
ms xy p rs ,t
2 2
S xy s ,t
s ,t S xy
48
USE OF HISTOGRAM STATISTICS FOR IMAGE
ENHANCEMENT
• THE GLOBAL MEAN AND VARIANCE ARE MEASURED
OVER AN ENTIRE IMAGE AND ARE USEFUL FOR
GROSS ADJUSTMENTS OF OVERALL INTENSITY AND
CONTRAST.
• A USE OF THESE MEASURES IN LOCAL
ENHANCEMENT IS, WHERE THE LOCAL MEAN AND
VARIANCE ARE USED AS THE BASIS FOR MAKING
CHANGES THAT DEPEND ON IMAGE
CHARACTERISTICS IN A PREDEFINED REGION ABOUT
EACH PIXEL IN THE IMAGE.
49
TUNGSTEN FILAMENT IMAGE
50
USE OF HISTOGRAM STATISTICS FOR IMAGE ENHANCEMENT
51
IMAGE ENHANCEMENT IN THE
SPATIAL DOMAIN
52
IMAGE ENHANCEMENT IN THE
SPATIAL DOMAIN
53
Readings from Book (3 Edn.)
rd
• 3.3 Histogram
Acknowledgements
Statistical Pattern Recognition: A Review – A.K Jain et al., PAMI (22) 2000
Material in these slides has been taken from, the following resources
55