Beruflich Dokumente
Kultur Dokumente
Intensity Transformation
and Spatial Filtering
domain
domain
2/6/2014
g ( x, y ) = T [ f ( x, y )])
f ( x, y ) : input image
g ( x, y ) : output image
T : an operator on f defined over
a neighborhood of point ( x, y )
2/6/2014
2/6/2014
2/6/2014
2/6/2014
Image Negatives
Image negatives
s = L 1 r
2/6/2014
Small
lesion
2/6/2014
Log Transformations
Log Transformations
=
s c log(1 + r )
2/6/2014
2/6/2014
10
s = cr
2/6/2014
11
2/6/2014
12
s=r
2/6/2014
1/2.5
13
2/6/2014
14
2/6/2014
15
Piecewise-Linear Transformations
Contrast
Stretching
Intensity-level
Slicing
2/6/2014
16
2/6/2014
17
2/6/2014
18
Bit-plane Slicing
2/6/2014
19
Bit-plane Slicing
2/6/2014
20
Bit-plane Slicing
2/6/2014
21
Histogram Processing
Histogram Equalization
Histogram Matching
2/6/2014
22
Histogram Processing
Histogram h(rk ) = nk
rk is the k th intensity value
nk is the number of pixels in the image with intensity rk
nk
Normalized histogram p(rk ) =
MN
nk : the number of pixels in the image of
size M N with intensity rk
2/6/2014
23
2/6/2014
24
Histogram Equalization
The intensity levels in an image may be viewed as
random variables in the interval [0, L-1].
Let pr (r ) and ps ( s ) denote the probability density
function (PDF) of random variables r and s.
2/6/2014
25
Histogram Equalization
=
s T (r )
0 r L 1
2/6/2014
26
Histogram Equalization
=
s T (r )
0 r L 1
ps ( s)ds = pr (r )dr
2/6/2014
27
Histogram Equalization
r
=
s T (r=
) ( L 1) pr ( w)dw
0
ds dT (r )
d r
=
= ( L 1)
p
w
dw
(
)
r
0
dr
dr
dr
= ( L 1) pr (r )
pr (r )dr pr (r )
1
pr (r )
=
ps ( s ) =
=
=
( ( L 1) pr (r ) ) L 1
ds
ds
dr
2/6/2014
28
Example
Suppose that the (continuous) intensity values
in an image have the PDF
2r
,
2
pr (r ) = ( L 1)
0,
for 0 r L-1
otherwise
29
Example
r
=
s T (r=
) ( L 1) pr ( w)dw
0
= ( L 1)
2w
dw
2
( L 1)
r
=
L 1
2/6/2014
30
Histogram Equalization
Continuous case:
r
) ( L 1) pr ( w)dw
=
s T (r=
0
Discrete values:
k
) ( L 1) pr (rj )
s=
T (rk=
k
j =0
L 1 k
=
= n j
( L 1)
MN MN j 0
=j 0=
k
2/6/2014
nj
k=0,1,..., L-1
31
2/6/2014
32
s0 =
T (r0 ) =
7 pr (rj ) =
7 0.19 =
1.33
s1 =
T (r1 ) =
7 pr (rj ) =
7 (0.19 + 0.25) =
3.08
j =0
1
j =0
2/6/2014
s2 =
4.55 5
s3 =
5.67 6
s4 =
6.23 6
s5 =
6.65 7
s6 =
6.86 7
s7 =
7.00 7
33
2/6/2014
34
2/6/2014
35
2/6/2014
36
Question
Is histogram equalization always good?
No
2/6/2014
37
Histogram Matching
Histogram matching (histogram specification)
generate a processed image that has a specified histogram
) ( L 1) pr ( w)dw
=
s T (r=
0
( L 1) pz (t )dt =
G( z) =
s
0
2/6/2014
38
Histogram Matching
r
=
s T (r=
) ( L 1) pr ( w)dw
0
G( z) =
s
( L 1) pz (t )dt =
0
=
z G=
(s) G
2/6/2014
[T (r )]
39
Obtain pr(r) from the input image and then obtain the values of s
r
=
s ( L 1) pr ( w)dw
0
Use the specified PDF and obtain the transformation function G(z)
z
G( z) =
( L 1) pz (t )dt =
s
0
Mapping from s to z
z = G 1 ( s )
2/6/2014
40
2r
,
2
pr (r ) = ( L 1)
0,
for 0 r L -1
otherwise
3z 2
,
3
pz ( z ) = ( L 1)
0,
2/6/2014
for 0 z ( L -1)
otherwise
41
r
2w
s=
T (r ) =
( L 1) pr ( w)dw =
( L 1)
dw =
0
0 ( L 1) 2
L 1
r
z3
3t 2
G( z) =
( L 1) pz (t )dt =
( L 1)
dt ==
s
2
0
0 ( L 1)3
( L 1)
z
z=
( L 1) s
2
2/6/2014
1/3
2 r
=
( L 1) L 1
2 1/3
( L 1)r
=
42
Obtain pr(rj) from the input image and then obtain the values of
sk, round the value to the integer range [0, L-1].
( L 1) k
sk =
T (rk ) =
( L 1) pr (rj ) = n j
MN j 0
=j 0=
k
G ( zq ) =
( L 1) pz ( zi ) =
sk
i =0
Mapping from sk to zq
2/6/2014
zq = G 1 ( sk )
43
2/6/2014
44
s0 1,=
s1 3,=
s2 5,=
s3 6,=
s4 7,
=
s5 7,=
s6 7,=
s7 7.
=
Compute all the values of the transformation function G,
0
=
G ( z0 ) 7=
pz ( z j ) 0.00
j =0
=
G ( z1 ) 0.00
G ( z2 ) 0.00 0
0
1
=
G ( z3 ) 1.05
G ( z4 ) 2.45 2
G ( z5 )
5
=
G ( z6 ) 5.95 6
4.55
G ( z7 ) = 7.00 7
2/6/2014
45
2/6/2014
46
s0 1,=
s1 3,=
s2 5,=
s3 6,=
s4 7,
=
s5 7,=
s6 7,=
s7 7.
=
Compute all the values of the transformation function G,
0
=
G ( z0 ) 7=
pz ( z j ) 0.00
j =0
=
G ( z1 ) 0.00
G ( z2 ) 0.00 0
0
1 s0 G ( z4 ) 2.45 2 s1
=
G ( z3 ) 1.05
G ( z5 )
5 s2 G ( z6 ) 5.95 6 s3
=
4.55
G ( z7 ) = 7.00 7
2/6/2014
s4 s5 s6 s7
47
rk
0
1
2
2/6/2014
3
4
5
6
7
48
49
2/6/2014
50
2/6/2014
51
2/6/2014
52
2/6/2014
53
2/6/2014
54
2/6/2014
55
L 1
m = ri p (ri )
i =0
u=
n (r )
Variance
L 1
(
r
m
)
p(ri )
i
i =0
=
2 u=
2 (r )
2/6/2014
1 M 1 N 1
f ( x, y )
=
MN =x 0=y 0
L 1
M 1 N 1
1
2
2
(
,
)
=
f
x
y
m
[
]
(ri m) p (ri )
MN =x 0=y 0
i =0
56
2
sxy
2/6/2014
L 1
(r m
i =0
s xy
) psxy (ri )
57
=
=
=
=
k0 0.4;
k1 0.02;
k2 0.4;
E 4
2/6/2014
58
Spatial Filtering
A spatial filter consists of (a) a neighborhood, and (b) a
predefined operation
Linear spatial filtering of an image of size MxN with a filter
of size mxn is given by the expression
=
g ( x, y )
w(s, t ) f ( x + s, y + t )
s=
a t=
b
2/6/2014
59
Spatial Filtering
2/6/2014
60
Spatial Correlation
The correlation of a filter w( x, y ) of size m n
with an image f ( x, y ), denoted as w( x, y ) f ( x, y )
w( x,=
y ) f ( x, y )
w(s, t ) f ( x + s, y + t )
s=
a t=
b
2/6/2014
61
Spatial Convolution
The convolution of a filter w( x, y ) of size m n
with an image f ( x, y ), denoted as w( x, y ) f ( x, y )
w( x,=
y ) f ( x, y )
w(s, t ) f ( x s, y t )
s=
a t=
b
2/6/2014
62
2/6/2014
63
2/6/2014
64
g ( x, y ) =
w(s, t ) f ( x + s, y + t )
s=
a t=
b
w(s, t )
s=
a t=
b
where m
= 2a + 1,
2/6/2014
=
n 2b + 1.
65
2/6/2014
66
2/6/2014
67
2/6/2014
68
2/6/2014
69
2/6/2014
70
Foundation
Laplacian Operator
2/6/2014
71
f
= f ( x + 1) f ( x)
x
2 f
= f ( x + 1) + f ( x 1) 2 f ( x)
2
x
2/6/2014
72
2/6/2014
73
f
2
f=
+ 2
2
x
y
2 f
= f ( x + 1, y ) + f ( x 1, y ) 2 f ( x, y )
2
x
2 f
=
f ( x, y + 1) + f ( x, y 1) 2 f ( x, y )
2
y
2 f = f ( x + 1, y ) + f ( x 1, y ) + f ( x, y + 1) + f ( x, y 1)
- 4 f ( x, y )
2/6/2014
74
2/6/2014
75
g ( x=
, y ) f ( x, y ) + c 2 f ( x, y )
where,
f ( x, y ) is input image,
g ( x, y ) is sharpenend images,
=
c -1 if 2 f ( x, y ) corresponding to Fig. 3.37(a) or (b)
and c = 1 if either of the other two filters is used.
2/6/2014
76
2/6/2014
77
Unsharp masking
Sharpen images consists of subtracting an unsharp (smoothed)
version of an image from the original image
e.g., printing and publishing industry
Steps
2/6/2014
78
2/6/2014
79
2/6/2014
80
2/6/2014
81
M ( x, y=
) mag(f =
)
gx2 + g y2
82
gx2 + g y2
M ( x, y ) | g x | + | g y |
z1
z4
z7
2/6/2014
z2
z5
z8
z3
z6
z9
M ( x, y ) =| z8 z5 | + | z6 z5 |
83
Sobel Operators
z1
z4
z7
2/6/2014
z2
z5
z8
z3
z6
z9
M ( x, y ) | ( z7 + 2 z8 + z9 ) ( z1 + 2 z2 + z3 ) |
+ | ( z3 + 2 z6 + z9 ) ( z1 + 2 z4 + z7 ) |
84
2/6/2014
85
Example
2/6/2014
86
Example:
Combining
Spatial
Enhancement
Methods
Goal:
Enhance the
image by
sharpening it
and by bringing
out more of the
skeletal detail
2/6/2014
87
Example:
Combining
Spatial
Enhancement
Methods
Goal:
Enhance the
image by
sharpening it
and by bringing
out more of the
skeletal detail
2/6/2014
88