UPDATED ImageProcessing3-ImageEnhancement(HistogramProcessing) (2)

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 38

Digital Image Processing

Image Enhancement
(Histogram Processing)
Image Histograms
The histogram of an image shows us the distribution of grey
levels in the image
Massively useful in image processing, especially in
segmentation
Frequencies

Grey Levels
Theory of Histogram
Theory of Histogram
Theory of Histogram
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Histogram Examples
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Histogram Examples (cont…)


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Histogram Examples (cont…)


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Histogram Examples (cont…)


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Histogram Examples (cont…)


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Histogram Examples (cont…)


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Histogram Examples (cont…)


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Histogram Examples (cont…)


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Histogram Examples (cont…)


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Histogram Examples (cont…)


Histogram Examples (cont…)
A selection of images and
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

their histograms
Notice the relationships
between the images and
their histograms
Note that the high contrast
image has the most
evenly spaced histogram
Contrast Stretching
We can fix images that have poor contrast by applying a
pretty simple contrast specification
The interesting part is how do we decide on this
transformation function?
Histogram Equalisation
Spreading out the frequencies in an image (or equalising the
image) is a simple way to improve dark or washed out
images
The formula for histogram
equalisation is given where
r :
k input intensity sk  T (rk )
s : processed intensity k
  pr ( r j )
k
k: the intensity range
(e.g 0.0 – 1.0) j 1
n : the frequency of intensity j
j
k nj

n: the sum of all frequencies

j 1 n
Example
19

No. of pixels

6
2 3 3 2
5
4 2 4 3 4

3 2 3 5 3

2
2 4 2 4
1
Gray level
4x4 image
0 1 2 3 4 5 6 7 8 9
Gray scale = [0,9]
histogram
Example

Gray
0 1 2 3 4 5 6 7 8 9
Level(j)

No. of
0 0 6 5 4 1 0 0 0 0
pixels
k

n
j 0
j 0 0 6 11 15 16 16 16 16 16

k nj 6 11 15 16 16 16 16 16
s 0 0 / / / / / / / /
j 0 n 16 16 16 16 16 16 16 16

3.3 6.1 8.4


sx9 0 0 9 9 9 9 9
3 6 8
Example
2 3 3 2
21

No. of pixels 4 2 4 3
6
3 2 3 5
3 6 6 3 5
2 4 2 4
8 3 8 6 4

6 3 6 9 3

2
3 8 3 8
1
Output image
0 1 2 3 4 5 6 7 8 9
Gray scale = [0,9] Gray level
Histogram equalization
Image Enhancement by Point Processing
 Histogram Equalization Example
Intensity 0 1 2 3 4 5 6 7
Number of pixels 10 20 12 8 0 0 0 0
p (0)  10 / 50  0.2
p (1)  20 / 50  0.4
p (2)  12 / 50  0.24
p (3)  8 / 50  0.16
p (r )  0 / 50  0, r  4,5, 6, 7
 r 
T (r )  round  7 p (i ) 
 i 0 
T (0)  round  7 * p(0)   round  7 *0.2   1
T (1)  round  7 *  p(0)  p(1)   round  7 *0.6   4
T (2)  round  7 *  p(0)  p(1)  p(2)   round  7 *0.84   6
T (3)  round  7 *  p(0)  p(1)  p(2)  p(3)   7
T (r )  7, r  4,5, 6, 7

Intensity 0 1 2 3 4 5 6 7
Number of pixels 0 10 0 0 20 0 12 8

22
Book example
Note
24

It is clearly seen that


Histogram equalization distributes the gray level to reach
the maximum gray level (white) because the cumulative
distribution function equals 1 when 0  r  L-1
If the cumulative numbers of gray levels are slightly
different, they will be mapped to little different or same
gray levels as we may have to approximate the processed
gray level of the output image to integer number
Thus the discrete transformation function can’t guarantee
the one to one mapping relationship
Histogram Matching (Specification)
25

Histogram equalization has a disadvantage which is that it


can generates only one type of output image.
With Histogram Specification, we can specify the shape of
the histogram that we wish the output image to have.
It doesn’t have to be a uniform histogram
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Equalisation Transformation Function


Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Equalisation Examples
1
Equalisation Transformation Functions
The functions used to equalise the images in the previous
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Equalisation Examples
2
Equalisation Transformation Functions
The functions used to equalise the images in the previous
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Equalisation Examples (cont…)

4
3
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

Equalisation Examples (cont…)

4
3
Equalisation Transformation Functions
The functions used to equalise the images in the previous
Images taken from Gonzalez & Woods, Digital Image Processing (2002)

examples
Summary
We have looked at:
Different kinds of image enhancement
Histograms
Histogram equalisation

Next time we will start to look at point processing and


some neighbourhood operations

You might also like