Gray Level Histograms: Histogram

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

Gray level histograms

4
x 10 Histogram Brain image
4

3.5

#pixels 3

2.5

1.5

0.5

0
0 50 100 150 200 250
gray level

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 1
4
x 10
3.5
Gray level histograms
x310
4
3.5
2.5
3
2
2.5
1.5
2
#pixels

1
1.5
0.5 Bay image
1
0
0.5 0 50 100 150 200 250

0
0 50 100 150 200 250
gray level

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 2
Gray level histogram in viewfinder

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 3
Gray level histograms
n  To measure a histogram:
l  For B-bit image, initialize 2B counters with 0
l  Loop over all pixels x,y
l  When encountering gray level f [x,y]=i, increment counter #i
n  Normalized histogram can be thought of as an estimate of the probability
distribution of the continuous signal amplitude
n  Use fewer, larger bins to trade off amplitude resolution against sample size.

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 4
Histogram equalization
Idea:


Find a non-linear transformation

g=T(f)
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].

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 5
Histogram equalization

Analyse ideal, continuous case first ...

Assume
l  Normalized input values 0 ≤ f ≤ 1 and output values 0 ≤ g ≤ 1

l  T( f ) is differentiable, increasing, and invertible, i.e., there exists

f = T −1 (g ) 0 ≤ g ≤1

Goal: pdf pg(g) = const over the entire range 0 ≤ g ≤ 1

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 6
Histogram equalization for continuous case
n  From basic probability theory
f g ⎡ df ⎤
pf ( f ) T(f) pg (g ) = ⎢ p f ( f ) ⎥
⎣ dg ⎦ f =T −1 (g)
n  Consider the transformation function

g = T ( f ) = ∫ p f (α ) dα
f
0 ≤ f ≤1
0

dg
n  Then . . . = pf ( f )
df
⎡ df ⎤ ⎡ 1 ⎤
pg (g ) = ⎢ p f ( f ) ⎥ = ⎢ pf ( f ) ⎥ =1 0 ≤ g ≤1
⎣ dg ⎦ f =T −1 (g) ⎢⎣ p f ( f )⎥⎦ −1
f =T (g )

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 7
Histogram equalization for discrete case

n  Now, f only assumes discrete amplitude values f0 , f1,, fL−1 with empirical
probabilities
n0 n1 nL−1
P0 = P1 = ! PL−1 = where n is total number of pixels
n n n
Discrete approximation of g = T ( f ) = p f (α ) dα
f
n 
∫ 0
k
gk = T [ fk ] = ∑ Pi for k = 0,1..., L − 1
i=0

n  The resulting values gk are in the range [0,1] and might have to
be scaled and rounded appropriately.

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 8
Histogram equalization example

Original image Bay ... after histogram equalization

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 9
Histogram equalization example
Original image Bay . . . after histogram equalization

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 10
Histogram equalization example

Original image Brain ... after histogram equalization

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 11
Histogram equalization example
Original image Brain
44
. . . after histogram equalization
44
x x10
10 x x10
10
44 44

3.5
3.5 3.5
3.5

33 33

2.5
2.5 2.5
2.5

22 22

#pixels
#pixels

1.5
1.5 1.5
1.5

11 11

0.5
0.5 0.5
0.5

00 00
00 50
50 100
100 150
150 200
200 250
250 00 50
50 100
100 150
150 200
200 250
250
gray level gray level

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 12
Histogram equalization example

Original image Moon ... after histogram equalization

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 13
Histogram equalization example
Original image Moon
4
. . . after histogram equalization
4
x 10 x 10
12 12

10 10

8 8

#pixels

#pixels
6 6

4 4

2 2

0 0
0 50 100 150 200 250 0 50 100 150 200 250
gray level gray level

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 14
Contrast-limited histogram equalization

Output gray level


no clipping
0.7
#pixels
0.7
0.4 0.4

0.1 0.1

Input gray level Input gray level

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 15
Adaptive histogram equalization
n  Histogram equalization based on a histogram obtained from a portion of the image

Sliding window approach:
 Tiling approach:



different histogram (and subdivide into overlapping
mapping) for every pixel regions, mitigate blocking
effect by smooth blending
between neighboring tiles

n  Limit contrast expansion in flat regions of the image,



e.g., by clipping histogram values. 

(“Contrast-limited adaptive histogram equalization”)
[Pizer, Amburn et al. 1987]

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 16
Adaptive histogram equalization
Original image Global histogram
Parrot equalization

Adaptive histogram Adaptive histogram


equalization, 8x8 tiles equalization, 16x16 tiles

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 17
Adaptive histogram equalization
Original image Global histogram
Dental Xray equalization

Adaptive histogram Adaptive histogram


equalization, 8x8 tiles equalization, 16x16 tiles

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 18
Adaptive histogram equalization
Original image Global histogram
Skull Xray equalization

Adaptive histogram Adaptive histogram


equalization, 8x8 tiles equalization, 16x16 tiles

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 19
Ansel Adam’s Zone System (1939)
full tonal gradation

11-step gradation

histogram of 11 zones à not quite flat

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 20
Ansel Adams, The Tetons and Snake River, 1942

Digital Image Processing: Bernd Girod, Gordon Wetzstein © 2013-2016 Stanford University -- Histograms 21

You might also like