Professional Documents
Culture Documents
g (m, n) = T ( f )(m, n)
How to specify T
∑ ∑ h( m − k , n − l ) f ( k , l )
∞ ∞
=
l = −∞ k = −∞
∑ ∑ f ( m − k , n − l ) h( k , l )
∞ ∞
=
l = −∞ k = −∞
• In practice, to reduce computations, h( m, n ) is of “finite
extent:”
h(k , l ) = 0, for (k , l ) ∉ ∆
G (u , v) = H e (u , v) Fe (u , v)
H(u) H(u)
1
1
0 0
h(x) h(x)
0 0
w1 w2 w3
h = w4 w5 w6
w7 w8 w9
then
g (m, n) = w1 f (m − 1, n − 1) + w2 f (m − 1, n) + w3 f (m − 1, n + 1)
+ w4 f (m, n − 1) + w5 f (m, n) + w6 f (m, n + 1)
+ w7 f (m + 1, n − 1) + w8 f (m + 1, n) + w9 f (m + 1, n + 1)
• The output g(m, n) is computed by sliding the mask over each
pixel of the image f(m, n). This filtering procedure is
sometimes referred to as moving average filter.
0 1 0
1 1 1
1 3 1
0 1 0
1 1 1 1
1 1 1 1 1 1 3 16 3 1 4 1
5
9
32
8
0 1 0 1 1 1 1 3 1 0 1 0
• This operation is equivalent to lowpass filtering.
Example of Image Blurring
1 1
1
1 1 1 1
N2
1 1
1 N×N
Avg. Mask
Original Image
N =3 N =5 N =7
N = 11 N = 15 N = 21
Example of noise reduction
1 1 1 1 1
1 1 1 1 1
1
1 1 1 1 1
25
1 1 1 1 1
1 1 1 1 1
Noise-free Image
1 − x2
pnoise ( x) =
exp
2σ 2
σ 2π
aK / 2 , for K even
median ( A) =
a( K +1) / 2 , for K odd
Noisy Image
Output of 3x3
Averaging filter
Output of 3x3
Median filter
−1 −1 −1
1
−1 8 −1
9
−1 −1 −1
Example
High-boost filtering
• Observe that
g (m, n) = Af (m, n) − lowpass( f (m, n))
= ( A − 1) f (m, n) + f (m, n) − lowpass( f (m, n))
= ( A − 1) f (m, n) + highpass( f (m, n))
Example:
∂f ( x, y )
∇f ( x, y ) = ∂f (∂xx, y )
∂y
2
∂f ( x, y ) ∂f ( x, y )
∇f ( x , y ) = +
∂x ∂y
z1 z2 z3
z4 z5 z6
z7 z8 z9
• We may use the approximation
[
∇f ( x, y ) ≈ ( z 5 − z 8 ) + ( z 5 − z 6 )
2
]
2 1/ 2
1
h1 = and h2 = [1 − 1]
−1
As follows:
[
∇f ( x, y ) ≈ ( f * h1 ) + ( f * h2 )
2
]
2 1/ 2
[
∇f ( x, y ) ≈ ( z5 − z9 ) + ( z6 − z8 )
2
]
2 1/ 2
1 0 0 1
h1 = and h2 =
0 −1 −1 0
As follows:
[
∇f ( x, y ) ≈ ( f * h1 ) + ( f * h2 )
2
]
2 1/ 2
1 1 0 0 1
h1 = and h2 = [1 − 1] h1 = and h2 =
−1 0 −1 −1 0
• Better approximations to the gradient can be obtained by:
∇f ( x , y ) ≈ [((z 7 + z8 + z9 ) − ( z1 + z2 + z3 )) + (( z3 + z6 + z9 ) − ( z1 + z4 + z7 ))
2
]
2 1/ 2
h1 = 0
0 0 and h2 = − 1 0 1
−1 0 1
1 1 1
as follows:
[
∇f ( x, y ) ≈ ( f * h1 ) + ( f * h2 )
2
]
2 1/ 2
−1 − 2 −1 −1 0 1
h1 = 0
0 0
and h2 = − 2 0 2
−1 0 1
1 2 1
Prewitt Sobel