Image Enhancement-Spatial Filtering From: Digital Image Processing, Chapter 3
Image Enhancement-Spatial Filtering From: Digital Image Processing, Chapter 3
of
19
2
of
19
Contents
Next, we will look at spatial filtering
techniques:
What is spatial filtering?
Smoothing Spatial filters.
Sharpening Spatial Filters.
Combining Spatial Enhancement Methods
3
of
19
Neighbourhood Operations
Neighbourhood operations simply operate
on a larger neighbourhood of pixels than
point operations
Origin
Neighbourhoods are
mostly a rectangle
around a central pixel
Neighbourhood
Any size rectangle
and any shape filter
are possible
y
Image f (x, y)
(x, y)
4
of
19
Neighbourhood Operations
For each pixel in the origin image, the
outcome is written on the same location at
the target image.
Origin
Origin
Neighbourhood
(x, y)
Image f (x, y)
Target
5
of
19
6
of
19
Origin
Simple 3*3
Neighbourhood
3*3 Filter
Image f (x, y)
Original Image
Pixels
Filter (w)
eprocessed = n*e +
j*a + k*b + l*c +
m*d + o*f +
p*g + q*h + r*i
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
7
of
19
w(s, t ) f ( x s, y t )
s at b
8
of
19
9
of
19
Origin
Simple 3*3
Neighbourhood
1
1
1
/9 100
/9 108
/9
104
1
/9 106
/9 198
/9
99
/9 190
/9 185
/9
95
90
85
Original Image
3*3 Smoothing
Pixels
/9
/9
/9
/9
/9
/9
/9
/9
/9
Filter
Filter
Image f (x, y)
e = 1/9*106 +
1
/9*104 + 1/9*100 + 1/9*108 +
1
/9*99 + 1/9*98 +
1
/9*95 + 1/9*90 + 1/9*85
= 98.3333
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
10
of
19
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
11
of
19
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
12
of
19
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
13
of
19
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
14
of
19
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
15
of
19
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
16
of
19
17
of
19
/16
/16
/16
/16
/16
/16
/16
/16
/16
Weighted
averaging filter
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
18
of
19
Original Image
Smoothed Image
Thresholded Image
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
19
of
19
Original Image
With Noise
Image After
Averaging Filter
Image After
Median Filter
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
20
of
19
Original
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
21
of
19
Averaging
Filter
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
22
of
19
Median
Filter
23
of
19
e
e
Image f (x, y)
24
of
19
25
of
19
Original Image
Pixels
Filter
eprocessed = v*e +
z*a + y*b + x*c +
w*d + u*e +
t*f + s*g + r*h
26
of
19
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
27
of
19
Spatial Differentiation
Differentiation measures the rate of change of
a function
Lets consider a simple 1 dimensional
example
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
28
of
19
Spatial Differentiation
A
B
29
of
19
1st Derivative
The formula for the 1st derivative of a
function is as follows:
f
f ( x 1) f ( x)
x
30
of
19
f(x)
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
0 -1 -1 -1 -1 0 0 6 -6 0 0 0 1 2 -2 -1 0 0 0 7 0 0 0
f(x)
31
of
19
2nd Derivative
The formula for the 2nd derivative of a
function is as follows:
f
f ( x 1) f ( x 1) 2 f ( x)
2
x
2
32
of
19
f(x)
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
f(x)
-12
6 0 0 1 1 -4 1 1 0 0 7 -7 0 0
33
of
19
f(x)
f(x)
f(x)
34
of
19
35
of
19
The Laplacian
The Laplacian is defined as follows:
f f
f 2 2
x y
where the partial 1st order derivative in the x
direction is defined as follows:
2
f
f ( x 1, y ) f ( x 1, y ) 2 f ( x, y )
2
x
and in the y direction as follows:
2
f
f ( x, y 1) f ( x, y 1) 2 f ( x, y )
2
y
2
36
of
19
f [ f ( x 1, y ) f ( x 1, y )
f ( x, y 1) f ( x, y 1)]
4 f ( x, y )
2
-4
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
37
of
19
Original
Image
Laplacian
Filtered Image
Laplacian
Filtered Image
Scaled for Display
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
38
of
19
g ( x, y ) f ( x, y ) f
2
Laplacian
Filtered Image
Scaled for Display
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
39
of
19
Original
Image
=
Laplacian
Filtered Image
Sharpened
Image
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
40
of
19
41
of
19
g ( x, y ) f ( x, y ) f
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)
2
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
42
of
19
-1
-1
-1
-1
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
43
of
19
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
44
of
19
-4
Simple
Laplacian
-8
-1
-1
-1
-1
-1
-1
-1
-1
Variant of
Laplacian
45
of
19
46
of
19
Highboost Filtering
47
of
19
Gy
48
of
19
G G
2
x
2
y
f
f
x
y
2
49
of
19
z3 2 z6 z9 z1 2 z 4 z7
z2
z3
z4
z5
z6
z7
z8
z9
50
of
19
Sobel Operators
Based on the previous equations we can
derive the Sobel Operators
-1
-2
-1
-1
-2
-1
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
51
of
19
Sobel Example
An image of a
contact lens which
is enhanced in
order to make
defects (at four
and five oclock in
the image) more
obvious
52
of
19
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
53
of
19
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
54
of
19
(a)
Laplacian filter
bone scan (a)
of
(b)
Sharpened version of
bone scan achieved
(c)
by subtracting (a)
Sobel filter of bone
and (b)
scan (a)
(d)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
55
of
19
Result of applying a
power-law trans. to
Sharpened image (g)
which is sum of (a)
(g)
and (f)
(f)
(h)
Images taken from Gonzalez & Woods, Digital Image Processing (2002)
56
of
19