Professional Documents
Culture Documents
3.4. Sharpening Spatial Filtering
3.4. Sharpening Spatial Filtering
Contact: kalpoma@aust.com
Google Class code: o5sjihh
◼ Highlight edges
of a function.
DIP, Spring 2012 GS & AS, Bahria University, Islambad
Spatial Differentiation
Let’s consider a simple 1 dimensional example
A B
f
= f ( x + 1) − f ( x)
x
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 01st 0Derivative
0 1 2 -2 -1 0 0 0 7 0 0 0
8
6
4
2
0
-2
-4
-6
-8
f 2
= f ( x + 1) + f ( x − 1) − 2 f ( x)
x
2
8
2nd Derivative
7
6
5
4
3
2
1
0
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 0 0 0 0 1 0 6 -12 6 0 0 1 1 -4 1 1 0 0 7 -7 0 0
2nd Derivative
10
-5
-10
-15
1. LAPLACIAN
• Use of 2nd Derivative for Image Enhancement
We can implement it 1 -4 1
using this filter.
0 1 0
DIP, Spring 2012 GS & AS, Bahria University, Islambad
Types of Laplacian Kernels
+ =
- =
Original Laplacian Sharpened
Image Filtered Image Image
g ( x, y) = f ( x, y) − f 2
= f ( x, y) − [ f ( x + 1, y) + f ( x −1, y)
0 1 0 + f ( x, y + 1) + f ( x, y −1)
1 -4 1
w w w
− 4 f ( x, y )]
1
0 1 0 2 3
f ( x, y ) − 2 f , w5 0
w4 w5 w6
g ( x, y ) =
DIP, Spring 2012
w7 w8 w9 f ( x, y ) + 2 f , w5 0
GS & AS, Bahria University, Islambad
Simplified Image Enhancement
The entire enhancement or sharpening can
be done in one PASS.
g ( x, y) = f ( x, y) − f 2
= 5 f ( x, y) − f ( x + 1, y) − f ( x −1, y)
0 -1 0
− f ( x, y + 1) − f ( x, y −1)
-1 5 -1 We can implement it
0 -1 0 using this filter.
DIP, Spring 2012 GS & AS, Bahria University, Islambad
Simplified Image Enhancement
0 -1 0
-1 5 -1
0 -1 0
0 1 0 1 1 1
-1 -1 -1
-1 9 -1
-1 -1 -1
DIP, Spring 2012 GS & AS, Bahria University, Islambad
Use of 1st Derivatives for Image
Enhancement
-1 -2 -1 -1 0 1
0 0 0 -2 0 2
1 2 1 -1 0 1
Gx, Extract horizontal edges Gy, Extract vertical edges
f ( z7 + 2 z8 + z9 ) − ( z1 + 2 z2 + z3 )
+ ( z3 + 2 z6 + z9 ) − ( z1 + 2 z4 + z7 )
Pixel Arrangement
Prewitt Operator
❑ is used for detecting edges horizontally and vertically.
f ( z7 + z8 + z9 ) − ( z1 + z2 + z3 )
+ ( z3 + z6 + z9 ) − ( z1 + z4 + z7 )
Pixel Arrangement
-1 -1 -1 -1 0 1
f f
= 0 0 0 = -1 0 1
x y
1 1 1 -1 0 1
Extract horizontal edges Extract vertical edges
DIP, Spring 2012 Gx GS & AS, Bahria University, Islambad Gy
Sobel Operator: Example
An image of a
contact lens
which is
enhanced in
order to make
defects more
obvious
35
DIP, Spring 2012 GS & AS, Bahria University, Islambad 2016/1/27
Source: D. Lowe
Sharpening with Sobel
Operator
1 0 -1
2 0 -2
1 0 -1
Sobel
Vertical Edge
DIP, Spring 2012 GS & AS, Bahria University, Islambad
(absolute value)
2016/1/27
36
Sharpening with Sobel
Operator
1 2 1
0 0 0
-1 -2 -1
Sobel
Horizontal Edge
DIP, Spring 2012 GS & AS, Bahria University, Islambad
(absolute value)
2016/1/27
37
Sharpening Spatial Filters
Laplacian Sobel
(a)
Laplacian filter of
bone scan (a)
(b)
Sharpened version of
bone scan achieved (c)
by subtracting (a)
and (b) Sobel filter of bone
scan (a) (d)
0 2 6 7 Laplacian
1 1 6 4 filter
0 -1 0
4 5 2 7 -1 +4 -1
1 2 6 0 0 -1 0
Ignore the border pixels in calculation and put zero in the border of
the output image.