2. 4.2
Introduction To Filters
• Filtering is a technique used for modifying or enhancing an
image like highlight certain features or remove other
features.
• Image filtering include smoothing, sharpening, and edge
enhancement
• Term ‘convolution ‘ means applying filters to an image .
• It may be applied in either
spatial domain
frequency domain
4. 4.4
SPATIAL FILTER
The spatial filter is just moving the filter mask from point to
point in an image.
The filter mask may be 3x3 mask or 5x5 mask or to be 7x7
mask.
Example
3x3 mask in a 5x5 image
5. 4.5
MECHANISM OF SPATIAL FILTERING
Filter at each point
(x , y) are calculated
by predefined
relationship
This process shows
moving filter mask
point to point
6. 4.6
Spatial Filtering
• Similar to neighborhood operation
• A mask or filter or template or kernel or window
defines the neighborhood
• Mask size is usually m × n
o m = 2a+1, n = 2b+1
• Output pixel value is determined from the pixels under
the mask
7. 4.7
The Approaches of Spatial Filtering
O A neighborhood (small rectangle)
O
A predefined operation performed on
image pixels.
Spatial filter consist of two steps
Filtering creates a new pixel value replaced by old pixel value
12. 4.12
Types Of Spatial Filters
There are two types of filter,
1.Linear Spatial Filter
2.Non Linear Spatial Filter
Each pixel in an image can be replaced with
constant value then it is called as linear spatial
filter otherwise it is called as non-linear.
19. 4.19
Image Enhancement using Spatial Filtering
w(-1,-1) w(-1,0) w(-1,1)
w(0,-1) w(0,0) w(0,1)
w(1,0) w(1,1)
f(x-1,y-1) f(x-1,y) f(x-1,y+1)
f(x,y) f(x,y+1)
f(x+1,y-1) f(x+1,y) f(x+1,y+1)
Mask
Coefficients
Pixels under Mask
w(1,-1)
f(x,y-1)
Response of the filter
at point (x, y):
)
1
,
1
(
)
1
,
1
(
)
,
1
(
)
0
,
1
(
)
,
1
(
)
0
,
1
(
)
1
,
1
(
)
1
,
1
(
y
x
f
w
y
x
f
w
y
x
f
w
y
x
f
w
R
20. 4.20
Image Enhancement using Spatial Filtering
w(-1,-1) w(-1,0) w(-1,1)
w(0,-1) w(0,0) w(0,1)
w(1,0) w(1,1)
f(x-1,y-1) f(x-1,y) f(x-1,y+1)
f(x,y) f(x,y+1)
f(x+1,y-1) f(x+1,y) f(x+1,y+1)
Mask
Coefficients
Pixels under Mask
w(1,-1)
f(x,y-1)
Response of the filter
at point (x, y):
)
1
,
1
(
)
1
,
1
(
)
,
1
(
)
0
,
1
(
)
,
1
(
)
0
,
1
(
)
1
,
1
(
)
1
,
1
(
y
x
f
w
y
x
f
w
y
x
f
w
y
x
f
w
R
**This type of response is called linear filtering
21. 4.21
Image Enhancement using Spatial Filtering
A more general
equation for
response:
w(-1,-1) w(-1,0) w(-1,1)
w(0,-1) w(0,0) w(0,1)
w(1,0) w(1,1)
f(x-1,y-1) f(x-1,y) f(x-1,y+1)
f(x,y-1) f(x,y) f(x,y+1)
f(x+1,y-1) f(x+1,y) f(x+1,y+1)
Mask
Coefficients
w(1,-1)
a
a
s
b
b
t
t
y
s
x
f
t
s
w
y
x
g )
,
(
)
,
(
)
,
(
g(x,y)
M
N
2b+1
2a+1
22. 4.22
Image Enhancement using Spatial Filtering
mn
i
i
i z
w
R
1
w1 w2 w3
w4 w5 w6
w8 w9
Mask
Coefficients
w7
Or, for a general case of
mask size mXn:
z1 z2 z3
z4 z5 z6
z8 z9
z7
9
1
i
i
i z
w
R