Digital Image Processing
Image Enhancement
(Spatial Filtering 2)
Course Website: http://www.comp.dit.ie/bmacnamee
2
of
Low pass Filter
30
Low pass Filter:
• Not allowing the information related to
sudden change in intensity.
• Noise gets reduced.
Spatial Avg
• U(m,n) V(m,n)
3
of
30
U(m,n) Low Pass Filter
- V(m,n)
+
4
of
30
• Remove noise and extract details
(sharpen) in the image (intensity variation)
Band Pass Filter
5
of
30
Band Pass Filter
Low Pass Filter1
-
+
Low Pass Filter2
6
of
Sharpening Filter
30
(High pass Filter)
Two requirements:
1.Summation of coefficient in the smooth
region (uniform intensity) is zero.
∑Zi=0
what can be the filter mask ??
2.Changes of intensity should be
highlighted.
7
of
30
-1 -1 -1
-1 8 -1
-1 -1 -1
8
of
30
• What will happen if Z5=+ve, all other –ve,
so that, total is zero?
-1 -1 -1
1/9 X -1 8 -1
-1 -1 -1
9
of
30
• Try to implement it over a 5x5 image,
which are having some isolated point with
high intensity.
10
of
30
• Scale the intensities to bring to the initial
range.
11
of
30
• Loosing lower frequency information.
• Slowly changing intensity region, does not
get highlight.
12
of
30
• High Pass Filter=Original-Low Pass;
• High Boost=A(Original)-Low Pass; A>=1
=(A-1)original+(original-Low Pass)
=(A-1)Original + High Pass
13
of
30
-1 -1 -1
1/9 x -1 w -1
-1 -1 -1
W=9A-1, with A>=1
14
of
30
• LPF=integration
• HPF=differentiation
Derivative Filters
15
of
30
1st Derivative Filtering
Implementing 1st derivative filters is difficult in
practice
For a function f(x, y) the gradient of f at
coordinates (x, y) is given as the column
vector:
f
Gx x
f f
Gy
y
16
of
30
17
of
30
1st Derivative Filtering (cont…)
The magnitude of this vector is given by:
f mag (f )
G G2
x
2
y 1
2
1
f f
2 2 2
x y
For practical reasons this can be simplified as:
f Gx G y
18
of
30
z1 z2 z3
1 -1
0 0
z4 z5 z6
1 0
z7 z8 z9 -1 0
Mag( f) = [ (z5-z8)2 +(z6-z5)2 ]0.5 = |(z5-z8)|+|(z5-z6)|
19
of
30
• Cross gradient:
f =|(z5-z9)|+|z6-z8|
Robert’s operator:
1 0 0 1
0 -1 -1 0
20
of
30
-1 -1 -1
= 0 0 0
1 1 1
21
of
30
Prewitt’s operator
-1 0 1
=
-1 0 1
-1 0 1
22
of
30
Sobel operator
-1 0 1
=
-2 0 2
-1 0 1
23
of
30
Sobel operator
-1 -2 -1
= 0 0 0
1 2 1
24
of
30
Sobel operator
How to find gradient in different direction?
At 45⁰, 90⁰?
Rotate the mask
-1 -2 -1
0 0 0
1 2 1
25
of
30
At 45⁰
Rotate the mask
-1 -1 0
0 1
-1
0 1 1
26
of
30
What gradient value you will take?
27
of
30
g(x,y)=max{gk(x,y) }
Where, k=0,1,…7.
28
of
30
2nd Derivative
Zero
crossing
29
of
30
What is second derivative?
30
of
30
The difference in first derivative.
31
of
30
The Laplacian
The Laplacian is defined as follows:
2 2
2 f f
f 2 2
x y
where the partial 1st order derivative in the x
direction is defined as follows:
2
f
2
f ( x 1, y ) f ( x 1, y ) 2 f ( x, y )
x
and in the y direction as follows:
2
f
2
f ( x, y 1) f ( x, y 1) 2 f ( x, y )
y
32
of
30
The Laplacian (cont…)
So, the Laplacian can be given as follows:
2
f [ f ( x 1, y ) f ( x 1, y )
f ( x, y 1) f ( x, y 1)]
4 f ( x, y )
We can easily build a filter based on this
0 1 0
1 -4 1
0 1 0
33
of
30
• Noise gets highlighted
• Remove noise
34
of
30
The Laplacian (cont…)
Applying the Laplacian to an image we get a
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
new image that highlights edges and other
discontinuities
Original Laplacian Laplacian
Image Filtered Image Filtered Image
Scaled for Display