![Page 1: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/1.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 1
Gray level histograms
0 50 100 150 200 2500
0.5
1
1.5
2
2.5
3
3.5
4 x 104
gray level
#pix
els
Brain image
![Page 2: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/2.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 2
Gray level histograms
0 50 100 150 200 2500
0.5
1
1.5
2
2.5
3
3.5 x 104
gray level
#pix
els
Bay image
![Page 3: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/3.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 3
Gray level histogram in viewfinder
![Page 4: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/4.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 4
Gray level histograms
To measure a histogram: 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 can be thought of as an estimate of the probability distribution of the continuous signal amplitude
Use fewer, larger bins to trade off amplitude resolution against sample size.
![Page 5: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/5.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 5
???
Which of the following operations does NOT change the histogram of the image? a) Adjusting γ to change contrast
b) Flipping the image horizontally
c) Adding a constant value to all pixels
d) Changing the size of the image by omitting every other row and column
![Page 6: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/6.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 6
Histogram equalization Idea:
Find a non-linear transformation
that is applied to each pixel of the input image f [x,y], such that a uniform
distribution of gray levels results for the output image g[x,y].
g = T f( )
![Page 7: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/7.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 7
Analyse ideal, continuous case first ...
Histogram equalization
Assume
Normalized input values and output values T(f) is differentiable, increasing, and invertible, i.e., there exists
0 ≤ f ≤ 1
f = T −1 g( )
0 ≤ g ≤ 1
0 ≤ g ≤ 1
0 ≤ g ≤ 1
Goal: pdf pg(g) = 1 over the entire range
![Page 8: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/8.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 8
Histogram equalization for continuous case
From basic probability theory
Consider the transformation function
Then . . .
pg g( )= pf f( )dfdg
f =T −1 g( )
g = T f( )= pf α( )0
f
∫ dα 0 ≤ f ≤ 1
dgdf
= pf f( )
pg g( )= pf f( )dfdg
f =T −1 g( )= pf f( ) 1
pf f( )
f =T −1 g( )
= 1 0 ≤ g ≤ 1
T f( )f gp f f( )
![Page 9: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/9.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 9
???
Which nonlinearity would you apply to the amplitude of a signal to achieve histogram equalization? a) Integral of the reciprocal of the pdf of the signal b) cdf of the signal c) Inverse of the cdf of the signal
What conditions must hold? ① The pdf of the signal may not be zero anywhere in the input signal range ② The pdf of the signal has to be finite everywhere in the input signal range ③ None of the above
![Page 10: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/10.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 10
Histogram equalization for discrete case
Now, f only assumes discrete amplitude values with empirical probabilities
Discrete approximation of
The resulting values gk are in the range [0,1] and might have to be scaled and rounded appropriately.
g = T f( )= pf α( )0
f
∫ dα
gk = T fk[ ]= Pii=0
k
∑ for k = 0,1..., L −1
pixel count for amplitude fl
![Page 11: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/11.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 11
Histogram equalization example
Original image Bay ... after histogram equalization
![Page 12: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/12.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 12
Histogram equalization example
0 50 100 150 200 2500
0.5
1
1.5
2
2.5
3
3.5 x 104 Original image Bay . . . after histogram equalization
gray level
#pix
els
gray level
#pix
els
0 50 100 150 200 2500
0.5
1
1.5
2
2.5
3
3.5 x 104
![Page 13: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/13.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 13
Histogram equalization example
Original image Brain ... after histogram equalization
![Page 14: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/14.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 14
0 50 100 150 200 2500
0.5
1
1.5
2
2.5
3
3.5
4 x 104
Histogram equalization example
0 50 100 150 200 2500
0.5
1
1.5
2
2.5
3
3.5
4 x 104 Original image Brain . . . after histogram equalization
gray level
#pix
els
gray level
#pix
els
![Page 15: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/15.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 15
???
After histogram equalization, the number of non-zero bins (a) can increase
(b) usually decreases (c) can either increase or decrease (d) usually stays the same
![Page 16: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/16.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 16
Histogram equalization example
Original image Moon ... after histogram equalization
![Page 17: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/17.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 17
Histogram equalization example
0 50 100 150 200 2500
2
4
6
8
10
12x 104
0 50 100 150 200 2500
2
4
6
8
10
12 x 104Original image Moon . . . after histogram equalization
gray level
#pix
els
gray level
#pix
els
![Page 18: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/18.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 18
Contrast-limited histogram equalization
no clipping
#pix
els
Input gray level Input gray level
Out
put g
ray
leve
l
0.7
0.7
0.4 0.4
0.1 0.1
![Page 19: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/19.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 19
Adaptive histogram equalization Histogram equalization based on a histogram obtained from a portion of the image
[Pizer, Amburn et al. 1987]
Sliding window approach: different histogram (and mapping) for every pixel
Tiling approach: subdivide into overlapping regions, mitigate blocking effect by smooth blending between neighboring tiles
Limit contrast expansion in flat regions of the image,
e.g., by clipping histogram values. (“Contrast-limited adaptive histogram equalization”)
![Page 20: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/20.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 20
Adaptive histogram equalization Original image
Parrot
Adaptive histogram equalization, 8x8 tiles
Global histogram equalization
Adaptive histogram equalization, 16x16 tiles
![Page 21: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/21.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 21
Adaptive histogram equalization Original image
Dental Xray Global histogram equalization
Adaptive histogram equalization, 8x8 tiles
Adaptive histogram equalization, 16x16 tiles
![Page 22: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/22.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 22
Adaptive histogram equalization Original image
Skull Xray Global histogram equalization
Adaptive histogram equalization, 8x8 tiles
Adaptive histogram equalization, 16x16 tiles
![Page 23: Gray level histograms - Stanford Universityweb.stanford.edu/.../Lectures/2013_Spring/4-Histograms_16x9.pdf · Histogram equalization based on a histogram obtained from a portion of](https://reader030.vdocuments.site/reader030/viewer/2022021521/5b55be887f8b9adf7d8bb9d8/html5/thumbnails/23.jpg)
Digital Image Processing: Bernd Girod, © 2013 Stanford University -- Histograms 23
???
Which technique is computationally the most demanding? (a) Global histogram equalization
(b) Adaptive histogram equalization with a 16x16 sliding window (c) Adaptive histogram equalization with 16x16 tiles