You are on page 1of 47

1

Digital Image Processing, 2nd ed.


Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
Chapter 5
Image Restoration
Chapter 5
Image Restoration
The ultimate goal of restoration techniques is
to improve an image in some predefined sense.
- image enhancement is largely a subjective process
- image restoration is for the most part an objective process
Restoration attempts to reconstruct or recover an image that has been
degraded by using a priori knowledge of the degradation phenomenon.
- modeling the degradation
- applying the inverse process in order to recover the original image
Spatial processing is applicable when the only degradation is additive
noise.
Degradations such as image blur are approach in the frequency
domain, with filters based on various criteria of optimality.
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.1 A Model of
the Image Degradation/Restoration Process
5.1 A Model of
the Image Degradation/Restoration Process
f(x,y) : an input image
g(x,y) : a degraded image
h(x,y) : the degradation function
(x,y) : the additive noise
f(x,y) : an estimate of the original image
The more we know about h and , the closer f(x,y) will be to f(x,y).
2
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.1 A Model of
the Image Degradation/Restoration Process
5.1 A Model of
the Image Degradation/Restoration Process
If H is a linear, position-invariant process, then
g(x,y) = h(x,y) * f(x,y) + (x,y) (5.1-1)
G(u,v) = H(u,v) F(u,v) + N(u,v) (5.1-2)
In section 5.2 5.4, assume that H is the identity operator, and deal
only with degradations due to noise.
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.2 Noise Models
5.2 Noise Models
The principal sources of noise in digital images arise during
- image acquisition (digitization) and/or
- transmission.
3
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.2.1 Spatial and Frequency Properties of Noise
5.2.1 Spatial and Frequency Properties of Noise
With the exception of spatially periodic noise (Section 5.2.3),
assume that noise is
- independent of spatial coordinates, and
- uncorrelated with respect to the image itself
(there is no correlation between pixel values and
the values of noise components)
These assumptions are invalid in some applications
(quantum-limited imaging,
such as in X-ray and nuclear-medicine imaging)
The complexities of dealing with spatially dependent and
correlated noise are beyond the scope of our discussion.
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.2.2 Some Important Noise
Probability Density Functions
5.2.2 Some Important Noise
Probability Density Functions
The following are among the most common PDFs found in image
processing applications.
Gaussian noise (also called normal) (Fig. 5.2(a))
- used frequently in practice.
The PDF of a Gaussian random variable, z, is given by
(5.2-1)
z : gray level
: the mean of average value of z
: its standard deviation

