Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
Digital Image
Processing
Spatial Domain Filtering: Part I
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
Spatial Filtering
w(-1,-1) w(-1,0) w(-1,1)
Mask coefficients showing
w(0,-1) w(0,0) w(0,1)
coordinate arrangement
w(1,-1) w(1,0) w(1,1)
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
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
Linear Spatial Filtering
R (1, 1) f ( x 1, y 1) (1, 0) f ( x 1, y ) ...
(0, 0) f ( x, y ) ... (1, 0) f ( x 1, y ) (1,1) f ( x 1, y 1)
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
Smoothing Spatial Filters
Types of Smoothing Filters : linear and nonlinear
Smoothing Linear Filters : known as averaging filter or lowpass
filters.
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
Smoothing Linear Filters
Box filter Weighted average
filter
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
Smoothing Linear Filters
Original 3x3
5x5 9x9
15x15 35x35
© 2002 R. C. Gonzalez & R. E. Woods
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
Smoothing Linear Filters
original blurred thresholded
© 2002 R. C. Gonzalez & R. E. Woods
Gholamreza Anbarjafari, PhD
Video Lecturers on Digital Image Processing
Summary
•We have looked at:
– What are spatial domain operations.
– What are convolution and correlation.
– What is smoothing linear filter
•Next time we will continue our talk
about image enhancement in spatial
domain by focusing on statistical
terminology