image processing 6-spatialfiltering2.ppt
TRANSCRIPT
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
1/33
Course Website: http://www.comp.dit.ie/bmacnamee
Digital Image Processing
Image Enhancement(Spatial Filtering !
http://www.comp.dit.ie/bmacnameehttp://www.comp.dit.ie/bmacnameehttp://www.comp.dit.ie/bmacnamee
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
2/33
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
3/33
#
o"
#$Spatial Filtering +e"resher
r s t
u v w
x y z
Origin x
y Image f (x, y)
e processed = v*e +
r *a + s*b + t *c +
u*d + w*f + x*g + y*h + z *i
Filter Simple 3*3
Neighbourhood
e
3*3 Filter
a b c
d e f
g h i
Original ImagePixels
*
,he abo*e is repeated "or e*er- piel in the
original image to generate the smoothed image
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
4/33
o"
#$Sharpening Spatial Filters
Pre*iousl- we ha*e loo%ed at smoothing"ilters which remo*e "ine detail
Sharpening spatial filters see% to highlight
"ine detail ' +emo*e blurring "rom images
' 0ighlight edges
Sharpening "ilters are based on spatialdifferentiation
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
5/33
1
o"
#$Spatial Di""erentiation
Di""erentiation measures the rate of change o"a "unction
2et3s consider a simple ) dimensional
eample
I m a
g e s t a % e n " r o m 4 o n 5 a l e 5 6 W o o d s 7
D i g i t a l I m a
g e P r o c e s s i n g ( $ $ !
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
6/33
8
o"
#$Spatial Di""erentiation
I m a g e s t a % e n " r o m 4 o n 5 a l e 5 6 W o o d s 7
D i g i t a l I m a
g e P r o c e s s i n g ( $ $ !
9
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
7/33
;
o"
#$)st Deri*ati*e
,he "ormula "or the )st deri*ati*e o" a"unction is as "ollows:
It3s
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
8/33
=
o"
#$)st Deri*ati*e (cont>!
1 1 # ) $ $ $ 8 $ $ $ $ ) # ) $ $ $ $ ; ; ; ;
$ ?) ?) ?) ?) $ $ 8 ?8 $ $ $ ) ? ?) $ $ $ ; $ $ $
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
9/33
@
o"
#$nd Deri*ati*e
,he "ormula "or the nd deri*ati*e o" a"unction is as "ollows:
Simpl- ta%es into account the *alues both
be"ore and a"ter the current *alue
)(2)1()1(2
2
x f x f x f x
f −−++=
∂
∂
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
10/33
)$
o"
#$nd Deri*ati*e (cont>!
1 1 # ) $ $ $ 8 $ $ $ $ ) # ) $ $ $ $ ; ; ; ;
?) $ $ $ $ ) $ 8 ?) 8 $ $ ) ) ? ) ) $ $ ; ?; $ $
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
11/33
))
o"
#$
Asing Second Deri*ati*es For Image
Enhancement
,he nd deri*ati*e is more use"ul "or imageenhancement than the )st deri*ati*e
' Stronger response to "ine detail
' Simpler implementation ' We will come bac% to the )st order deri*ati*elater on
,he "irst sharpening "ilter we will loo% at is
the Laplacian ' Isotropic
' Bne o" the simplest sharpening "ilters
' We will loo% at a digital implementation
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
12/33
)
o"
#$,he 2aplacian
,he 2aplacian is de"ined as "ollows:
where the partial )st order deri*ati*e in the x direction is de"ined as "ollows:
and in the y direction as "ollows:
y
f
x
f f
2
2
2
22
∂
∂+
∂
∂=∇
),(2),1(),1(2
2
y x f y x f y x f x
f −−++=
∂
∂
),(2)1,()1,(2
2
y x f y x f y x f y
f −−++=
∂
∂
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
13/33
)#
o"
#$,he 2aplacian (cont>!
So7 the 2aplacian can be gi*en as "ollows:
We can easil- build a "ilter based on this
),1(),1([2 y x f y x f f −++=∇
)]1,()1,( −+++ y x f y x f
),(4 y x f −
$ ) $
) ? )
$ ) $
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
14/33
)
o"
#$,he 2aplacian (cont>!
9ppl-ing the 2aplacian to an image we get anew image that highlights edges and other
discontinuities
I m a g e s t a % e n " r o m 4 o n 5 a l e 5 6 W o o d s 7
D i g i t a l I m a
g e P r o c e s s i n g ( $ $ !
Briginal
Image
2aplacian
Filtered Image
2aplacian
Filtered Image
Scaled "or Displa-
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
15/33
)1
o"
#$ut ,hat Is ot er- Enhanced
,he result o" a 2aplacian "ilteringis not an enhanced image
We ha*e to do more wor% in
order to get our "inal imageSubtract the 2aplacian result
"rom the original image to
generate our "inal sharpenedenhanced image
2aplacian
Filtered Image
Scaled "or Displa-
I m a g e s t a % e n " r o m 4 o n 5 a l e 5 6 W o o d s 7
D i g i t a l I m a
g e P r o c e s s i n g ( $ $ !
f y x f y x g 2),(),( ∇−=
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
16/33
)8
o"
#$2aplacian Image Enhancement
In the "inal sharpened image edges and "inedetail are much more ob*ious
I m a g e s t a % e n " r o m 4 o n 5 a l e 5 6 W o o d s 7
D i g i t a l I m a
g e P r o c e s s i n g ( $ $ !
?
Briginal
Image
2aplacian
Filtered Image
Sharpened
Image
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
17/33
);
o"
#$2aplacian Image Enhancement
I m a g e s t a % e n " r o m 4 o n 5 a l e 5 6 W o o d s 7
D i g i t a l I m a
g e P r o c e s s i n g ( $ $ !
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
18/33
)=
o"
#$Simpli"ied Image Enhancement
,he entire enhancement can be combinedinto a single "iltering operation
),1(),1([),( y x f y x f y x f −++−=
)1,()1,( −+++ y x f y x f
)],(4 y x f −
f y x f y x g 2),(),( ∇−=
),1(),1(),(5 y x f y x f y x f −−+−=
)1,()1,( −−+− y x f y x f
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
19/33
)@
o"
#$Simpli"ied Image Enhancement (cont>!
,his gi*es us a new "ilter which does thewhole
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
20/33
$
o"
#$Simpli"ied Image Enhancement (cont>!
I m a g e s t a % e n " r o m 4 o n 5 a l e 5 6 W o o d s 7
D i g i t a l I m a
g e P r o c e s s i n g ( $ $ !
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
21/33
)
o"
#$ariants Bn ,he Simple 2aplacian
,here are lots o" slightl- di""erent *ersions o"the 2aplacian that can be used:
$ ) $
) ? )
$ ) $
) ) )
) ?= )
) ) )
?) ?) ?)
?) @ ?)
?) ?) ?)
Simple2aplacian
ariant o" 2aplacian
I m a g e s t a % e n " r o m 4 o n 5 a l e 5 6 W o o d s 7
D i g i t a l I m a
g e P r o c e s s i n g ( $ $ !
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
22/33
o"
#$Simple Con*olution ,ool In Ga*a
9 great tool "or testing out di""erent "ilters ' From the boo% HImage Processing tools in
Ga*a
' 9*ailable "rom webC, later on toda- ' ,o launch: java ConvolutionTool Moon.jpg
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
23/33
#
o"
#$)st Deri*ati*e Filtering
Implementing )st deri*ati*e "ilters is di""icult inpractice
For a "unction f(x y! the gradient o" f at
coordinates (x y! is gi*en as the column*ector:
∂
∂∂
∂
=
=∇
y
f x
f
"
"
y
xf
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
24/33
o"
#$)st Deri*ati*e Filtering (cont>!
,he magnitude o" this *ector is gi*en b-:
For practical reasons this can be simpli"ied as:
)f (∇=∇ mag f
[ ] 21
22
y x "" +=
21
22
∂∂
+
∂∂
= y
f
x
f
y x "" f +≈∇
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
25/33
1
o"
#$)st Deri*ati*e Filtering (cont>!
,here is some debate as to how best tocalculate these gradients but we will use:
which is based on these coordinates
( ) ( )321987 22 z z z z z z f ++−++≈∇
( ) ( )741963 22 z z z z z z ++−+++
5) 5 5#
5 51 58
5; 5= 5@
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
26/33
8
o"
#$Sobel Bperators
ased on the pre*ious e&uations we canderi*e the Sobel Operators
,o "ilter an image it is "iltered using both
operators the results o" which are added
together
?) ? ?)
$ $ $
) )
?) $ )
? $
?) $ )
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
27/33
;
o"
#$Sobel Eample
Sobel "ilters are t-picall- used "or edge
detection
I m
a g e s t a % e n " r o m 4 o n 5 a l e 5 6 W o o d s 7
D i g i t a l I m a g e P r o c e s s i n g ( $ $ ! An image of a
contact lens which
is enhanced in
order to make
defects (at four
and five o’clock inthe image) more
obvious
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
28/33
=
o"
#$)st 6 nd Deri*ati*es
Comparing the )st and nd deri*ati*es wecan conclude the "ollowing:
' )st order deri*ati*es generall- produce thic%er
edges ' nd order deri*ati*es ha*e a stronger
response to "ine detail e.g. thin lines
' )st order deri*ati*es ha*e stronger response
to gre- le*el step
' nd order deri*ati*es produce a double
response at step changes in gre- le*el
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
29/33
@
o"
#$Summar-
In this lecture we loo%ed at: ' Sharpening "ilters
)st deri*ati*e "ilters
nd
deri*ati*e "ilters ' Combining "iltering techni&ues
C bi i S ti l E h t
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
30/33
#$
o"
#$
Combining Spatial Enhancement
Jethods
Success"ul imageenhancement is t-picall-
not achie*ed using a single
operation+ather we combine a range
o" techni&ues in order to
achie*e a "inal result,his eample will "ocus on
enhancing the bone scan to
the right I m a g e s t a % e n " r o m 4 o n 5 a l e 5 6 W o o d s 7
D i g i t a l I m a g e P r o c e s s i n g ( $ $ !
C bi i S ti l E h t
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
31/33
#)
o"
#$
Combining Spatial Enhancement
Jethods (cont>!
I m
a g e s t a % e n " r o m 4 o n 5 a l e 5 6 W o o d s 7
D i g i t a l I m a g e P r o c e s s i n g ( $ $ !
2aplacian "ilter o"
bone scan (a!
Sharpened *ersion o"
bone scan achie*ed
b- subtracting (a!
and (b! Sobel "ilter o" bone
scan (a!
(a)
(b)
(c)
(d)
C bi i S ti l E h t
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
32/33
#
o"
#$
Combining Spatial Enhancement
Jethods (cont>!
I m
a g e s t a % e n " r o m 4 o n 5 a l e 5 6 W o o d s 7
D i g i t a l I m a g e P r o c e s s i n g ( $ $ !
,he product o" (c!
and (e! which will be
used as a mas%
Sharpened image
which is sum o" (a!
and ("!
+esult o" appl-ing a
power?law trans. to(g!
(e)
(f)
(g)
(h)
Image (d! smoothed witha 1K1 a*eraging "ilter
C bi i S ti l E h t
-
8/9/2019 Image Processing 6-SpatialFiltering2.ppt
33/33
##
o"
#$
Combining Spatial Enhancement
Jethods (cont>!
Compare the original and "inal images
m
a g e s t a % e n " r o m 4 o n 5 a
l e 5 6 W o o d s 7
D i g i t a l I m a g e P r o c e s s i n g ( $ $ !