2. 2
Chapter 5
Image Restoration
Objectives:
To improve a given image in some predefined sense.
How MATLAB and Image Processing Tool models
degradation phenomena and formulate restoration
solutions.
Image restoration is an objective process while image
enhancement is subjective.
3. 3
A Model of the Image Degradation/Restoration Process
The degradation process is modeled as a degradation
function that together with an additive noise term, operates
on an input image f(x,y) to produce a degraded image
g(x,y):
Given g(x,y), some knowledge about the degradation
function H, and some knowledge about the additive noise
term , the objective of restoration is to obtain an
estimate, , of the original image as close as possible
to the original input image.
),()],([),( yxyxfHyxg
),( yx
),(ˆ yxf
5. 5
A Model of the Image Degradation/Restoration Process
If H is a linear, spatially invariant process, it can be shown
that the degraded image is given in the spatial domain by:
Where h(x,y) is the spatial representation of the degradation
function and “*” indicates convolution. We can also write
its frequency domain equivalent as:
Where all terms in capital letter refer to Fourier transform
of corresponding terms.
The degradation function H(u,v) is called the optical
transform function (OTF), and the h(x,y) is called the point
spread function. MATLAB provides conversion functions:
otf2psf and psf2otf.
),(),(),(),( yxyxfyxhyxg
),(),(),(),( vuNvuFvuHvuG
6. 6
A Model of the Image Degradation/Restoration Process
Because the degradation due to a linear, spatially invariant
degradation function, H, can be modeled as convolution,
sometimes the degradation process is referred to as
“convolving the image with a PSF or OTF”.
Similarly the restoration process is sometimes referred to as
deconvolution.
We first deal with cases where H is assumed to be an
identity operator, so it does not have any effect on the
process. This way we deal only with degradation noise.
Later we get H involve too.
7. 7
Noise Models
Ability to simulate the behavior and effects of noise is
crucial to image restoration.
We will look at two noise models:
• Noise in the spatial domain (described by the noise
probability density function), and
• Noise in the frequency domain, described by various
Fourier properties of the noise.
MATLAB uses the function imnoise to corrupt an image
with noise. This function has the basic syntax:
g = imnoise(f, type, parameters)
Where f is the input image, and type and parameters will
be described later.
8. 8
Adding Noise with Function imnoise
Function imnoise converts the input image to class double
in the range [0, 1] before adding noise to it.
This is very important to remember. For example, to add
Gaussian noise of mean 64 and variance 400 to a uint8
image, we scale the mean to 64/255 and the variance to
400/2552 for input into imnoise. Below is a summary of the
syntax for this function (see Page 143 for more information)
g = imnoise(f, ‘gaussian’, m, var)
g = imnoise(f, ‘localvar’, V)
g = imnoise(f, ‘localvar’, image_intensity, var)
g = imnoise(f, ‘salt & pepper’, d)
g = imnoise(f, ‘speckle’, var)
g = imnoise(f, ‘poisson’)
9. 9
Generating Spatial Random Noise with a Specified
Distribution
Often, we wish to generate noise of types and parameters
other than the ones listed on previous page. In such cases,
spatial noise are generated using random numbers,
characterized by probability density function (PDF) or by
the corresponding cumulative distribution function (CDF).
Two of the functions used in MATLAB to generate random
numbers are:
rand – to generate uniform random numbers, and
randn – to generate normal (Gaussian) random numbers.
10. 10
Example:
Assume that we have a random number generator that
generates numbers, w, uniformly in the [0 1] range.
Suppose we wish to generate random numbers with a
Rayleigh CDF, which is defined as:
az
aze
zF
baz
z
for0
for1
)(
/)( 2
To find z we solve the equation:
Or
Since the square root term is nonnegative, we are assured
that no values of z less than a are generated.
In MATALB: R = a + sqrt(b*log(1 – rand(M, N) ));
we baz
/)( 2
1
)1ln( wbaz
12. 12
imnoise vs. imnoise2
The imnoise function generates a 1D noise array, imnoise2
will generate an M-by-N noise array.
imnoise scales the noise array to [0 1], imnoise2 does not
scale at all and will produce the noise pattern itself. The
user specifies the parameters directly.
Note: The salt-and-pepper noise has three values:
0 corresponding to pepper noise
1 corresponding to salt noise, and
0.5 corresponding to no noise.
You can copy the imnoise2 function from the course web
page.
20. 20
0 10 20 30 40 50 60
0
1
2
3
4
5
6
7
8
9
10
x 10
4
r = imnoise2(‘salt & pepper', 100000, 1, 0.05, 0.05);
p = hist(r, 50);
bar(p) If r(x,y) = 0, black
If r(x,y) = 1, white
If r(x,y) = 0.5 none
21. 21
Periodic Noise
This kind of noise usually arises from electrical and/or
electromagnetical interference during image acquisition.
These kinds of noise are spatially dependent noise.
The periodic noise is handled in an image by filtering in
the frequency domain.
Our model for a periodic noise is:
Where A is amplitude, u0 and v0 determine the sinusoidal
frequencies with respect to the x- and y-axis, respectively,
and Bx and By are phase displacements with respect to the
origin. The M-by-N DFT of the equation is:
]/)(2/)(2[(),( 00 NByvMBxuSinAyxr yx
)],()(),()[(
2
),( 00
/2
00
/2 00
vvuuevvuue
A
jvuR
NBvjMBuj yx
22. 22
This statement shows a pair of complex conjugate impulses
located at (u+u0 , v+v0) and (u-u0 , v-v0), respectively.
A MATLAB function (imnoise3) accepts an arbitrary number
of impulse locations (frequency coordinates), each with its
own amplitude, frequencies, and phase displacement
parameters, and computes r(x, y) as the sum of sinusoids of
the form shown in the previous page.
The function also outputs the Fourier transform of the sum of
sinusoides, R(u,v) and the spectrum of R(u,v).
The sine waves are generated from the given impulse
location information via the inverse DFT.
Only one pair of coordinates is required to define the
location of an impulse.
The program generates the conjugate symmetric impulses.
23. 23
C = [0 64; 0 128; 32 32; 64 0; 128 0; -32 32];
[r, R, S] = imnoise3(512, 512, C);
imshow(S, []);
C is k-by-2 matrix
containing K pairs
of frequency
domain coordinates
(u,v)
r is the noise
pattern of size M-
by-N
R is the Fourier
transform of r
S is the spectrum
of R