Image Enhancement
Image Enhancement
Image Enhancement
Image Enhancement
Image Enhancement
◼ The objective of image enhancement is to process an
image so that the result is more suitable than the
original image for a specific application.
◼ There are two main approaches:
❑ Image enhancement in spatial domain: Direct manipulation
of pixels in an image
◼ Point processing: Change pixel intensities
◼ Spatial filtering
❑ Image enhancement in frequency domain: Modifying the
Fourier transform of an image
Bahadir K. Gunturk 2
Image Enhancement by Point Processing
◼ Intensity Transformation
Bahadir K. Gunturk 3
Image Enhancement by Point Processing
◼ Contrast Stretching
Bahadir K. Gunturk 4
Image Enhancement by Point Processing
◼ Contrast Stretching
T (r ) = c log(1 + r )
Bahadir K. Gunturk 5
Image Enhancement by Point Processing
◼ Intensity Transformation
Bahadir K. Gunturk 6
Image Enhancement by Point Processing
◼ Intensity Transformation
Bahadir K. Gunturk 7
Image Enhancement by Point Processing
◼ Intensity Transformation
Bahadir K. Gunturk 8
Image Enhancement by Point Processing
◼ Gray-Level Slicing
Bahadir K. Gunturk 9
Image Enhancement by Point Processing
◼ Histogram
p(r )
0 r 255
Bahadir K. Gunturk 12
Histogram Specification
◼ Intensity mapping
s = T (r )
◼ Assume
❑ T(r) is single-valued and monotonically increasing.
❑ 0 T (r ) 1 and 0 r 1
pr (r )
ps ( s )
Bahadir K. Gunturk 13
Histogram Specification
◼ The relationship between the PDFs is
dr
ps ( s ) = pr (r )
p (s)ds = p (r )dr = 1
s r
ds r =T −1 ( s )
r
ds d
=
dr dr w=0
pr ( w)dw = pr (r )
1
ps ( s ) = pr (r ) = 1, 0 s 1 Histogram equalization!
pr (r ) r =T −1 ( s )
Bahadir K. Gunturk 14
Image Enhancement by Point Processing
◼ Histogram Equalization
Number of pixels with intensity i r
T (r ) = round 255
Total number of pixels
r
Number of pixels with intensity i
= round 255
i = 0 Total number of pixels
r
= round 255 p (i )
i =0
0 r 255
Bahadir K. Gunturk 15
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
Bahadir K. Gunturk 16
Image Enhancement by Point Processing
◼ Histogram Equalization
Bahadir K. Gunturk 17
Histogram Specification
◼ Intensity mapping
s = T (r )
◼ Assume
❑ T(r) is single-valued and monotonically increasing.
❑ 0 T (r ) 1 and 0 r 1
pr (r )
ps ( s )
Bahadir K. Gunturk 18
Histogram Specification
◼ The relationship between the PDFs is
dr
ps ( s ) = pr (r )
ds r =T −1 ( s )
r
ds d
=
dr dr w=0
pr ( w)dw = pr (r )
1
ps ( s ) = pr (r ) = 1, 0 s 1 Histogram equalization!
pr (r ) r =T −1 ( s )
Bahadir K. Gunturk 19
Histogram Specification
◼ Example
−2r + 2, for 0 r 1
Assume pr (r ) =
0, elsewhere
r = T −1 ( s ) = 1 1 − s = 1 − 1 − s
Bahadir K. Gunturk 20
Histogram Specification
◼ Example
dr
ps ( s ) = pr (r )
= (−2r + 2)
ds r =T −1 ( s )
(d
ds
)
1− 1− s
r =1− 1− s
(
= 2 1− s
) 1
=1
2 1− s
1
2 1− s
Bahadir K. Gunturk 21
Histogram Specification
◼ Assume we have a desired PDF pz ( z )
◼ Let the following be the equalization mappings
r
s = T (r ) =
w= 0
pr ( w)dw
z
v = G( z) =
w=0
pz ( w)dw
z = G −1 (T (r ) )
Bahadir K. Gunturk 22
Histogram Specification
Bahadir K. Gunturk 23
Histogram Specification
Bahadir K. Gunturk 24
Histogram Specification
Bahadir K. Gunturk 25
Histogram Specification
Bahadir K. Gunturk 26
Local Histogram Processing
◼ Histogram processing can be applied locally.
Bahadir K. Gunturk 27
Image Subtraction
g ( x , y ) = f ( x, y ) − h ( x, y )
Bahadir K. Gunturk 28
Image Averaging
g ( x , y ) = f ( x, y ) + n ( x, y )
1
2
i ( x, y) =
M M
1 1 2
E ni ( x , y ) = 2
E n 2
M
i =1
M i =1 M
Bahadir K. Gunturk 29
Image Averaging
Bahadir K. Gunturk 30
Spatial Filtering
1 1 1
1
1 1 1 A low-pass filter
9
1 1 1
1 1 1
1 −8 1 A high-pass filter
1 1 1
Bahadir K. Gunturk 31
Spatial Filtering
◼ Median Filter
10 20 10
25 10 75
Sort: (10 10 10 20 25 75 85 90 100)
90 85 100
◼ Example
Original signal: 100 100 100 100 10 10 10 10 10
Filter by 1x3
100 100 100 10 10 10 10
median filter:
Bahadir K. Gunturk 32
Spatial Filtering
◼ Median filters are nonlinear.
◼ Median filtering reduces noise without blurring edges and
other sharp details.
◼ Median filtering is particularly effective when the noise
pattern consists of strong, spikelike components. (Salt-and-
pepper noise.)
Bahadir K. Gunturk 33
Spatial Filtering
Original Salt&Pepper
noise added
3x3 3x3
averaging median
filter filter
Bahadir K. Gunturk 34
Spatial Filtering
Bahadir K. Gunturk 35
Spatial Filtering
◼ Gradient Operators
❑ Averaging of pixels over a region tends to blur detail in an
image.
❑ As averaging is analogous to integration, differentiation can
be expected to have the opposite effect and thus sharpen an
image.
❑ Gradient operators (first-order derivatives) are commonly
used in image processing applications.
Bahadir K. Gunturk 36
Spatial Filtering
◼ Gradient Operators
Bahadir K. Gunturk 37
Spatial Filtering
◼ Laplacian Operators
❑ Laplacian operators are second-order derivatives.
Bahadir K. Gunturk 38
Spatial Filtering
−1 −1 −1
−1 8 −1
−1 −1 −1
Bahadir K. Gunturk 39
Spatial Filtering
◼ High-boost or high-frequency-emphasis filter
❑ Sharpens the image but does not remove the low-frequency
components unlike high-pass filtering
Bahadir K. Gunturk 40
Spatial Filtering
◼ High-boost or high-frequency-emphasis filter
Bahadir K. Gunturk 41
Spatial Filtering
−1 −1 −1 −1 −1 −1
−1 8 −1 −1 9 −1
−1 −1 −1 −1 −1 −1
Bahadir K. Gunturk 42
Spatial Filtering
◼ High-boost or high-frequency-emphasis filter
Bahadir K. Gunturk 43
Spatial Filtering
Bahadir K. Gunturk 44