Lecture W6c (Spatial Filtering)
Lecture W6c (Spatial Filtering)
Muhammad Shahzad
Department Of Computing (DOC), SEECS, NUST
http://seecs.nust.edu.pk/faculty/muhammadshahzad.html
[email protected]
Spring 2019, MSCS-8
▪ They don’t know where they are in an image
2
▪ Spatial Filtering : Basics
3
Basics
4
Basics
5
Basics
6
Basics
7
Basics
8
Basics
9
Basics
10
▪ The output intensity value at (x,y) depends not only on the
input intensity value at (x,y) but also on the specified number of
neighbouring intensity values around (x,y)
11
12
= wTz
13
g ( x, y ) = w ( −1, −1) f ( x − 1, y − 1) + w ( −1,0 ) f ( x − 1, y ) + w ( −1,1) f ( x − 1, y + 1)
+ w ( 0, −1) f ( x, y − 1) + w ( 0,0 ) f ( x, y ) + w ( 0,1) f ( x, y + 1)
+ w (1, −1) f ( x + 1, y − 1) + w (1,0 ) f ( x + 1, y ) + w (1,1) f ( x + 1, y + 1)
Pixels of
m −1 n −1 image
where a = ,b =
2 2 section
under filter
where x and y are varied so that each
pixel in w visits every pixel in f
14
▪ There are two closely related concepts that must be understood
clearly when performing linear spatial filtering
▪ Correlation
▪ Convolution
15
Correlation Convolution
16
Correlation Convolution
17
▪ Two important points
▪ Correlating a filter w with a function that contains all 0s and a single
1 yields a copy of w (rotated)
▪ We call a function that contains a single 1 with the rest being 0s
a discrete unit impulse
▪ Thus correlation of a function with a discrete unit impulse
yields a rotated version of the function at the location of the
impulse
▪ Concept of convolution is cornerstone of linear system theory
▪ A fundamental property of convolution is that convolving a function
with a unit impulse yields a copy of the function at the location of
the impulse
18
If the filter mask is
symmetric, correlation
and convolution yield the
same result
20
For the image,
take dark pixel value = 1,
light pixel value = 0
21
▪ The final result is
22
▪ To summarize
a b
w ( s, t ) f ( x + s, y + t )
s =− a t =−b m −1 n −1
where a = ,b =
2 2
In general, convolution of an image of
and x and y are varied so that each
size M x N with a filter of size m x n is
given below pixel in w visits every pixel in f
a b
w ( s, t ) f ( x − s, y − t )
s =− a t =−b
23
Various contents in this presentation have been taken from
different books, lecture notes, and the web. These solely belong
to their owners, and are here used only for clarifying various
educational concepts. Any copyright infringement is not
intended.
24