Image Enhancement II-1-23
Image Enhancement II-1-23
Image Enhancement II-1-23
Enhancement
II
Filtering
• It is applied for noise removal or to perform some
type of image enhancement
• Filtering can be done in the spatial domain as well
as frequency domain
• The operators we will discuss here are called spatial
filters since they operate on the raw image data in
the spatial domain
• They operate on the image data by considering small
neighborhoods in an image and returning the result
based on a linear or non-linear operations; moving
sequentially across and down the entire image
Spatial Filtering
Spatial Filtering
Pixels
Since the
of f (x,y-1) f (x,y) f (x,y+1) operations
image performed in the
section convolution are
under f (x+1,y-1) f (x+1,y) f (x+1,y+1) linear, these types
mask of filters are called
linear filters
Linear Spatial Filtering
• The process consists simply of moving the filter
mask from point to point in an image
• At each point (x, y), the response of the filter at that
point is calculated using a predefined relationship
• The response is given by a sum of products of the
filter coefficients and the corresponding image
pixels in the area spanned by the filter mask
• The coefficient w (0,0) coincides with image value
f (x, y), indicating that the mask is centered at (x, y)
when the computation of the sum of products takes
place
Linear Spatial Filtering
• For a 3x3 mask shown in figure, the response, R, of
linear filtering with the filter mask at a point (x, y)
in the image
R = w(-1,-1) f(x-1,y-1)+ w(-1,0) f(x-1,y)+……
+ w(0,0) f(x,y)+… + w(1,0) f(x+1,y)
+ w(1,1) f(x+1,y+1)
w(s,t) :(2a+1)×(2b+1) mask Where „a‟ & „b‟ are
nonnegative integers
• For a mask of size mxn, we assume that m = 2a+1 and
n = 2b+1
• Focus: mask of odd sizes, smallest meaningful size: 3x3
Linear Spatial Filtering
• In general, Linear filtering of an image f of size MxN
with a filter mask of size mxn is given by:
a b
g ( x, y ) w(s, t ) f ( x + s, y + t )
s at b
• Correlation a b
w( x, y ) f ( x, y ) w(s, t ) f ( x + s, y + t )
s at b
• Convolution
a b
w( x, y ) f ( x, y ) w(s, t ) f ( x s, y t )
s at b
w(s, t ) f ( x + s, y + t )
g ( x, y ) s at b
a b
w(s, t )
s at b
Weighted Average
Filter
Example 1
(a) Original image of size
a b 500x500 pixel
c d (b)-(f) Results of smoothing with
e f square averaging filter masks of
sizes n = 3, 5, 9, 15, and 35
respectively
Note:
- details that are of approx. the
same size as the filter mask are
affected considerably more
- the size of the mask establishes
the relative size of the objects
that will be blended with the
background
- big mask is used to eliminate
small objects from an image