ReviewSpatial Filtering Basics
Spatial Filtering
Dr. Praveen Sankaran
Department of ECE
NIT Calicut
January 6, 2013
Dr. Praveen Sankaran DIP Winter 2013
ReviewSpatial Filtering Basics
Outline
1 Review
2 Spatial Filtering Basics
Convolution and Correlation
Filter Masks
Dr. Praveen Sankaran DIP Winter 2013
ReviewSpatial Filtering Basics
Review
A pixel is a small image area indexed by [m,n];
g [m,n] is the associated pixel value;
A digital image is an M×N array of gray levels.
Dr. Praveen Sankaran DIP Winter 2013
ReviewSpatial Filtering Basics
Neighbors, Adjacency, Regions, Connectivity, Boundaries,
Edges
We took ξ = 1. We are essentially de�ning our neighbors in this
step.
Dr. Praveen Sankaran DIP Winter 2013
ReviewSpatial Filtering Basics
Spatial Domain
Refers to the image plane itself.
↓Direct manipulation of image pixels.
Figure: Spatial Filtering with a 3×3 mask (kernel, template or window)
Dr. Praveen Sankaran DIP Winter 2013
ReviewSpatial Filtering Basics
Convolution and CorrelationFilter Masks
Outline
1 Review
2 Spatial Filtering Basics
Convolution and Correlation
Filter Masks
Dr. Praveen Sankaran DIP Winter 2013
ReviewSpatial Filtering Basics
Convolution and CorrelationFilter Masks
Spatial Filter
Dr. Praveen Sankaran DIP Winter 2013
ReviewSpatial Filtering Basics
Convolution and CorrelationFilter Masks
Correlation and Convolution - In 1D
Dr. Praveen Sankaran DIP Winter 2013
ReviewSpatial Filtering Basics
Convolution and CorrelationFilter Masks
Correlation and Convolution - In 2D
Dr. Praveen Sankaran DIP Winter 2013
ReviewSpatial Filtering Basics
Convolution and CorrelationFilter Masks
Correlation and Convolution - Representations
Correlation
w (m,n)�g (m,n) =a
∑s=−a
b
∑t=−b
w (s, t)g (m+ s, y + t)
Convolution
w (m,n)?g (m,n) =a
∑s=−a
b
∑t=−b
w (s, t)g (m− s, y − t)
Dr. Praveen Sankaran DIP Winter 2013
ReviewSpatial Filtering Basics
Convolution and CorrelationFilter Masks
Outline
1 Review
2 Spatial Filtering Basics
Convolution and Correlation
Filter Masks
Dr. Praveen Sankaran DIP Winter 2013
ReviewSpatial Filtering Basics
Convolution and CorrelationFilter Masks
Vector Representation
w1 w2 w3
w4 w5 w6
w7 w8 w9
→3×3 �lter mask
g1 g2 g3g4 g5 g6g7 g8 g9
→image
Linear Representation
R5 = w1g1+w2g2+ · · ·+w9g9 =9
∑k=1
wkgk =wTg
where, w and g are 9-dimensional vectors formed from the
mask and the image respectively.
Dr. Praveen Sankaran DIP Winter 2013
ReviewSpatial Filtering Basics
Convolution and CorrelationFilter Masks
Generating a Mask
Creating a �lter essentially boils down to specifying the values
of mask coe�cients.
Remember - All we are doing is a sum-of-products.
Creating an averaging �lter - replace pixel with average intensity in
neighborhood
Average = 19
9
∑i=1
gi =9
∑i=1
19gi
19
19
19
19
19
19
19
19
19
→averaging mask!
Dr. Praveen Sankaran DIP Winter 2013
ReviewSpatial Filtering Basics
Convolution and CorrelationFilter Masks
Gaussian Mask
Basic form →h (x ,y) = e
− x2+y2
2σ2
sample,quantize
⇓
h (m,n) = e−m
2+n2
2σ2
Sample the continuous function about its center.w1 w2 w3
w4 w5 w6
w7 w8 w9
=
h (−1,−1) h (0,−1) h (1,−1)h (−1,0) h (0,0) h (1,0)h (−1,1) h(0,1) h (1,1)
Dr. Praveen Sankaran DIP Winter 2013
ReviewSpatial Filtering Basics
Convolution and CorrelationFilter Masks
Summary
Pixel relationships.
Correlation and Convolution.
Vector representation.
Generating a mask for �ltering.
Dr. Praveen Sankaran DIP Winter 2013
ReviewSpatial Filtering Basics
Convolution and CorrelationFilter Masks
Questions
3.1, 3.2, 3.3, 3.4, 3.5
3.6, 3.7, 3.11
3.13, 3.14
Dr. Praveen Sankaran DIP Winter 2013