lecture_5
lecture_5
Dr. LavdieRADA
([email protected])
• Spatial domain operation or filtering is the processed
value for the current pixel depending on both itself
and surrounding pixels.
• Type of filters
– Linear filtering
– Non-linear filtering ( Rank order filtering including median;
Morphological filtering)
– Adaptive filtering
Spatial Domain Filtering and Application in Noise
Removal and Edge Detection
a b
g( x, y ) ω( s,t ) f ( x s, y t )
s a t b
g ω f
1 -1 -1
Input Image f
1 2 -1
2 2 2 3
1 1 1
2 1 3 3
Don’t rotate use it directly
2 2 1 2
1 3 2 2
1 -1 -1 Correlation 2 2 2 3
1 2 -1 2 1 3 3
1 1 1 2 2 1 2
1 3 2 2
1 -1 -1
1 2 -2
4 2 2 3 5
1 2 1 3 3 output
Image, g
2 2 1 2
1 3 2 2
Input Image, f
1 -1 -1 Correlation 2 2 2 3
1 2 -1 2 1 3 3
1 1 1 2 2 1 2
1 3 2 2
1 -1 -1
2 2 -2
4 2 3 5 10
2 1 3 3 output
Image, g
2 2 1 2
1 3 2 2
Input Image, f
1 -1 -1 Correlation 2 2 2 3
1 2 -1 2 1 3 3
1 1 1 2 2 1 2
1 3 2 2
1 -1 -1
2 2 2 -3
4 3 5 10 10
2 1 3 3 output
Image, g
2 2 1 2
1 3 2 2
Input Image, f
1 -1 -1 Correlation 2 2 2 3
1 2 -1 2 1 3 3
1 1 1 2 2 1 2
1 3 2 2
1 -1 -1
2 2 2 3
6 -1 5 10 10 15
2 1 3 3 1 output
Image, g
2 2 1 2
1 3 2 2
Input Image, f
1 -1 -1 Correlation 2 2 2 3
1 2 -1 2 1 3 3
1 1 1 2 2 1 2
1 3 2 2
1 -2
2 -2
2 2 3 5 10 10 15
1 4
2 -1
1 3 3 3 output
Image, g
1 2 2 1 2
1 3 2 2
Input Image, f
1 -1 -1 Correlation 2 2 2 3
1 2 -1 2 1 3 3
1 1 1 2 2 1 2
1 3 2 2
2 -2
2 -2
2 3 5 10 10 15
2 2
1 -3
3 3 3 4 output
Image, g
2 2 1 2
1 3 2 2
Input Image, f
Correlation
5 10 10 15
3 4 6 11
7 11 4 9
-5 4 4 5
Final output Image, g
Convolution
a b
g( x, y ) ω( s,t ) f ( x s, y t )
s a t b
g ω f
Convolution
Convolution kernel, ω Input Image, f
1 -1 -1 2 2 2 3
1 2 -1 2 1 3 3
1 1 1 2 2 1 2
Rotate 180o 1 3 2 2
1 1 1
-1 2 1
-1 -1 1
1 1 1 Convolution 2 2 2 3
-1 2 1 2 1 3 3
-1 -1 1 2 2 1 2
1 3 2 2
1 1 1
2
-1 4 2 2 3 5
Output
2 1
-1 -2 3 3 Image, g
2 2 1 2
1 3 2 2
Input Image, f
1 1 1 Convolution 2 2 2 3
-1 2 1 2 1 3 3
-1 -1 1 2 2 1 2
1 3 2 2
1 1 1
2 4
-2 2 2 3 5 4
Output
2 -1
-2 1 3 3 Image, g
2 2 1 2
1 3 2 2
Input Image, f
1 1 1 Convolution 2 2 2 3
-1 2 1 2 1 3 3
-1 -1 1 2 2 1 2
1 3 2 2
1 1 1
2 -2
2 4
2 3 5 4 4
Output
2 -1
1 -3
3 3 Image, g
2 2 1 2
1 3 2 2
Input Image, f
1 1 1 Convolution 2 2 2 3
-1 2 1 2 1 3 3
-1 -1 1 2 2 1 2
1 3 2 2
1 1 1
2 2 2 3
-2 6 1 5 4 4 -2
Output
2 1 3 -3
-3 3 1 Image, g
2 2 1 2
1 3 2 2
Input Image, f
1 1 1 Convolution 2 2 2 3
-1 2 1 2 1 3 3
-1 -1 1 2 2 1 2
1 3 2 2
1 2 2 2 3 5 4 4 -2
Output
-1 4
2 1 3 3 9 Image, g
-1 -2
2 2 1 2
1 3 2 2
Input Image, f
1 1 1 Convolution 2 2 2 3
-1 2 1 2 1 3 3
-1 -1 1 2 2 1 2
1 3 2 2
2 2 2 3 5 4 4 -2
Output
-2
2 2
1 3 3 9 6 Image, g
2 -2
-2 2 1 2
1 3 2 2
Input Image, f
Convolution
5 4 4 -2
9 6 14 5
11 7 6 5
9 12 8 5
Final output Image, g
Smoothing Spatial Filters
5x5 9x9
15x15 35x35
Median filter
a1 < a2 < … < a n then median is a(1+n)/2
Given
18 22 33
34 128 24
22 19 32
f
f ( x 1) f ( x)
x
2 f
f ( x 1) f ( x) ( f ( x) f ( x 1))
x 2
f ( x 1) f ( x 1) 2 f ( x)
Sharpening Spatial Filters
The Laplacian
2
f 2
f
f 2 2
2
x y
2 f
f ( x 1, y) f ( x 1, y) 2 f ( x, y)
x 2
2 f
f ( x, y 1) f ( x, y 1) 2 f ( x, y)
y 2
Sharpening Spatial Filters
The 2D Laplacian
2 f f ( x 1, y ) f ( x 1, y ) f ( x, y 1) f ( x, y 1) 4 f ( x, y )
Sharpening Spatial Filters
The 2D Laplacian
Sharpening Spatial Filters
The 2D Laplacian
If the center coefficient of
f ( x, y ) f ( x, y )
2
the Laplacian mask is
negative
g ( x, y )
If the center coefficient of
f ( x, y ) 2 f ( x, y ) the Laplacian mask is
positive
2
f f
2
2 1/ 2
f mag (f ) Gx G y
2
x y
The First Derivatives for Enhancement
The Gradient
f Gx Gy
f Gx G y ( z7 2 z8 z9 ) ( z1 2 z2 z3 )
( z3 2 z6 z9 ) ( z1 2 z4 z7 )
The First Derivatives for Enhancement
The Sobel Operator
The First Derivatives for Enhancement
The Sobel Operator
Horizontal Vertical
Summary
•We have looked at:
– What are statistical filters.
– What are Laplacian and Gradient.
– What is Sobel operator.