1
Digital Image Processing
Lecture # 5 Spatial & Frequency Domain Image Enhancement
Sharpening Spatial Filters
Previously we have looked at smoothing filters which remove
fine detail
Sharpening spatial filters seek to highlight fine detail
Remove blurring from images
Highlight edges
Sharpening filters are based on spatial differentiation
Spatial Differentiation
• Let’s consider a simple 1 dimensional
example
Spatial Differentiation
A B
1st Derivative
The 1st derivative of a function is given by:
Its just the difference between subsequent
values and measures the rate of change of
the function
)()1( xfxfx
f
Image Strip
0
1
2
3
4
5
6
7
8
1st Derivative
-8
-6
-4
-2
0
2
4
6
8
5 5 4 3 2 1 0 0 0 6 0 0 0 0 1 3 1 0 0 0 0 7 7 7 7
-1 -1 -1 -1 -1 0 0 6 -6 0 0 0 1 2 -2 -1 0 0 0 7 0 0 0
1st Derivative
2nd Derivative
The 2nd derivative of a function is given by:
Simply takes into account the values both before and after the current value
)(2)1()1(2
2
xfxfxfx
f
Image Strip
0
1
2
3
4
5
6
7
8
5 5 4 3 2 1 0 0 0 6 0 0 0 0 1 3 1 0 0 0 0 7 7 7 7
2nd Derivative
2nd Derivative
-15
-10
-5
0
5
10
-1 0 0 0 0 1 0 6 -12 6 0 0 1 1 -4 1 1 0 0 7 -7 0 0
2nd Derivative for Image Enhancement
The 2nd derivative is more useful for image enhancement
than the 1st derivative - Stronger response to fine detail
We will come back to the 1st order derivative later on
The first sharpening filter we will look at is the Laplacian
Laplacian Filter
2
2
2
22
y
f
x
ff
),(2),1(),1(2
2
yxfyxfyxfx
f
The Laplacian is defined as follows:
),(2)1,()1,(2
2
yxfyxfyxfy
f
Laplacian Filter
So, the Laplacian can be given as follows:
),1(),1([2 yxfyxff
)]1,()1,( yxfyxf
),(4 yxf
0 1 0
1 -4 1
0 1 0
Can we implement it using a filter/ mask?
Laplacian Filter
Laplacian Filter
Applying the Laplacian to an image we get a
new image that highlights edges and other
discontinuities
Original
Image
Laplacian
Filtered Image
Laplacian
Filtered Image
Scaled for Display
Laplacian Image Enhancement
The result of a Laplacian filtering is not an
enhanced image
Laplacian
Filtered Image
Scaled for Display 2
5
2
5
( , ) , 0( , )
( , ) , 0
f x y f wg x y
f x y f w
To generate the final enhanced image
Laplacian Image Enhancement
In the final sharpened image edges and fine
detail are much more obvious
- =
Original
Image
Laplacian
Filtered Image
Sharpened
Image
Laplacian Image Enhancement
Simplified Image Enhancement
• The entire enhancement can be combined
into a single filtering operation
),1(),1([),( yxfyxfyxf
)1,()1,( yxfyxf
)],(4 yxf
fyxfyxg 2),(),(
Simplified Image Enhancement
• The entire enhancement can be combined
into a single filtering operation
fyxfyxg 2),(),(
),1(),1(),(5 yxfyxfyxf
)1,()1,( yxfyxf0 -1 0
-1 5 -1
0 -1 0
Simplified Image Enhancement
• This gives us a new filter which does the
whole job for us in one step
0 -1 0
-1 5 -1
0 -1 0
Unsharp Masking
Use of first derivatives for image enhancement: The Gradient
• The gradient of a function f(x,y) is defined as
y
fx
f
G
G
y
xf
-1 -2 -1
0 0 0
1 2 1
-1 0 1
-2 0 2
-1 0 1
Extract horizontal edges
7 8 9 1 2 3
3 6 9 1 4 7
( 2 ) ( 2 )
( 2 ) ( 2 )
f z z z z z z
z z z z z z
Emphasize more the current point
(y direction)
Emphasize more the current point (x
direction) Pixel Arrangement
Gradient Operators
Extract vertical edges
Sobel Operator
Sobel Operator: Example
Sobel filters are typically used for edge
detection
An image of a
contact lens
which is
enhanced in
order to make
defects more
obvious
Combining Spatial Enhancement Methods
Successful image enhancement is
typically not achieved using a single
operation
Rather we combine a range of
techniques in order to achieve a final
result
This example will focus on enhancing
the bone scan
Laplacian filter of
bone scan (a)
Sharpened version of
bone scan achieved
by subtracting (a)
and (b) Sobel filter of bone
scan (a)
(a)
(b)
(c)
(d)
Combining Spatial Enhancement Methods
Combining Spatial Enhancement Methods
The product of (c)
and (e) which will be
used as a mask
Sharpened image
which is sum of (a)
and (f)
Result of applying a
power-law trans. to
(g)
(e)
(f)
(g)
(h)
Image (d) smoothed with
a 5*5 averaging filter
Combining Spatial Enhancement Methods
Compare the original and final images
Image Enhancement in Frequency Domain
31
Joseph Fourier (1768 – 1830)
– Most famous for his work “La Théorie Analitique de la Chaleur” published in 1822
– Translated into English in 1878: “The Analytic Theory of Heat”
Nobody paid much attention when the work was first published One of the most important mathematical theories in modern engineering
32
The big idea …
=
Any function that periodically repeats itself can be expressed as a sum of sines and cosines of different frequencies each multiplied by a different coefficient – a Fourier series
33
The big idea…
Approximating a square wave as the sum of sine waves
36
Frequencies in Images
37
The Discrete Fourier Transform (DFT)
The Discrete Fourier Transform of f(x, y), for x = 0, 1, 2…M-1 and y = 0,1,2…N-1, denoted by F(u, v), is given by the equation:
for u = 0, 1, 2…M-1 and v = 0, 1, 2…N-1.
1
0
1
0
)//(2),(),(M
x
N
y
NvyMuxjeyxfvuF
38
DFT & Images
DFT
Scanning electron microscope
image of an integrated circuit
magnified ~2500 times
Fourier spectrum of the image
39
40
41
The Inverse DFT
It is really important to note that the Fourier transform is completely reversible
The inverse DFT is given by:
for x = 0, 1, 2…M-1 and y = 0, 1, 2…N-1
1
0
1
0
)//(2),(1
),(M
u
N
v
NvyMuxjevuFMN
yxf
42
The DFT and Image Processing
To filter an image in the frequency domain: 1. Compute F(u,v) the DFT of the image 2. Multiply F(u,v) by a filter function H(u,v) 3. Compute the inverse DFT of the result
43
Some Basic Frequency Domain Filters
Low Pass Filter
High Pass Filter
44
Ideal Low Pass Filter
Simply cut off all high frequency components that are a specified distance D0 from the origin
46
Ideal Low Pass Filter (cont…)
Above we show an image, it’s Fourier spectrum and a series of ideal low pass filters of radius 5, 15, 30, 80 and 230 superimposed on top of it
47
Ideal Low Pass Filter (cont…)
48
Ideal Low Pass Filter (cont…)
49
Original
image
Result of filtering
with ideal low
pass filter of
radius 5
Result of filtering
with ideal low
pass filter of
radius 30
Result of filtering
with ideal low
pass filter of
radius 230
Result of filtering
with ideal low
pass filter of
radius 80
Result of filtering
with ideal low
pass filter of
radius 15
60
Ideal High Pass Filters
The ideal high pass filter is given as:
61
Results of ideal
high pass filtering
with D0 = 15
Results of ideal
high pass filtering
with D0 = 30
Results of ideal
high pass filtering
with D0 = 80
Readings from Book (3rd Edn.)
• Sharpening Filters • Frequency Analysis • Filters in Frequency Domain
69
Acknowledgements
Digital Image Processing”, Rafael C. Gonzalez & Richard E. Woods, Addison-Wesley, 2002
Peters, Richard Alan, II, Lectures on Image Processing, Vanderbilt University, Nashville, TN, April 2008
Brian Mac Namee, Digitial Image Processing, School of Computing, Dublin Institute of Technology
Computer Vision for Computer Graphics, Mark Borg
Mat
eria
l in
th
ese
slid
es h
as b
een
tak
en f
rom
, th
e fo
llow
ing
reso
urc
es