# Image Enhancement in the Spatial Domain

AI and Robotics

Nov 6, 2013 (4 years and 6 months ago)

70 views

Chapter
3

Image Enhancement in the Spatial
Domain

Background

Some Basic Gray Level Transformations

Histogram Processing

Enhancement Using Arithmetic/Logic Operations

Basics of Spatial Filtering

Smoothing Spatial Filters

Sharpening Spatial Filters

Co
mbining Spatial Enhancement Methods

Background

Spatial domain processes

)]
,
(
[
)
,
(
y
x
f
T
y
x
g

where
)
,
(
y
x
f

is the input image,
)
,
(
y
x
g

is the processed image, and
T

is an
operato
r on
f
, defined over some neighborhood of
)
,
(
y
x
.

T
can operate on a
set

of input images, such as performing the pixel
-
by
-
pixel sum of
K
images for noise reduction.

filters,

kernels,

templates

windows

Point processing

A
gray
-
leve
l

(also called an
intensity

or
mapping) transformation function

)
(
r
T
s

Contrast stretching
,

Thresholding

function

Some Basic Gray Level Transformations

Image Negatives

The negative of an image with g
ray levels in the range
]
1
,
0
[

L

is obtained by using the
negative transformation shown in Fig. 3.3, which is given by the expression

r
L
s

1

Log Transformations

The general form of the log transformation s
hown in Fig. 3.3 is

r)
(
c
s

1
log

Power
-
Law Transformations

Power
-
law transformations have the basic form

cr
s

Piecewi
se
-
Linear

Transformation Functions

Contrast stretching

Gray
-
level slicing

Bit
-
plane slicing

Histogram Processing

The histogram of a digital image with
gray levels in the range
]
1
,
0
[

L

is a
discrete function
k
k
n
r
h

)
(
,

where
k
r

is
the

kth

gray level and
k
n
is the number of
pixels in the image having gray level
k
r
.

The right side of the figure shows the
histograms corresponding to these
images. The horizontal axis of each
histogram plot correspon
ds to gray level
values,

k
r
.
The vertical axis corresponds
to values of
k
k
n
r
h

)
(

or
n
n
r
p
k
k
/
)
(

if the values are normalized.

Histogram Equalization

)
(
r
T
s

1
0

r

(a)

)
(
r
T

is single
-
valued and monotonically increasing in the interval
1
0

r
;
and

(b)

1
)
(
0

r
T

for 0 <
r <

1.

Let
)
(
r
p
r

and
)
(
s
p
s

denote the probability density functions of random variables
r

and
s,

respectively

ds
dr
r
p
s
p
r
s
)
(
)
(

A transformation function of particular importance in image processing has the form

r
r
dw
w
p
r
T
s
0
)
(
)
(

W
e find
)
(
s
p
s
as a uniform probability function

by applying

)
(
)
(
)
(
0
r
p
dw
w
p
dr
d
dr
r
dT
dr
ds
r
r
r

1
)
(
1
)
(
)
(
)
(

r
p
r
p
ds
dr
r
p
s
p
r
r
r
s

1
0

s

For discrete values,

T
he probability of occurrence of gray level
k
r

in an image is approximated by

1
,
,
2
,
1
,
0
)
(

L
k
n
n
r
p
k
k
r

The discrete version of the transformation function is given as

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)

Development of the method

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

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
s
G
z
k
k

1
,
,
2
,
1
,
0
0
)
)
ˆ
(
(

L
k
s
z
G
k

Implementation

The procedure we have just developed for histogram matching may be sum
-
marized as follows:

1. Obtain the hi
stogram of the given image.

2. Use
1
,
,
2
,
1
,
0
)
(
)
(
0
0

L
k
n
n
r
p
r
T
s
k
j
j
k
j
j
r
k
k

to precompute a mapped
level
k
s

for each level
k
r
.

3. Obtain the transformation function
G

from the given
)
(
z
p
z

using
1
,
,
2
,
1
,
0
)
(
)
(
0

L
k
s
z
p
z
G
v
k
k
i
i
z
k
k

.

4. Precompute
k
z

for each value of
k
s
, where
z
z
k
ˆ

is the smallest integer such
that
1
,
,
2
,
1
,
0
0
)
)
ˆ
(
(

L
k
s
z
G
k

.

5. For each pixel in the original image, if the value of that pixel is
k
r
, map this
value to its corresponding level
k
s
; then map level
k
s
into the final level
k
z
. Use
the precomputed values from Steps (2) and (4) for these mappings.

Local Enhancement

Use of Histogram Statistics for Image Enhancement

G
lobal

mean and variance

1
0
)
(
)
(
)
(
L
i
i
n
i
n
r
p
m
r
r

1
0
)
(
L
i
i
i
r
p
r
m

1
0
2
2
2
)
(
)
(
)
(
)
(
L
i
i
i
r
p
m
r
r
r

L
ocal

mean and variance

xy
xy
S
t
s
t
s
t
s
S
r
p
r
m
)
,
(
,
,
)
(

xy
xy
xy
S
t
s
t
s
S
t
s
S
r
p
m
r
)
,
(
,
,
2
)
(
]
[

S
ummary of the enhancement method

otherwise
y
x
f
D
k
D
k
and
M
k
m
if
y
x
f
E
y
x
g
G
S
G
G
S
xy
xy
)
,
(
)
,
(
)
,
(
1
1
0

where
E
,
0
k
,
1
k
,

and
2
k

are specified parameters;
G
M

is the global mean of

the input image; and
G
D

is its global standard deviation.

0
.
4

E
,
4
.
0
0

k
,
02
.
0
1

k
,

and
4
.
0
2

k

Enhancement Using Arithmetic/Logic Operations

Image Subtraction

)
,
(
)
,
(
)
,
(
y
x
h
y
x
f
y
x
g

The values in a difference image can range from a minimum of
-
255 to a
maximum of 255

One method is t
o add 255 to every pixel and then divide by 2

The other method, at
first, the value of the minimum difference is ob
tained and
its negative added to all the pixels in the difference image. Then, all the pixels in
the image are scaled to the interval [0, 25
5] by multiplying each pixel by the
quantity
255/Max,

where Max is the maximum pixel value in the modi
fied
difference image

Image Averaging

)
,
(
)
,
(
)
,
(
y
x
y
x
f
y
x
g

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

)
,
(
)
,
(
1
y
x
y
x
g
K

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

a
a
s
b
b
t
t
y
s
x
f
t
s
w
y
x
g
)
,
(
)
,
(
)
,
(

9
1
9
9
2
2
1
1
i
i
i
z
w
z
w
z
w
z
w
R

mn
i
i
i
mn
mn
z
w
z
w
z
w
z
w
R
1
2
2
1
1

Smoothing Spatial Filters

Smoothing Linear Filters

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
-
Statistics Filters

Median filter

Median filters are particularly effectiv
e in the presence of
impulse noise
,

also
called
salt
-
and
-
pepper

noise

Max filter

Min filter

Sharpening Spatial Filters

Foundation

)
(
)
1
(
x
f
x
f
x
f

)
(
2
)
1
(
)
1
(
2
2
x
f
x
f
x
f
x
f

Use of Second Derivatives for
Enhancement
-
The

Laplacian

2
2
2
2
2
y
f
x
f
f

)
,
(
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

)
,
(
4
)]
1
,
(
)
1
,
(
)
,
1
(
)
,
1
(
[
y
x
f
y
x
f
y
x
f
y
x
f
y
x
f
f

positive
is
Laplacian
the
of
t
coefficien
center
the
if
)
,
(
)
,
(
negative
is
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

(3.7
-
5)

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

mas
king and high
-
boost filtering

)
,
(
)
,
(
)
,
(
y
x
f
y
x
f
y
x
f
s

where
)
,
(
y
x
f
s

denotes the sharpened image obtained by unsharp masking, and
)
,
(
y
x
f

is a blurred version of

)
,
(
y
x
f

High
-
boost filterin
g

)
,
(
)
,
(
)
,
(
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

positive
is
Laplacian
the
of
t
coefficien
center
the
if
)
,
(
)
,
(
negative
is
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 Enhancement

y
f
x
f
G
G
f
y
x

2
/
1
2
2
)
(
y
x
G
G
f
mag
f

y
x
G
G
f

)
(
5
9
z
z
G
x

)
(
6
8
z
z
G
y

2
/
1
2
6
8
2
5
9
)
(
)
(
z
z
z
z
f

Roberts cross
-

6
8
5
9
z
z
z
z
f

Sobel operator

)
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

Combining Spatial Enhancement Methods