Spatial Filter-I
Spatial Filter-I
Digital Image
Processing
Spatial Domain Filtering: Part I
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
Spatial Filtering
Convolution
a b
g( x, y ) ω( s,t ) f ( x s, y t )
s a t b
g ω f
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
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
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
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
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
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
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
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
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
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
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
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
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
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
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
Convolution
5 4 4 -2
9 6 14 5
11 7 6 5
9 12 8 5
Final output Image, g
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
Correlation
a b
g( x, y ) ω( s,t ) f ( x s, y t )
s a t b
g ω f
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
Correlation
correlation kernel, ω
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
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
1 -1 -1 Correlation 2 2 2 3
1 2 -1 2 1 3 3
1 1 1 2 2 1 2
1 -1 -1 1 3 2 2
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
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
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
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
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
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
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
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
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
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
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 1 -3
2 3 3 3 4 output
Image, g
2 2 1 2
1 3 2 2
Input Image, f
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
Correlation
5 10 10 15
3 4 6 11
7 11 4 9
-5 4 4 5
Final output Image, g
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
5x5 9x9
15x15 35x35
Summary
•We have looked at:
– What are spatial domain operations.
– What are convolution and correlation.
– What is smoothing linear filter