2
: variance of z
2 2
2 / ) (
2
1
) (



=
z
e z p
4
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.2.2 Some Important Noise
Probability Density Functions
5.2.2 Some Important Noise
Probability Density Functions
Rayleigh noise (Fig. 5.2(b))
The PDF of a Rayleigh noise is given by
for z a (5.2-2)
for z < a
the mean and variance of this density are
(5.2-3)
(5.2-4)
The basic shape of this density is skewed to the right.
The Rayleigh density can be quite useful for approximating skewed
histograms.


=

0
) (
2
) (
/ ) (
2
b a z
e a z
b
z p
4
) 4 (
4 /
2

=
+ =
b
b a
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.2.2 Some Important Noise
Probability Density Functions
5.2.2 Some Important Noise
Probability Density Functions
Erlang (Gamma) noise (Fig. 5.2(c))
The PDF of a Erlang noise is given by
for z 0 (5.2-5)
for z < 0
where a > 0, b : positive integer, ! : factorial
the mean and variance of this density are
(5.2-6)
(5.2-7)
Although Eq.(5.2-5) often is referred to as the gamma density,
strictly speaking this is correct only when the denominator is the
gamma function, (b).

0
)! 1 (
) (
1
az
b b
e
b
z a
z p
2
2
a
b
a
b
=
=

5
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.2.2 Some Important Noise
Probability Density Functions
5.2.2 Some Important Noise
Probability Density Functions
Exponential noise (Fig. 5.2(d))
The PDF of a exponential noise is given by
for z 0 (5.2-8)
for z < 0
where a > 0
the mean and variance of this density function are
(5.2-9)
(5.2-10)
This PDF is a special case of the Erlang PDF, with b=1.

=

0
) (
az
ae
z p
2
2
1
1
a
a
=
=

Digital Image Processing, 2nd ed.


Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.2.2 Some Important Noise
Probability Density Functions
5.2.2 Some Important Noise
Probability Density Functions
Uniform noise (Fig. 5.2(e))
The PDF of a uniform noise is given by
if a z b (5.2-11)
otherwise
the mean and variance of this density are given by
(5.2-12)
(5.2-13)

=
0
1
) (
a b
z p
12
) (
2
2
2
a b
b a

=
+
=

6
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.2.2 Some Important Noise
Probability Density Functions
5.2.2 Some Important Noise
Probability Density Functions
Impulse (salt-and-pepper) noise (Fig. 5.2(f))
The PDF of (bipolar) impulse noise is given by
for z = a
for z = b (5.2-11)
otherwise
If b > a, gray-level b will appear as a light dot in the image.
gray-level a will appear like a dark dot.
If P
a
= P
b
= 0, the impulse noise is called unipolar.
If P
a
= P
b
( 0), impulse noise value will resemble
salt-and-pepper (or shot-and-spike) granules
randomly distributed over the image.

=
0
) (
b
a
P
P
z p
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.2.2 Some Important Noise
Probability Density Functions
5.2.2 Some Important Noise
Probability Density Functions
Noise impulses can be negative or positive.
scaling usually is part of
image digitizing process.
Impulse corruption usually is large
compared with the image signal.
pure black (pepper) or white (salt)
equal to the minimum and
maximum allowed values
in the digitized images.
7
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.2.2 Some Important Noise
Probability Density Functions
5.2.2 Some Important Noise
Probability Density Functions
The preceding PDFs provide useful tools for modeling a broad range
of noise corruption situations found in practice.
Gaussian noise : electronic circuit noise and sensor noise due to
poor illumination and/or high temperature
Rayleigh density : characterizing noise phenomena in range
imaging.
Exponential and gamma density : application in laser imaging
Impulse noise : quick transients, such as faulty switching,
take place during imaging.
Uniform density : useful as the basis for numerous random
number generators that are used in simulations
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
Fig.5.3 : a test pattern for
illustrating
the noise model
5.2.2 Some Important Noise
Probability Density Functions
5.2.2 Some Important Noise
Probability Density Functions
8
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.2.2 Some Important Noise
Probability Density Functions
5.2.2 Some Important Noise
Probability Density Functions
The parameters of
the noise were
chosen in each case
so that the histogram
corresponding to
the three gray levels
in the test pattern
would start to merge.
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.2.2 Some Important Noise
Probability Density Functions
5.2.2 Some Important Noise
Probability Density Functions
See a close
correspondence in
comparing the
histograms in Fig.5.4
with the PDFs in
Fig.5.2.
It is difficult to
differentiate visually
between the first five
images in Fig.5.4,
even though their
histograms are
significantly different.
9
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.2.3 Periodic Noise
5.2.3 Periodic Noise
Periodic noise in an image arises typically from electrical or
electromechanical interference during image acquisition.
spatially dependent noise
Periodic noise can be reduced significantly via frequency domain
filtering.
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.2.3 Periodic Noise
5.2.3 Periodic Noise
Fig.5.5(a) : corrupted by
(spatial) sinusoidal noise
of various frequencies
The Fourier transform of
a pure sinusoid is
a pair of conjugate impulses
located at the conjugate frequencies of the sine
wave (Table 4.1 (p.211)).
if the amplitude of a sine wave in
the spatial domain is strong enough,
expect to see in the spectrum of
the image a pair of impulses for
each sine wave in the image.
Fig.5.5(b)
10
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.2.4 Estimation of Noise Parameters
5.2.4 Estimation of Noise Parameters
The parameters of periodic noise typically are estimated by
inspection of the Fourier spectrum of the image.
Visual analysis
Automated analysis is possible in situations in which the noise
spikes are either exceptionally pronounced, or when some
knowledge is available
If the imaging system is available,
one simple way to study the characteristics of system noise is
to capture a set of images of flat environments. The resulting
images typically are good indicators of system noise.
When only images already generated by the sensor are available,
frequently it is possible to estimate the parameters of the PDF
from small patches of reasonably constant gray level.
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.2.4 Estimation of Noise Parameters
5.2.4 Estimation of Noise Parameters
Ex. The vertical strips (of 150 x 20 pixels) shown in Fig.5.6 were
cropped from the Gaussian, Rayleigh, and uniform images in Fig.5.4.
The shape of these histograms correspond quite closely to the
histograms in Fig.5.4.
11
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.2.4 Estimation of Noise Parameters
5.2.4 Estimation of Noise Parameters
The simplest way to use the data from the image strips is for
calculating the mean and variance of the gray levels.
If S is a strip (subimage),
(5.2-15)
(5.2-16)
Z
i
: the gray-level values of the pixels in S
p(z
i
) : the corresponding normalized histogram values
The shape of the histogram identifies the closest PDF match.
If the shape is approximately Gaussian, then mean and variance is all
we need because the Gaussian PDF is completely specified by these
two parameters.

=
=
S z
i i
S z
i i
i
i
z p z
z p z
) ( ) (
) (
2 2

Digital Image Processing, 2nd ed.


Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.3 Restoration in the Presence of Noise
Only-Spatial Filtering
5.3 Restoration in the Presence of Noise
Only-Spatial Filtering
When the only degradation present in an image is noise
g(x,y) = f(x,y) + (x,y) (5.3-1)
G(u,v) = F(u,v) + N(u,v) (5.3-2)
The noise terms are unknown, so subtracting then is not a realistic
option.
In the case of periodic noise, it usually is possible to estimate N(u,v)
from the spectrum of G(u,v), as noted in Section 5.2.3.
N(u,v) can be subtracted from G(u,v) to obtain an estimate of
F(u,v)
Spatial filtering is the method of choice in situations when only
additive noise is present.
12
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
Arithmetic mean filter
S
xy
: the set of coordinates in a rectangular subimage window of
size m x n, centered at point (x,y)
The arithmetic mean filtering process computes the average value of
the corrupted image g(x,y) in the area defined by S
xy
.
(5.3-3)
Noise is reduced as a result of blurring
5.3.1 Mean Filters
5.3.1 Mean Filters

=
xy
S t s
t s g
mn
y x f
) , (
) , (
1
) , (
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
Geometric mean filter
(5.3-4)
A geometric mean filter achieves smoothing comparable to the
arithmetic mean filter, but it tends to lose less image detail in the
process.
Harmonic mean filter
(5.3-5)
Works well for salt noise, but fails for pepper noise.
It does well also with other types of noise like Gaussian noise.
mn
S t s
t s g y x f
xy
1
) , (
) , ( ) , (
(

=

5.3.1 Geometric mean filter
5.3.1 Geometric mean filter

=
xy
S t s
t s g
mn
y x f
) , (
) , (
1
) , (
13
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
Contraharmonic mean filter
(5.3-6)
Q : the order of the filter
This filter is well suited for reducing or virtually eliminating the
effects of salt-and-pepper noise.
Positive values of Q eliminates pepper noise
Negative values of Q eliminates salt noise
cannot do both simultaneously
If Q = 0 the arithmetic mean filter
If Q = -1 the harmonic mean filter
5.3.1 Geometric mean filter
5.3.1 Geometric mean filter

+
=
xy
xy
S t s
Q
S t s
Q
t s g
t s g
y x f
) , (
) , (
1
) , (
) , (
) , (
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.3.1 Geometric mean filter
5.3.1 Geometric mean filter
(a) X-ray image
(b) Gaussian noise
zero mean
variance = 400
(c) Arithmetic mean
filter (size 3x3)
(d) Geometric mean
filter (size 3x3)
The geometric mean
filter did not blur the
image as much as
the arithmetic filter
14
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.3.1 Geometric mean filter
5.3.1 Geometric mean filter
(a) Pepper noise with
probability of 0.1
(b) Salt noise with
probability of 0.1
(c) filtering (a) using
contraharmonic
mean filter (Q=1.5)
(d) filtering (b) using
(Q= -1.5)
Positive-order filter did a better
job of cleaning the background,
at the expense of blurring the
dark areas.
The opposite was true of the negative-order filter.
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.3.1 Geometric mean filter
5.3.1 Geometric mean filter
The arithmetic and geometric mean filters (particularly the latter) are
well suited for random noise like Gaussian or uniform noise.
The contraharmonic filter is well suited for impulse noise
must be known whether the noise is dark or light in order to select
the proper sign for Q.
Fig.5.9 : The result of choosing the wrong sign for Q.
15
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.3.2 Order-Statistics Filters
5.3.2 Order-Statistics Filters
Order-statistics filters are spatial filters whose response is based on
ordering (ranking) the pixels contained in the image area
encompassed by the filter.
Median filter
replaces the value of a pixel by the median of the gray levels in the
neighborhood of that pixel
(5.3-7)
For certain types of random noise, they provide excellent noise-
reduction capabilities, with considerably less blurring than linear
smoothing filters of similar size.
)} , ( { ) , (
) , (
t s g median y x f
xy
S t s
=
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.3.2 Order-Statistics Filters
5.3.2 Order-Statistics Filters
Max and min filter
max filter
(5.3-8)
- Useful for finding the brightest points in an image.
- Because pepper noise has very low values,
it is reduced by this filter.
min filter
(5.3-9)
- Useful for finding the darkest points in an image.
- Reduces salt noise.
)} , ( { max ) , (
) , (
t s g y x f
xy
S t s
=
)} , ( { min ) , (
) , (
t s g y x f
xy
S t s
=
16
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.3.2 Order-Statistics Filters
5.3.2 Order-Statistics Filters
Midpoint filter
computes the midpoint between the maximum and minimum values
in the area.
(5.3-10)
This filter combines order statistics and averaging.
This filter works best for randomly distributed noise, like Gaussian
or uniform noise.
(

+ =

)} , ( { min )} , ( { max
2
1
) , (
) , ( ) , (
t s g t s g y x f
xy xy
S t s S t s
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.3.2 Order-Statistics Filters
5.3.2 Order-Statistics Filters
Alpha-trimmed mean filter
- delete the d/2 lowest and the d/2 highest gray-level values of g(s,t)
in the neighborhood S
xy
.
- g
r
(s,t) represent the remaining mn - d pixels.
- a filter formed by averaging these remaining pixels is called an
alpha-trimmed mean filter.
(5.3-11)
d can range from 0 to mn 1.
d = 0 the arithmetic mean filter.
d = (mn-1) a median filter.
Other value of d useful in situations involving multiple types of
noise, such as a combination of salt-and-pepper
and Gaussian noise

=
xy
S t s
r
t s g
d mn
y x f
) , (
) , (
1
) , (
17
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.3.2 Order-Statistics Filters
5.3.2 Order-Statistics Filters
(b) One pass with the
median filter.
(Several noise
points are still
visible.)
(c) Second pass with
the median filter.
(d) Third pass
Repeated passes of a median
filter tend to blur the image.
It is desirable to keep the
number of passes as low as
possible.
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.3.2 Order-Statistics Filters
5.3.2 Order-Statistics Filters
(a) Applying the max filter to the pepper noise image of Fig.5.8(a)
- also removed (set to a light gray level) some dark pixels.
(b) Applying the min filter to the salt noise image in Fig.5.8(b)
- in this particular case, did a better job than the max filter on
noise removal.
- removed some white points around the border of light objects
18
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.3.2 Order-Statistics Filters
5.3.2 Order-Statistics Filters
(a) Uniform noise (variance 800, zero mean)
(b) Further addition of salt-and-pepper noise
(P
a
= P
b
= 0.1)
(c) Arithmetic mean filter (size 5x5)
(d) Geometric mean filter (size 5x5)
(e) Median filter (size 5x5)
(f) alpha-trimmed mean (size 5x5, with d=5)
The arithmetic and geometric mean filters do
not do well because of the presence of
impulse noise.
The alpha-trimmed filter giving slightly better
noise reduction than median filter.
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.3.3 Adaptive Filters
5.3.3 Adaptive Filters
The filters discussed thus far are applied to an image without regard
for how image characteristics vary from one point to another.
Adaptive filter whose behavior changes based on statistical
characteristics of the image inside the filter region.
- Performance superior to that of the filters discussed thus far
- an increase in the filter complexity.
(we still are dealing with the case in which the degraded image is
equal to the original image plus noise.)
19
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.3.3 Adaptive Filters
5.3.3 Adaptive Filters
Adaptive, local noise reduction filter
The simplest statistical measures of a random variable are
- its mean (gives a measure of average gray level in the region)
- its variance (givers a measure of average contrast in that region)
Operate on a local region, S
xy
The response of the filter at any point (x,y) is to be based on four
quantities.
(a) g(x,y) : the value of the noisy image at (x,y)
(b)
2

: the variance of the noise corrupting f(x,y) to form g(x,y)


(c) m
L
: the local mean of the pixels in S
xy
(d)
2
L
: the local variance of the pixels in S
xy
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.3.3 Adaptive Filters
5.3.3 Adaptive Filters
Operation
(1) if
2

= 0 the filter should return simply the value of g(x,y)


(zero-noise case : g(x,y) = f(x,y) )
(2) if the local variance is high relative to
2

the filter should return a value close to g(x,y)


(the high local variance typically is associated with edges,
and these should be preserved.)
(3) if the two variances are equal
the filter should return the arithmetic mean value of
the pixels in S
xy
(the local area has the same properties as the overall image,
and the local noise is to be reduced simply by averaging.)
20
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
An adaptive expression:
(5.3-12)
The only quantity that needs to be known or estimated is the variance
of the overall noise,

2
.
The other parameters are computed from the pixels in S
xy
.
We seldom have exact knowledge of

2
.
it is possible for the condition (

2

L
2
) to be violated in practice.
a test should be built into an implementation of Eq.(5.3-12)
so that the ratio is set to 1 if the condition

2
>
L
2
occurs.
This makes this filter nonlinear, but it prevents negative gray levels.
Another approach is to allow the negative values to occur, and then
rescale the gray level values at the end.
a loss of dynamic range in the image
5.3.3 Adaptive Filters
5.3.3 Adaptive Filters
| |
L
L
m y x g y x g y x f = ) , ( ) , ( ) , (
2
2

Digital Image Processing, 2nd ed.


Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.3.3 Adaptive Filters
5.3.3 Adaptive Filters
(a) Gaussian noise (zero
mean, variance 1000)
(b) Arithmetic mean filter
(size 7 x 7)
(c) Geometric mean filter
(size 7 x 7)
(d) Using the adaptive
filter (size 7 x 7)
with

2
= 1000.
much sharper than (b) and (c)
If the quantity

2
is not known and
an estimates used that is too low,
the algorithm will return an image that closely resembles the original
because the corrections will be smaller than they should be.
21
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.3.3 Adaptive Filters
5.3.3 Adaptive Filters
Adaptive median filter
The median filter discussed in Section 5.3.2 performs well as long as
the spatial density of the impulse noise is not large (P
a
and P
b
< 0.2).
The adaptive median filtering can handle impulse noise with
probabilities even larger than these.
- preserve detail while smoothing nonimpulse noise
(traditional median filter does not do)
- the adaptive median filter changes (increases) the size of S
xy
during
filter operation, depending on certain conditions.
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.3.3 Adaptive Filters
5.3.3 Adaptive Filters
The key to understanding the mechanics of this algorithm is to keep in
mind that it has three main purposes:
- to remove salt-and-pepper (impulse) noise,
- to provide smoothing of other noise that may not be impulsive,
- and to reduce distortion, such as excessive thinning or thickening
of object boundaries..
z
min
= minimum gray level in S
xy
z
max
= maximum gray level in S
xy
z
med
= median of gray levels in S
xy
z
xy
= gray level at coordinates (x,y)
S
max
= maximum allowed size of S
xy
22
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.3.3 Adaptive Filters
5.3.3 Adaptive Filters
The adaptive median filtering algorithm.
Level A : A1 = z
med
- z
min
A2 = z
med
- z
max
If A1 > 0 AND A2 < 0, Go to level B
Else increase the window size
If window size S
max
repeat level A
Else output z
xy
.
Level B : B1 = z
xy
- z
min
B2 = z
xy
- z
max
If B1 > 0 AND B2 < 0, output z
xy
Else output z
med
considered to be
impulselike noise
considered to be
impulselike noise
determine if z
med
is
an impulse or not
true (z
min
< z
med
< z
max
)
not impulsego to level B
see if z
xy
is an impulse
true (z
min
< z
xy
< z
max
) not impulse
output z
xy
(unchanged pixel value)
false (z
xy
= z
min
or z
xy
= z
max
) impulse
output z
med
(not impulse)
false impulse increases the size
of the window and repeats level A.
This looping continues until the algorithm either finds
a median value that is not an impulse (and branches to
level B), or the maximum window size is reached
(returns the value of z
xy
).
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.3.3 Adaptive Filters
5.3.3 Adaptive Filters
No guarantee that this value is not an impulse
The smaller the noise probabilities P
a
and/or P
b
are, or the larger S
max
is allowed to be, the less likely it is that a premature exit condition
will occur.
As the density of the impulses increases, it stands to reason that we
would need a larger window to clean up the noise spikes.
23
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.3.3 Adaptive Filters
5.3.3 Adaptive Filters
The adaptive filter preserved sharpness and detail.
The choice of maximum allowed window size depends on the
application, but a reasonable starting value can be estimated by
experimenting with various size of the standard median filter first.
(a) Salt-and-pepper
noise with
P
a
= P
b
= 0.25
(b) 7x7 median filter
(loss of detail in
the image)
(c) Adaptive median
filtering with
S
max
= 7
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.4 Periodic Noise Reduction
by Frequency Domain Filtering
5.4 Periodic Noise Reduction
by Frequency Domain Filtering
- Bandreject filter
- Bandpass filter
- Notch filter
Tools for periodic noise reduction or removal.
24
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.4.1 Bandreject Filters
5.4.1 Bandreject Filters
An ideal bandreject filter :
(5.4-1)
D(u,v) : the distance from the origin of the centered frequency rectangle.
W : the width of the band
D
0
: its radial center

+ >
+
<
=
2
) , ( 1
2
) , (
2
0
2
) , ( 1
) , (
0
0 0
0
W
D v u D if
W
D v u D
W
D if
W
D v u D if
v u H
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.4.1 Bandreject Filters
5.4.1 Bandreject Filters
A Butterworth bandreject filter :
(5.4-2)
A Gaussian bandreject filter :
(5.4-3)
n
D v u D
W v u D
v u H
2
2
0
2
) , (
) , (
1
1
) , (
(

+
=
2
2
0
2
) , (
) , (
2
1
1 ) , (
(
(

=
W v u D
D v u D
e v u H
25
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.4.1 Bandreject Filters
5.4.1 Bandreject Filters
(a) Sinusoidal noise
of various
frequencies
(b) Spectrum of (a).
the pairs of bright
dots are the noise
components.
(c) Butterworth bandreject
filter of order 4
(d) Result of filtering.
It would not be possible to get equivalent results by a direct spatial
domain filtering approach using small convolution masks.
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.4.2 Bandpass Filters
5.4.2 Bandpass Filters
A bandpass filter performs the opposite operation of a band reject filter.
H
bp
(u,v) = 1 H
br
(u,v) (5.4-4)
Bandpass filtering generally remove too much image detail.
Bandpass filtering is quite useful in isolating the effect on an image of
selected frequency bands.
This image was generated by
(1) Using Eq.(5.4-4) to obtain the bandpass filter
corresponding to the band reject filter used in
the previous example
(2) taking the inverse transform of the band pass-filtered transform.
Most image detail was lost, but the information that remains is
most useful. noise pattern.
Bandpass filtering helped isolate the noise pattern.
26
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.4.3 Notch Filters
5.4.3 Notch Filters
Fig.5.18
Due to the symmetry of the Fourier transform,
notch filters must appear in symmetric pairs
about the origin.
The one exception is if the notch filter is
located at the origin.
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.4.3 Notch Filters
5.4.3 Notch Filters
The transfer function of an ideal notch reject filter :
(5.4-5)
Where
(5.4-6)
(5.4-7)
The transfer function of a Butterworth notch reject filter of order n :
(5.4-8)
A Gaussian notch reject filter :
(5.4-9)
These three filters become highpass filters if u
0
= v
0
= 0.
otherwise
D v u D or D v u D if
v u H
0 2 0 1
) , ( ) , (
1
0
) , (

=
| |
| |
2 / 1
2
0
2
0 2
2 / 1
2
0
2
0 1
) 2 / ( ) 2 / ( ) , (
) 2 / ( ) 2 / ( ) , (
v N v u M u v u D
v N v u M u v u D
+ =
+ =
n
v u D v u D
D
v u H
(

+
=
) , ( ) , (
1
1
) , (
2 1
2
0
(
(

=
2
0
2 1
) , ( ) , (
2
1
1 ) , (
D
v u D v u D
e v u H
27
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.4.3 Notch Filters
5.4.3 Notch Filters
Obtain notch filters that pass, rather than suppress, the frequencies
contained in the notch areas, by
H
np
(u,v) = 1 H
nr
(u,v) (5.4-10)
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.4.3 Notch Filters
5.4.3 Notch Filters
(a) The nearly horizontal lines of the noise pattern.
We expect its contribution in the frequency
domain to be concentrated along the vertical axis.
(b) Spectrum of (a).
(c) Ideal notch pass filter.
(used to obtain noise pattern)
(d) Noise pattern.
(corresponds closely to the pattern in (a) )
(e) Result of corresponding notch reject filter
28
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.4.4 Optimum Notch Filtering
5.4.4 Optimum Notch Filtering
Clearly defined interference patterns are not common.
Fig. 5.20(a)
The interference pattern is quit similar to the one shown in Fig.5.16(a),
but the former pattern is considerably more subtle and, consequently,
harder to detect in the frequency plane.
Fig. 5.20(b) : the Fourier spectrum of the image (a).
The starlike components were caused by the interference, and several
pairs of components
are present, indicating
that the pattern
contained more than
just one sinusoidal
component.
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.4.4 Optimum Notch Filtering
5.4.4 Optimum Notch Filtering
The optimum notch filtering is optimum, in the sense that it minimizes
local variances of the restored estimate f(x,y).
The procedure consists of
- first isolating the principal contributions of the interference pattern
- and then subtracting a variable, weighted portion of the pattern
from the corrupted image
29
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.4.4 Optimum Notch Filtering
5.4.4 Optimum Notch Filtering
The procedure :
- Placing a notch pass filter, H(u,v), at the location of each spike.
the Fourier transform of the interference noise pattern is
N(u,v) = H(u,v)G(u,v) (5.4-11)
- The corresponding pattern in the spatial domain is obtain from
(5.4-12)
- The effect of components not present in the estimate of (x,y) can be
minimized instead by subtracting from g(x,y) a weighted portion of
(x,y) to obtain an estimate of f(x,y)
(5.4-13)
w(x,y) is called a weighting or modulation function. Select this
function so that the result is optimized in some meaningful way.
{ } ) , ( ) , ( ) , (
1
v u G v u H v u

=
) , ( ) , ( ) , ( ) , (

y x y x w y x g y x f =
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.4.4 Optimum Notch Filtering
5.4.4 Optimum Notch Filtering
One approach is to select w(x,y) so that the variance of the estimate
f(x,y) is minimized over a specified neighborhood of every point (x,y).
w(x,y) is
(5.4-21)
where (x,y) is the average value of a in the neighborhood.
(see p.251-252 for the derivation of eq.(5.4-21))
To obtain the restored image f(x,y)
- compute w(x,y) from Eq.(5.4-21)
- use Eq.(5.4-13)
) , ( ) , (
) , ( ) , ( ) , ( ) , (
) , (
2
2
y x y x
y x y x g y x y x g
y x w

=
30
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.4.4 Optimum Notch Filtering
5.4.4 Optimum Notch Filtering
As w(x,y) is assumed to be constant in a neighborhood, computing this
function for every value of x and y in the image is unnecessary.
w(x,y) is computed for one point in each nonoverlapping neighborhood
(preferably the center point) and then used to process all the image
points contained in that neighborhood.
Fig.5.21 5.23
a neighborhood of size (2a+1) by (2b+1)
a = b = 15 .
Fig.5.21 :
Fourier spectrum (without shifting)
of the image shown in Fig.5.20(a).
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.4.4 Optimum Notch Filtering
5.4.4 Optimum Notch Filtering
(a) The spectrum of N(u,v), where only the spikes are present.
(b) Noise interference pattern (x,y) obtained by taking the inverse
Fourier transform of N(u,v)
Note the similarity between this pattern and the structure of the
noise present in Fig.5.20(a).
31
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.4.4 Optimum Notch Filtering
5.4.4 Optimum Notch Filtering
The processed image obtained by using E1.(5.4-13).
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.5 Linear, Position-Invariant Degradations
5.5 Linear, Position-Invariant Degradations
Degradation model:
g(x,y) = H[ f(x,y) ] + (x,y) (5.5-1)
Assume that (x,y)=0 so that g(x,y) = H[ f(x,y) ].
H is linear if
H[ af
1
(x,y) + bf
2
(x,y) ] = aH[f
1
(x,y) ] + bH[ f
2
(x,y) ] (5.5-2)
where a and b are scalars.
If a=b=1, Eq.(5.5-2) becomes
H[ f
1
(x,y) + f
2
(x,y) ] = H[ f
1
(x,y) ] + H[ f
2
(x,y) ] (5.5-3)
which is called the property of additivity.
with f
2
(x,y)=0, Eq.(5.5-2) becomes
H[ af
1
(x,y) ] = aH[ f
1
(x,y) ] (5.5-4)
which is called the property of homogeneity.
32
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.5 Linear, Position-Invariant Degradations
5.5 Linear, Position-Invariant Degradations
A linear operator possesses both the property of additivity and the
property of homogeneity.
g(x,y) = H[ f(x,y) ] is said to be position (or space) invariant if
H[ f(x-, y-) ] = g(x-, y-) (5.5-5)
This definition indicates that the response at any point in the image
depends only on the value of the input at that point, not on its position.

g(x,y) = h(x,y) * f(x,y) + (x,y) (5.5-16)


G(u,v) = H(u,v)F(u,v) + N(u,v) (5.5-17)
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.5 Linear, Position-Invariant Degradations
5.5 Linear, Position-Invariant Degradations
In summary, a linear, spatially-invariant degradation system with
additive noise
- can be modeled in the spatial domain as the convolution of the
degradation (point spread) function with an image, followed by (x,y).
- (the convolution theorem), the same process can be expressed in the
frequency domain as the product of the transforms of the image and
degradation, followed by the addition of N(u,v).
This chapter focuses on linear, space-invariant restoration techniques,
because degradations are modeled as being the result of convolution,
and restoration seeks to find filters that apply the process in reverse,
the term image deconvolution is used frequently to signify linear image
restoration.
The filter used in the restoration often are called deconvolution filters.
33
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.6 Estimating the Degradation Function
5.6 Estimating the Degradation Function
Three principal ways to estimate the degradation function use in
image restoration :
(1) Observation
(2) Experimentation
(3) Mathematical modeling
The process of restoring an image by using a degradation function
that has been estimated in some way sometimes is called blind
deconvolution.
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.6.1 Estimation by Image Observation
5.6.1 Estimation by Image Observation
One way is to gather information from the image itself. Ex.
- If the image is blurred, we can look at a small section of the image
containing simple structures, like part of an object and the background.
- We would look for areas of strong signal content.
- We can construct an unblurred image of the same size and
characteristics as the observed subimage.
g
s
(x,y) : observed subimage
f
s
(x,y) : constructed subimage
(our estimate of the original image in that area)
assuming that the effect of noise is negligible because of choice of a
strong-signal area.
(5.6-1)
assuming position invariance, we can construct a complete function
H(u,v) on a larger scale, but having the same shape.
) , (

) , (
) , (
v u F
v u G
v u H
S
S
s
=
34
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.6.2 Estimation by Experimentation
5.6.2 Estimation by Experimentation
If equipment similar to the equipment used to acquire the degraded
image is available, it is possible in principle to obtain an accurate
estimate of the degradation.
- set the system until images are degraded as closely as possible to
the image we wish to restore.
- obtain the impulse response of the degradation by imaging an
impulse (small dot of light) using the same system settings.
An impulse is simulated by a bright dot of light,
as bright as possible to reduce the effect of noise.
Fourier transform of an impulse is a constant. From Eq.(5.5-17),
(5.6-2)
G(u,v) : the Fourier transform of the observed image.
A : a constant describing the strength of the impulse.
A
v u G
v u H
) , (
) , ( =
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.6.2 Estimation by Experimentation
5.6.2 Estimation by Experimentation
35
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.6.3 Estimation by Modeling
5.6.3 Estimation by Modeling
Ex. The degradation
model proposed
by Hufnagel and
Stanley [1964] is
based on
the physical
characteristics of
atmospheric
turbulence.
(5.6-3)
k : a constant that depends on the
nature of the turbulence
6 / 5 2 2
) (
) , (
v u k
e v u H
+
=
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.6.3 Estimation by Modeling
5.6.3 Estimation by Modeling
Another major approach
Image has been blurred by uniform linear motion between the image
and the sensor during image acquisition.
x
0
(t) : the time varying components of motion in the x-directions
y
0
(t) : the time varying components of motion in the y-directions
T : the duration of the exposure
The blurred image (5.6-4)

(5.6-8)
G(u,v) = H(u,v) F(u,v) (5.6-9)
If the notation variable x
0
(t) and y
0
(t) are known, the transfer function
H(u,v) can be obtained directly from Eq.(5.6-8).
| |

=
T
dt t y y t x x f y x g
0
0 0
) ( ), ( ) , (
| |

+
=
T
t vy t ux j
dt e v u H
0
) ( ) ( 2
0 0
) , (

36
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.6.3 Estimation by Modeling
5.6.3 Estimation by Modeling
Suppose that the image in question undergoes uniform linear motion
in the x-direction only ( x
0
(t) = at/T, y
0
(t) = 0 )
when t = T, the image has been displaced by a total distance a.

(5.6-10)
If y
0
(t) = bt/T as well,
(5.6-11)
ua j
T
T uat j
T
t ux j
e ua
ua
T
dt e
dt e v u H

=
=
=

) sin(
) , (
0
/ 2
0
) ( 2
0
| |
) (
) ( sin
) (
) , (
vb ua j
e vb ua
vb ua
T
v u H
+
+
+
=

Digital Image Processing, 2nd ed.


Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.6.3 Estimation by Modeling
5.6.3 Estimation by Modeling
37
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.7 Inverse Filtering
5.7 Inverse Filtering
An estimate, F(u,v), of the transform of the original image,
(5.7-1)
Substituting G(u,v) from Eq.(5.5-17) in Eq.(5.7-1),
(5.7-2)
Even if we know the degradation function, we cannot recover the
undegraded image exactly, because N(u,v) is a random function whose
Fourier transform is not known.
If H(u,v) has zero or very small values,
then the ratio N(u,v)/H(u,v) could easily dominate the estimate
F(u,v)
) , (
) , (
) , (

v u H
v u G
v u F =
) , (
) , (
) , ( ) , (

v u H
v u N
v u F v u F + =
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
one approach is to limit the filter frequencies to values near the origin.
H(0,0) is equal to the average value of h(x,y), and usually the
highest value of H(u,v).
By limiting the analysis to frequencies near the origin, we reduce
the probability of encountering zero values.
Ex. Fig.5.25(b) was inverse filtered with Eq.(5.7-1) using the exact
inverse of the degradation function that generated that image.
The degradation function used was
with k=0.0025.
A Gaussian-shape function has no zeros. But the degradation values
became so small that the result of full inverse filtering is useless.
5.7 Inverse Filtering
5.7 Inverse Filtering
| |
6 / 5
2 2
) 2 / ( ) 2 / (
) , (
N v M u k
e v u H
+
=
38
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.7 Inverse Filtering
5.7 Inverse Filtering
(a) Full inverse filter.
Butterworth lowpass
function of order 10.
(b) Result with H cut
off outside a radius
of 40 (Radii below
70 tended toward blurred
images)
(c) Radii near 70 yielded the best
visual results
(d) values above 70 started to
produce degraded images.
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.8 Minimum Mean Square Error (Wiener) Filtering
5.8 Minimum Mean Square Error (Wiener) Filtering
The inverse filtering approach makes no explicit provision for
handling noise.
In this section we discuss an approach that incorporates both the
degradation function and statistical characteristics of noise into the
restoration process.
The objective is to find an estimate f of the uncorrupted image f
such that the mean square error between then is minimized.
(5.8-1)
assume that the noise and the image are uncorrelated.
one or the other has zero mean
The gray levels in the estimate are a linear function of
the levels in the degraded image.
{ }
2 2
)

( f f E e =
39
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.8 Minimum Mean Square Error (Wiener) Filtering
5.8 Minimum Mean Square Error (Wiener) Filtering
(5.8-2)
Wiener filter
minimum mean square error filter (least square error filter)
The Wiener filter does not have the same problem as the inverse
filter with zeros in the degradation function, unless both H(u,v) and
S

(u,v) are zero for the same value(s) of u and v.


) , (
) , ( / ) , ( ) , (
) , (
) , (
1
) , (
) , ( / ) , ( ) , (
) , ( *
) , (
) , ( ) , ( ) , (
) , ( *
) , (

2
2
2
2
) , (
v u G
v u S v u S v u H
v u H
v u H
v u G
v u S v u S v u H
v u H
v u G
v u S v u H v u S
S v u H
v u F
f
f
f
v u f
(
(

+
=
(
(

+
=
(
(

+
=

Digital Image Processing, 2nd ed.


Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.8 Minimum Mean Square Error (Wiener) Filtering
5.8 Minimum Mean Square Error (Wiener) Filtering
H(u,v) = degradation function
H*(u,v) = complex conjugate of H(u,v)
|H(u,v)|
2
= H*(u,v)H(u,v)
S

(u,v) = |N(u,v)|
2
= power spectrum of the noise
S
f
(u,v) = |F(u,v)|
2
= power spectrum of the undegraded image.
If the noise is zero, then the noise power spectrum vanishes and the
Wiener filter reduces to the inverse filter.
The power spectrum of the undegraded image seldom is known.
An approach used frequently is to approximate Eq.(5.8-2) by
(5.8-3)
K : a specified constant
) , (
) , (
) , (
) , (
1
) , (

2
2
v u G
K v u H
v u H
v u H
v u F
(
(

+
=
40
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.8 Minimum Mean Square Error (Wiener) Filtering
5.8 Minimum Mean Square Error (Wiener) Filtering
The value of K was chosen interactively to yield the best visual
results.
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.8 Minimum Mean Square Error (Wiener) Filtering
5.8 Minimum Mean Square Error (Wiener) Filtering
41
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.9 Constrained Least Squares Filtering
5.9 Constrained Least Squares Filtering
A constant estimate of the ratio of the power spectra in the Wiener filter
is not always a suitable solution.
Constrained Least Squares Filtering requires knowledge of only
the mean and variance of the noise.
These parameters usually can be calculated from a given degraded
image.
Wiener filter is based on minimizing a statistical criterion and, as such,
it is optimal in an average sense.
Constrained Least Squares Filter yields an optimal result for each
image to which it is applied.
(these optimality criteria, while satisfying from a theoretical point of
view, are not related to the dynamics of visual perception.)
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.9 Constrained Least Squares Filtering
5.9 Constrained Least Squares Filtering
In vector-matrix form
g = Hf + (5.9-1)
Central to the method is the issue of the sensitivity of H to noise.
One way to alleviate the noise sensitivity problem is to base
optimality of restoration on a measure of smoothness, such as the
second derivative of an image (the Laplacian)
Find the minimum of a criterion function, C,
(5.9-2)
subject to the constraint
||g Hf ||
2
= ||||
2
(5.9-3)
where is the Euclidean vector norm.
| |

=
=
1
0
1
0
2
2
) , (
M
x
N
y
y x f C

=
=
n
k
k
T
w
1
2
2
w w w
42
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.9 Constrained Least Squares Filtering
5.9 Constrained Least Squares Filtering
The frequency domain solution to this optimization problem is
(5.9-4)
: a parameter that must be adjusted so that the constraint
in Eq.(5.9-3) is satisfied
P(u,v) : the Fourier transform ot the function
(5.9-5)
p(x,y), recognized as the Laplacian operator, as well as all other
relevant spatial domain functions, must be properly padded with
zeros prior to computing their Fourier transform for use in Eq.(5.9-4).
If is zero, Eq.(5.9-4) reduces to inverse filtering.
) , (
) , ( ) , (
) , ( *
) , (

2 2
v u G
v u P v u H
v u H
v u F
(
(

+
=

(
(
(



=
0 1 0
1 4 1
0 1 0
) , ( y x p
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.9 Constrained Least Squares Filtering
5.9 Constrained Least Squares Filtering
The parameter in Eq.(5.9-4) is a scalar, while the value of K in
Eq.(5.8-3) is an approximation to the ratio of two unknown frequency
domain functions whose ratio seldom is constant.
manually selecting would be a more accurate estimation
Result of processing Fig.5.29(a), (d), and (g) with constrained least
squares filters. (select manually to yield the best visual results)
The constrained least
squares filter would
outperform the Wiener
filter when selecting
the parameters
manually for better
visual results.
43
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.9 Constrained Least Squares Filtering
5.9 Constrained Least Squares Filtering
It is possible to adjust the parameter interactively until acceptable
results are achieved.
If we are interested in optimality, must be adjusted so that the
constraint in Eq.(5.9-3) is satisfied.
A procedure for computing by iteration is as described
in p.268.
Optimum restoration in the sense of constrained least squares does
not necessarily imply best in the visual sense.
In general, automatically determined restoration filters yield inferior
results to manual adjustment of filter parameters.
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.9 Constrained Least Squares Filtering
5.9 Constrained Least Squares Filtering
Fig. 5.25(b),
44
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.10 Geometric Mean Filter
5.10 Geometric Mean Filter
The generalization :
(5.10-1)
(, : positive, real constants)
When =1 this filter reduces to the inverse filter.
With =0 the filter becomes the so-called parametric Wiener filter,
which reduces to the standard Wiener filter when =1.
With =1,
as decreases below , the filter will behave more like inverse filter.
as increases above , the filter will behave more like Wiener filter.
When = and =1, the filter is commonly referred to as the spectrum
equalization filter.
) , (
) , (
) , (
) , (
) , ( *
) , (
) , ( *
) , (

1
2
2
v u G
v u S
v u S
v u H
v u H
v u H
v u H
v u F
f

(
(
(
(
(

(
(

+
(
(

=
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.11 Geometric Transformations
5.11 Geometric Transformations
Geometric transformations often are called
Rubber-sheet transformations.
A geometric transformation consists of
(1) Spatial transformation : defines the re-arrangement of pixels
on the image plane
(2) Gray-level interpolation : deals with the assignment of gray
levels to pixels in the spatially transformed image.
45
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.11.1 Spatial Transformations
5.11.1 Spatial Transformations
Suppose that an image f(x,y) undergoes geometric distortion to
produce an image g(x,y).
x = r(x,y) (5.11-1)
y = s(x,y) (5.11-2)
If r(x,y) = x/2 and s(x,y) = y/2, the distortion is simply a shrinking
of the size of f(x,y) by one-half in both spatial directions.
Formulate the spatial relocation of pixels by the use of tiepoints,
which are a subset of
pixels whose location in
the input (distorted) and
output (corrected) images is
known precisely.
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.11.1 Spatial Transformations
5.11.1 Spatial Transformations
Suppose that the geometric distortion process within the quadrilateral
region is modeled by a pair of bilinear equations so that
r(x,y) = c
1
x + c
2
y + c
3
xy + c
4
(5.11-3)
s(x,y) = c
5
x + c
6
y + c
7
xy + c
8
(5.11-4)
Then, from Eqs.(5.11-1) and (5.11-2),
x = c
1
x + c
2
y + c
3
xy + c
4
(5.11-5)
y = c
5
x + c
6
y + c
7
xy + c
8
(5.11-6)
Since there are a total of eight known tiepoints, these equations can
be solved for the eight coefficients c
i
, i = 1,2,,8.
The coefficients constitute the geometric distortion model used to
transform all pixels within the quadrilateral region defined by the
tiepoints used to obtain the coefficients.
46
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.11.2 Gray-Level Interpolation
5.11.2 Gray-Level Interpolation
The simplest scheme for gray-level interpolation is based on a nearest
neighbor approach.
zero-order interpolation (Fig.5.33)
(1) The mapping of integer (x,y) coordinates into fractional coordinates
(x,y) by means of Eqs.(5.11-5) and (5.11-6)
(2) The selection of the closest integer coordinate neighbor to (x,y)
(3) The assignment of the gray level of this nearest neighbor to the
pixel located at (x,y).
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.11.2 Gray-Level Interpolation
5.11.2 Gray-Level Interpolation
Nearest neighbor interpolation has the drawback of producing
undesirable artifacts, such as distortion of straight edges in images of
high resolution.
Cubic convolution interpolation :
fits a surface of the sin (z) / z type through a much larger number of
neighbors (say, 16) in order to obtain a smooth estimate of the gray
level at any desired point.
used in 3D graphics, medical imaging
For general-purpose image processing
bilinear interpolation
use the gray levels of the four nearest neighbors
v(x,y) = ax + by + cxy + d (5.11-7)
47
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.11.2 Gray-Level Interpolation
5.11.2 Gray-Level Interpolation
The four coefficients are easily determined
from the four equations in four unknowns
that can be written using the four known
neighbors of (x,y).
When these coefficients have been
determined, v(x,y) is computed and this
value is assigned to the location in f(x,y).
The image have such few gray levels in
the sharp boundaries that almost any type
of geometric distortion will cause
significant degradation.
Digital Image Processing, 2nd ed.
Digital Image Processing, 2nd ed.
www.imageprocessingbook.com
2002 R. C. Gonzalez & R. E. Woods
Somkiat Wangsiripitak
5.11.2 Gray-Level Interpolation
5.11.2 Gray-Level Interpolation
When images have more texture,
geometric correction errors end to
be less noticeable.

You might also like