Professional Documents
Culture Documents
DIP6
DIP6
Image Enhancement
(Spatial Filtering 2)
Contents
In this lecture we will look at more spatial filtering
techniques
Spatialfiltering refresher
Sharpening filters
1stderivative filters
2nd derivative filters
function
Let’s consider a simple 1 dimensional example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
A
Spatial Differentiation
B
1st Derivative
The formula for the 1st derivative of a function is as
follows:
f
f ( x 1) f ( x)
x
It’s just the difference between subsequent values and
measures the rate of change of the function
1st Derivative (cont…) Image Strip
8
7
6
5
4
3
2
1
0
5 5 4 3 2 1 0 0 0 6 0 0 0 0 1 3 1 0 0 0 0 7 7 7 7
1st Derivative
0 -1 -1 -1 -1 0 0 6 -6 0 0 0 1 2 -2 -1 0 0 0 7 0 0 0
8
6
4
2
0
-2
-4
-6
-8
2nd Derivative
The formula for the 2nd derivative of a function is as
follows: 2
f
f ( x 1) f ( x 1) 2 f ( x)
x
2
8
7
6
5
4
3
2
1
0
5 5 4 3 2 1 0 0 0 6 0 0 0 0 1 3 1 0 0 0 0 7 7 7 7
-1 0 0 0 0 1 0 6 -12 6
2nd0 0 1
Derivative 1 -4 1 1 0 0 7 -7 0 0
10
-5
-10
-15
Sharpening Spatial filters
f
f ( x 1) f ( x)
x
2 f
f ( x 1) f ( x 1) 2 f ( x)
x 2
Second derivative:
1. Zero in flat areas
2. Non-Zero at start and end of step/ramps
3. Zero along ramps of constant slope
x y
where the partial 2nd order derivative in the x
direction is defined as follows:
f
2
f ( x 1, y) f ( x 1, y) 2 f ( x, y)
x
2
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
The Laplacian (cont…)
Applying the Laplacian to an image we get a new
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
an enhanced image
We have to do more work in order to
get our final image
Subtract the Laplacian result from the
original image to generate our final Laplacian
Filtered Image
sharpened enhanced image Scaled for Display
g ( x, y) f ( x, y) f 2
Laplacian Image Enhancement
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
- =
Original Laplacian Sharpened
Image Filtered Image Image
f ( x, y) [ f ( x 1, y) f ( x 1, y)
f ( x, y 1) f ( x, y 1)
4 f ( x, y)]
5 f ( x, y) f ( x 1, y) f ( x 1, y)
f ( x, y 1) f ( x, y 1)
Simplified Image Enhancement (cont…)
This gives us a new filter which does the whole job for
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
us in one step
0 -1 0
-1 5 -1
0 -1 0
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
-1 -1 -1
-1 9 -1
-1 -1 -1
Unsharp Masking and Highboost filtering
f
Gx x
f f
G y
y
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 Gy
1st Derivative Filtering (cont…)
There is some debate as to how best to calculate these
gradients but we will use:
f z7 2 z8 z9 z1 2 z2 z3
z3 2 z6 z9 z1 2 z4 z7
which is based on these coordinates
z1 z2 z3
z4 z5 z6
z7 z8 z9
Sobel Operators
Based on the previous equations we can derive the Sobel
Operators
-1 -2 -1 -1 0 1
0 0 0 -2 0 2
1 2 1 -1 0 1
To filter an image it is filtered using both operators the
results of which are added together
Sobel Example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
An image of a
contact lens which
is enhanced in
order to make
defects (at four
and five o’clock in
the image) more
obvious
(a)
Laplacian filter of
bone scan (a)
(b)
Sharpened version of
bone scan achieved (c)
by subtracting (a)
and (b) Sobel filter of bone
scan (a) (d)
Combining Spatial Enhancement Methods
(cont…)
Result of applying a (h)
power-law trans. to
Images taken from Gonzalez & Woods, Digital Image Processing (2002)