Professional Documents
Culture Documents
cr s =
c ) ( + = r c s
1 <
1 >
Monitor,
5 . 2 =
Piecewise-linear transformation
functions
The form of piecewise functions can be
arbitrarily complex
Contrast stretching
Gray-level slicing
Bit-plane slicing
Histogram Processing
Histogram
where is the kth gray level and is
the number of pixels in the image
having gray level
Normalized histogram
k k
n r h = ) (
k
r
k
n
k
r
n n r p
k k
/ ) ( =
Histogram equalization
1 0 ), ( s s = r r T s
1 0 ), (
1
s s =
s s T r
Probability density functions (PDF)
ds
dr
r p s p
r s
) ( ) ( =
}
= =
r
r
dw w p r T s
0
) ( ) (
) ( ) (
) (
0
r p dw w p
dr
d
dr
r dT
dr
ds
r
r
r
=
(
= =
}
1 ) ( = s p
s
1 ,..., 2 , 1 , 0 , ) ( ) (
0 0
= = = =
= =
L k
n
n
r p r T s
k
j
j
k
j
j r k k
Histogram matching (specification)
}
= =
r
r
dw w p r T s
0
) ( ) (
}
= =
z
z
s dt t p z G
0
) ( ) (
)] ( [ ) (
1 1
r T G s G z
= =
) (z p
z
is the desired PDF
1 ,..., 2 , 1 , 0 , ) ( ) (
0 0
= = = =
= =
L k
n
n
r p r T s
k
j
j
k
j
j r k k
1 ,..., 2 , 1 , 0 , ) ( ) (
0
= = = =
=
L k s z p z G v
k
k
i
i z k k
1 ,..., 2 , 1 , 0 )], ( [
1
= =
L k r T G z
k k
Histogram matching
Obtain the histogram of the given
image, T(r)
Precompute a mapped level for each
level
Obtain the transformation function G
from the given
Precompute for each value of
Map to its corresponding level ;
then map level into the final level
) (z p
z
k
s
k
r
k
z
k
s
k
r
k
s
k
s
k
z
Local enhancement
Histogram using a local neighborhood,
for example 7*7 neighborhood
Use of histogram statistics for
image enhancement
denotes a discrete random variable
denotes the normalized
histogram component corresponding to
the ith value of
Mean
) (
i
r p
r
r
=
=
1
0
) (
L
i
i i
r p r m
The nth moment
The second moment
=
=
1
0
) ( ) ( ) (
L
i
i
n
i n
r p m r r
=
=
1
0
2
2
) ( ) ( ) (
L
i
i i
r p m r r
Global enhancement: The global mean
and variance are measured over an
entire image
Local enhancement: The local mean
and variance are used as the basis for
making changes
is the gray level at coordinates
(s,t) in the neighborhood
is the neighborhood normalized
histogram component
mean:
local variance
t s
r
,
) (
,t s
r p
e
=
xy
xy
S t s
t s t s S
r p r m
) , (
, ,
) (
e
=
xy
xy xy
S t s
t s S t s S
r p m r
) , (
,
2
,
2
) ( ] [ o
are specified parameters
is the global mean
is the global standard deviation
Mapping
2 1 0
, , , k k k E
G
M
G
D
s s
s
=
otherwise ) , (
and
if
) , (
) , (
2 1
0
y x f
D k D k
M k m
y x f E
y x g
G S G
G S
xy
xy
o
Enhancement Using Arithmetic/Logic
Operations
AND
OR
NOT
Subtraction
Addition
Multiplication
Division
Image subtraction
Enhancement of differences between
images
) , ( ) , ( ) , ( y x h y x f y x g =
Mask mode radiography
Image Averaging
Averaging K different noisy images
) , ( ) , ( ) , ( y x y x f y x g q + =
=
=
K
i
i
y x g
K
y x g
1
) , (
1
) , (
{ } ) , ( ) , ( y x f y x g E =
2
) , (
2
) , (
1
y x y x g
K
q
o o =
) , ( ) , (
1
y x y x g
K
q
o o = ,
Basics of Spatial Filtering
) 1 , 1 ( ) 1 , 1 (
) , 1 ( ) 0 , 1 (
) , ( ) 0 , 0 (
) , 1 ( ) 0 , 1 (
) 1 , 1 ( ) 1 , 1 (
+ +
+ +
+ +
+ +
+ =
y x f w
y x f w
y x f w
y x f w
y x f w R
Image size:
Mask size:
and
and
N M
n m
= =
+ + =
a
a s
b
b t
t y s x f t s w y x g ) , ( ) , ( ) , (
2 / ) 1 ( = m a 2 / ) 1 ( = n b
1 ,..., 2 , 1 , 0 = M x 1 ,..., 2 , 1 , 0 = N y
=
=
+ + + =
9
1
9 9 2 2 1 1
...
i
i i
z w
z w z w z w R
Smoothing Spatial Filters
Smoothing
Noise reduction
Smoothing of false contours
Reduction of irrelevant detail
=
=
9
1
9
1
i
i
z R
= =
= =
+ +
=
a
a s
b
b t
a
a s
b
b t
t s w
t y s x f t s w
y x g
) , (
) , ( ) , (
) , (
Order-statistic filters
median filter: Replace the value of a
pixel by the median of the gray levels
in the neighborhood of that pixel
Noise-reduction
Sharpening Spatial Filters
Foundation
The first-order derivative
The second-order derivative
) ( ) 1 ( x f x f
x
f
+ =
c
c
) ( 2 ) 1 ( ) 1 (
2
2
x f x f x f
x
f
+ + =
c
c
Use of second derivatives for
enhancement-The Laplacian
Development of the method
) , ( 2 ) , 1 ( ) , 1 (
2
2
y x f y x f y x f
x
f
+ + =
c
c
2
2
2
2
2
y
f
x
f
f
c
c
+
c
c
= V
) , ( 2 ) 1 , ( ) 1 , (
2
2
y x f y x f y x f
y
f
+ + =
c
c
) , ( 4 )] 1 , (
) 1 , ( ) , 1 ( ) , 1 ( [
2
y x f y x f
y x f y x f y x f f
+ + + + + = V
V +
V
=
positive is
mask Laplacian the of
t coefficien center the if
) , ( ) , (
negative is
mask Laplacian the of
t coefficien center the if
) , ( ) , (
) , (
2
2
y x f y x f
y x f y x f
y x g
Simplifications
)] 1 , (
) 1 , ( ) , 1 ( ) , 1 ( [ ) , ( 5
) , ( 4 )] 1 , (
) 1 , ( ) , 1 ( ) , 1 ( [ ) , ( ) , (
+ + + + + =
+
+ + + + + =
y x f
y x f y x f y x f y x f
y x f y x f
y x f y x f y x f y x f y x g
Unsharp masking and high-boost
filtering
Unsharp masking
Substract a blurred version of an image
from the image itself
: The image, : The
blurred image
) , ( ) , ( ) , ( y x f y x f y x f
s
=
) , ( y x f
) , ( y x f
High-boost filtering
) , ( ) , ( ) , ( y x f y x Af y x f
hb
=
) , ( ) , ( ) , ( ) 1 ( ) , ( y x f y x f y x f A y x f
hb
+ =
) , ( ) , ( ) 1 ( ) , ( y x f y x f A y x f
s hb
+ =
Use the Laplacian as the sharpening
filtering
V +
V
=
positive is
mask Laplacian the of
t coefficien center the if
) , ( ) , (
negative is
mask Laplacian the of
t coefficien center the if
) , ( ) , (
2
2
y x f y x Af
y x f y x Af
f
hb
Use of first derivatives for
enhancementThe gradient
(
(
(
(
c
c
c
c
=
(
= V
y
f
x
f
G
G
y
x
f
The magnitude is rotation invariant
(isotropic)
| |
2
1
2
2
2
1
2 2
) ( mag
(
(
|
|
.
|
\
|
c
c
+
|
.
|
\
|
c
c
=
+ = V = V
y
f
x
f
G G f
y x
f
y x
G G f + ~ V
Computing using cross differences,
Roberts cross-gradient operators
) (
5 9
z z G
x
= ) (
6 8
z z G
y
=
and
| |
2
1
2
6 8
2
5 9
) ( ) ( z z z z f + = V
6 8 5 9
z z z z f + ~ V
Sobel operators
A weight value of 2 is to achieve some
smoothing by giving more importance to
the center point
) 2 ( ) 2 (
) 2 ( ) 2 (
7 4 1 9 6 3
3 2 1 9 8 7
z z z z z z
z z z z z z f
+ + + + +
+ + + + ~ V
Combining Spatial Enhancement
Methods
An example
Laplacian to highlight fine detail
Gradient to enhance prominent edges
Smoothed version of the gradient
image used to mask the Laplacian
image
Increase the dynamic range of the gray
levels by using a gray-level
transformation
Example 1
Histogram Equalization
(a) Write a computer program for computing the
histogram of an image.
(b) Implement the histogram equalization technique
discussed in Section 3.3.1.
(c) Download Fig. 3.8(a) and perform histogram
equalization on it.
Fig3.08(a).bmp
histo.c
Example 2
Arithmetic Operations
Write a computer program capable of performing the
four arithmetic operations between two images. This
project is generic, in the sense that it will be used in
other projects to follow. (See comments on pages
112 and 116 regarding scaling). In addition to
multiplying two images, your multiplication function
must be able to handle multiplication of an image by
a constant.
Fig3.08(a).bmp
new2.bmp
arithmetic.c