Professional Documents
Culture Documents
03-3 - Spatial Filtering Fundamentals
03-3 - Spatial Filtering Fundamentals
byGlebV.Tcheslavski:gleb@ee.lamar.edu http://ee.lamar.edu/gleb/dip/index.htm
Spring 2008 ELEN 4304/5365 DIP 1
Spring 2008
4/28/2008
In general:
g ( x, y ) =
s = a t = b
w(s, t ) f ( x + s, y + t )
Spring 2008
m = 2a + 1 n = 2b + 1
Where a and b are some integers.
For a 3 x 3 mask
Spring 2008
4/28/2008
Spring 2008
4/28/2008
Spring 2008
w( x, y ) : f ( x, y ) =
s = a t = b
w(s, t ) f ( x + s, y + t )
w(s, t ) f ( x s, y t )
a b
w( x, y ) f ( x, y) =
s = a t = b
Spring 2008
4/28/2008
R = wk zk = w T z
k =1
Filter coeffs Image intensities
mn
R = wk zk = w T z
k =1
Spring 2008 ELEN 4304/5365 DIP 9
R=
9
1 9 zi 9 i =1
Which is:
R = wi zi = w T z;
i =1
ELEN 4304/5365 DIP
wi =
1 9
10
Spring 2008
4/28/2008
g ( x, y ) =
s = a t = b
w(s, t ) f ( x + s, y + t )
s = a t = b
w(s, t )
12
Spring 2008
4/28/2008
And the results of smoothing with a square averaging filter of sizes m = 3, 5, 9, 15, 25, and 35 pixels.
Spring 2008
13
Spring 2008
14
4/28/2008
4/28/2008
f = f ( x + 1) f ( x) x
The second-order derivative:
2 f = f ( x + 1) + f ( x 1) 2 f ( x) x 2
It can be verified that these definitions satisfy the conditions for derivatives.
Spring 2008
18
4/28/2008
2 f 2 f f = 2 + 2 x y
2
Therefore:
2 f = f ( x + 1, y ) + f ( x 1, y ) + f ( x, y + 1) + f ( x, y 1) 4 f ( x, y )
The Laplacian is a linear operator since derivatives are linear operators.
Spring 2008 ELEN 4304/5365 DIP 20
10
4/28/2008
Spring 2008
22
11
4/28/2008
23
g mask ( x, y ) = f ( x, y ) f ( x, y )
Original Blurred image
g ( x, y ) = f ( x, y ) + k g mask ( x, y )
Here k is a weight.
Spring 2008
24
12
4/28/2008
Spring 2008
25
Result of using unshapr mask (k = 1) Result of using highboost filtering with k = 4.5
Spring 2008 ELEN 4304/5365 DIP 26
13
4/28/2008
Gradient method
First derivatives can be implemented for nonlinear image sharpening using the magnitude of the gradient:
f g x x f grad ( f ) = g y f y The gradient vector points in the direction of the greatest rate of g of f at location (x,y y) ). The magnitude g ( (length) g ) of g gradient change
2 2 M ( x, y ) = f = g x + gy
Spring 2008
27
Gradient method
M(x,y) is an image of the same size as the original and is called the gradient image. Magnitude makes M(x,y) non-linear. It is more s suitable itable in some applications to use: se
M ( x, y ) g x + g y
For an image where z5 represent the pixel f(x,y) and z1 represent the pixel f(x-1,y-1), the simplest (Roberts) definitions for gradients are:
M ( x, y ) =
( z9 z5 ) + ( z8 z6 )
2
M ( x, y ) z9 z5 + z8 z6
However, Roberts cross-gradient operators lead to masks of even sizes, which is inconvenient.
ELEN 4304/5365 DIP 28
Spring 2008
14
4/28/2008
Gradient method
The smallest masks with central symmetry (ones we are interested in) are 3x3. The gradient can be approximated for such masks as following:
Roberts operators
Gradient method
The coefficients in all masks shown sum to zero. This indicates that mask will give a zero response in an area of constant intensity as expected of a derivative operator operator.
Sobel gradient
Defect
Spring 2008 ELEN 4304/5365 DIP 30
15
4/28/2008
Spring 2008
31
Spring 2008
32
16