You are on page 1of 29

Digital Image Processing, 2nd ed.

www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: Image Enhancement:
INTRODUCTION
I- GOALS OF IMAGE ENHANCEMENT
Better visual quality for human analysis
Facilitate further image processing
II- SPATIAL DOMAIN PROCESSING
Processing directly the pixels of the image
Single pixel or neighborhood of pixels is processed
Statistical model of gray levels used
Linear or Nonlinear types of processing
Corresponding frequency domain interpretation is possible
III- FOURIER/FREQUENCY DOMAIN PROCESSING
Explicitly process the image in the frequency domain (DFT)
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: Spatial Processing:
NEIGHBORHOOD OF (x,y)
Masks or filters operate on
neighborhoods of input image
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: IMAGE AVERAGING (set-up)
Problem: Image has additive noise
Advantage: Multiple images are available
(assumed to be aligned)
Noise mode: zero-mean, uncorrelated
Recall: Variance is reduced
2
) , (
2
) , (
1
1
; ) , ( )} , ( {
) , (
1
) , (
) , ( ) , ( ) , (
y x y x g
K
i
i
i i
K
y x f y x g E
y x g
K
y x g
y x y x f y x g
q
o o
q
= =
=
+ =

=
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: IMAGE AVERAGING (Example)
Simulated Example:
Add Gaussian Noise (Std=60)
Orig., Noisy Image
Average of 8, 16 images
Average of 64, 128 images
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3:IMAGE AVERAGING (differences)
Diff. = Original - Averaged
(8, 16, 64, 128 images)
NOTE: non-zero mean
due to negative noise values
and scaling for display (?)
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: SPATIAL DOMAIN FILTERING
Mask
Image neighborhood
under the mask
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3:MASK COEFFICIENTS. and
CONVOLUTION EQUATION
s
t
1 ,... 2 , 1 . 0 ; 1 ,..., 1 , 0
) , ( ) , (
) , ( ) , ( ) , (
= =
=
+ + =


= =
= =
N y M x
t y s x f t s w
t y s x f t s w y x g
a
a s
b
b t
a
a s
b
b t
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: Example Filter Masks,
Border Effects
1 ) , ( : =

= =
a
a s
b
b t
t s w Note
Implementation Issue: (x,y) near borders, alternatives:
Avoid non-overlap, zero-extension, constant extension,
replicate rows & columns, symmetric extension, etc.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: Smoothing Filter Masks for
Weighted Averaging
1 ,... 2 , 1 . 0 ; 1 ,..., 1 , 0
) , ( ) , ( ) , (
= =
+ + =

= =
N y M x
t y s x f t s w y x g
a
a s
b
b t
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: EXAMPLE OF SMOOTHING/AVERAGING
Filter Mask Sizes Used:
3x3, 5x5, 9x9, 15x15, 35x35
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: Use of Spatial Smoothing before
thresholding
Gross detail is preserved
Apply threshold of 25% of maximum gray level
Small objects do not survive the processing
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Implementing neigborghood operations
MATLAB example
% assume a 3x3 mask and anMxMimage
% zero pad extension of image
Xe = X;
Xe = [ zeros(1,M); X; zeros(1,M)];
Xe = [zeros(N+2,1) Xe zeros(N+2,1)];
%output image
Ye = zeros(size(Xe);
%for loops to move over the image
for n = 2:N+1
for m = 2:M+1
%for loops to implement 2-D mask
new_value = 0;
for i = -1:1
for j=-1:1
new_value = new_value + mask(i+2,j+2)*Xe( n+i, m+j) ;
end
end
Ye(n,m) = new_value;
end
end
%remove padding
Y = Ye(2:N+1,2:M+1);
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: Order-Statistics, Median Filters
1 ,... 2 , 1 , 0 ; 1 ,..., 1 , 0
} ] , [ ], , [ : ) , ( { ) , (
= =
e e + + =
N y M x
b b t a a s t y s x f median y x g
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: Order-Statistics, Median Filters - II
1 ,... 2 , 1 , 0 ; 1 ,..., 1 , 0
} ] , [ ], , [ : ) , ( { ) , (
= =
e e + + =
N y M x
b b t a a s t y s x f median y x g
Properties of Median Filter:
Nonlinear Operation
Replace outliers (impulsive noise, salt-pepper noise) with
typical gray level value
Often preserves edge discontinuities (vs. mean filter)
Other Order-Statistics Filters:
X percentile (vs. 50%) rank
Max filter (100%)
Min filter (0%)
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: Intro. to Derivative Operations
Typical responses for
1
st
and 2
nd
derivative
operators in 1-D
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: Intro. to Derivative Operations - II
Discrete derivate operators for 1-D
| | | |
) 1 ( ) ( 2 ) 1 (
) 1 ( ) ( ) ( ) 1 (
) ( ) 1 (
2
2
+ + =
+ =
c
c
+ =
c
c
x f x f x f
x f x f x f x f
x
f
x f x f
x
f
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: Intro. to Derivative Operations - III
Discrete derivate operators for 2-D
Laplacian
y
y x f
x
y x f
f
y x f y x f y x f
y
y x f
y x f y x f y x f
x
y x f
y x f y x f
y
y x f
y x f y x f
x
y x f
2
2
2
2
2
2
2
2
2
) , ( ) , (
) 1 , ( ) , ( 2 ) 1 , (
) , (
) , 1 ( ) , ( 2 ) , 1 (
) , (
) , ( ) 1 , (
) , (
) , ( ) , 1 (
) , (
c
c
+
c
c
= V
+ + =
c
c
+ + =
c
c
+ =
c
c
+ =
c
c
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: Re-Visit Derivative Operations
Typical responses for
1
st
and 2
nd
derivative
operators in 1-D
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: Use of Laplacian for Enhancement
+
-
) , ( 4 ) 1 , (
) 1 , ( ) , 1 ( ) , 1 (
2
y x f y x f
y x f y x f y x f f
+
+ + + + = V
90

45

Digital Image Processing, 2nd ed.


www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: Application of Laplacian for
Enhancement
f y x f y x g
2
) , ( ) , ( V =
Original plus high-pass filtered
(Laplacian with negative
center value in the mask)
) 1 , ( ) 1 , ( ) , 1 (
) , 1 ( ) , ( 5 ) , (
+
+ =
y x f y x f y x f
y x f y x f y x g
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: Comparison of 2 Laplacian Masks
for Enhancement with Combined Masks
4+1
8+1
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: Unsharp Masking and High-Boost
Filtering
) , ( ) , ( ) , ( y x f y x f y x f
s
=
Unsharp Masking: Original Blurred Version
High-Boost: A x Original Blurred Version (A>1)
| |
) , ( ) , (
) , ( ) , ( ) , ( ) 1 (
) , ( ) , ( ) , ( ) 1 (
) , ( ) , ( ) , (
2
2
y x f y x Af
y x f y x f y x f A
y x f y x f y x f A
y x f y x Af y x f
hb
V =
V + =
+ =
=
) , ( ) , ( ) , ( y x f y x Af y x f
hb
=
Using Laplacian: Blurred=Original Sharpened Image
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: Unsharp Masking and High-Boost
Filtering
) , ( ) , ( ) , ( y x f y x f y x f
s
=
Unsharp Masking: Original Blurred Version
) , ( ) , ( ) , (
2
y x f y x Af y x f
hb
V =
High-Boost Using Laplacian:
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: Example: Unsharp, High-Boost
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: Use of First Derivatives for
Enhancement: Gradient Vector, Gradient
.
2 / 1
2
2
approx common G G f
y
f
x
f
f
G
G
y
f
y
f
f
y x
y
x
+ ~ V
|
|
.
|

\
|
|
|
.
|

\
|
c
c
+
|
.
|

\
|
c
c
= V =>
(

(
=
(
(
(
(

(
c
c
c
c
= V


Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: Masks for First Partial Derivatives
Roberts
Operators
Sobel
Operators
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Chapter 3: Example use of Gradient
Use Gradient for preprocessing before automated inspection
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods