ELECTRONICS ENGINEERING
SUBJECT:
STUDENT NAME:
MWIGHUSA ()
SUPERVISOR:
PROJECT TITLE:
IMAGE RESTORATION
DATE: 24TH NOVEMBER
1|Page
Overview:
In the past two decades, the technique of image processing has made its way into every aspect of
todays tech-savvy society. Its applications encompass a wide variety of specialized disciplines
including medical imaging, machine vision, remote sensing and astronomy. Personal images
captured by various digital cameras can easily be manipulated by a variety of dedicated image
processing algorithms. Image restoration can be described as an important part of image processing
technique. The basic objective is to enhance the quality of an image by removing defects and make
it look pleasing. The method used to carry out the project was MATLAB software. Mathematical
algorithms were programmed and tested for the result to find the necessary output. In this project
mathematical analysis was the basic core. Generally the spatial and frequency domain methods
were both important and applicable in different technologies. This project has tried to show the
comparison between spatial and frequency domain approaches and their advantages and
disadvantages. This project also suggested that more research have to be done in many other image
processing applications to show the importance of those methods.
Acknowledgements:
The author remains thankful to Dr. Ding Xuewen (Dr. & Lecturer, Dept. of Electronics &
Electrical Engineering, Tianjin University of Technology & Education, Tianjin, China P.R) for his
useful discussions and suggestions during the preparations of this project.
2|Page
Contents
Introduction..1
Image Noise Model..2
Noise Types.3
Filters...6
Filtering Techniques7
Noise Filtering in Spatial and Frequency Domain...8
Filtering to remove noise.8
Order statistic filters...11
Adaptive Filters..15
Adaptive Filters Example..17
Periodic Noise17
Band Reject Filters.17
Band Reject Filters Example.18
Advantage and Disadvantage of Spatial and Frequency Domain Methods...19
Conclusion.19
Reference...20
3|Page
IMAGE RESTORATION
Introduction
Image Restoration is the process of obtaining the original image from the degraded image given
the knowledge of the degrading factors. Digital image restoration is a field of engineering that
studies methods used to recover original scene from the degraded images and observations.
Techniques used for image restoration are oriented towards modeling the degradations, usually
blur and noise and applying various filters to obtain an approximation of the original scene. There
are a variety of reasons that could cause degradation of an image and image restoration is one of
the key fields in today's Digital Image Processing due to its wide area of applications. Commonly
occurring degradations include blurring, motion and noise. Blurring can be caused when object in
the image is outside the cameras depth of field sometime during the exposure, whereas motion
blur can be caused when an object moves relative to the camera during an exposure.
The purpose of image restoration is to "compensate for" or "undo" defects which degrade an image.
Degradation comes in many forms such as motion blur, noise, and camera misfocus. In cases like
motion blur, it is possible to come up with a very good estimate of the actual blurring function and
"undo" the blur to restore the original image. In cases where the image is corrupted by noise, the
best we may hope to do is to compensate for the degradation it caused. In this project, we will
introduce and implement several of the methods used in the image processing world to restore
images. The field of image restoration (sometimes referred to as image de-blurring or image deconvolution) is concerned with the reconstruction or estimation of the uncorrupted image from a
blurred and noisy one. Essentially, it tries to perform an operation on the image that is the inverse
of the imperfections in the image formation system. In the use of image restoration methods, the
characteristics of the degrading system and the noise are assumed to be known a priori. In practical
situations, however, one may not be able to obtain this information directly from the image
formation process. The goal of blur identification is to estimate the attributes of the imperfect
imaging system from the observed degraded image itself prior to the restoration process. The
combination of image restoration and blur identification is often referred to as blind image deconvolution. Image restoration algorithms distinguish themselves from image enhancement
methods in that they are based on models for the degrading process and for the ideal image. For
4|Page
those cases where a fairly accurate blur model is available, powerful restoration algorithms can be
arrived at. Unfortunately, in numerous practical cases of interest, the modeling of the blur is
unfeasible, rendering restoration impossible. The limited validity of blur models is often a factor
of disappointment, but one should realize that if none of the blur models described in this chapter
are applicable, the corrupted image may well be beyond restoration. Therefore, no matter how
powerful blur identification and restoration algorithms are, the objective when capturing an image
undeniably is to avoid the need for restoring the image.
In restoration process, degradation is taken to be a linear spatially invariant operator
(, ) = (, ) (, ) + (, )
where, if g(x, y) is noise free, restoration can be done by using the inverse transfer function of h(u,
v) as the restoration filter and (x, y) is the noise. The restoration techniques use various types of
filters for achieving best performance, like inverse filter, wiener filter, constrained least square
filter, Histogram Adaptive Fuzzy filter, Min-max Detector Based filter and Centre Weighted Mean
filter etc.
5|Page
Noise Types
For an image to be restored it is important to know the features of the noises that caused its
degradation. They have different features but the most important in this project are the spatial and
frequency properties.
Spatial properties mean dealing with the statistical behaviors of the noise component, while in
frequency properties deal with the frequency contents of the noise in Fourier form. There are
many noise patterns in image processing and some of them include:
a) Gaussian noise is a noise type initiated by a Gaussian amplitude distribution. The Gaussian
probability distribution has a a probability density function of
2
2
1
() = 2 () 2
where is the gray level is the mean, is the standard deviation and 2 is the variance.
b) Erlang (Gamma) noise is a noise having a probability distribution function of
() = {
(1)!
0
where the mean is a =
and ! is factorial.
0
< 0
()2
+
2
where the mean = 2 is and = 12 is variance.
e) Impulse noise(Salt-and-pepper) is a noise type with a probability density function of
=
() = {
=
0
6|Page
Noise Example
The test pattern to the right is ideal for demonstrating the addition of noise, The following
images will show the result of adding noise based on various models to the original image.
7|Page
Original Image
8|Page
Histogram
Filters
Elimination of noise is one of the major works to be done in computer vision and image processing,
as noise leads to the error in the image. Presence of noise is manifested by undesirable information,
which is not at all related to the image under study, but in turn disturbs the information present in
the image. It is translated into values, which are getting added or subtracted to the true gray level
values on a gray level pixel. These unwanted noise information can be introduced because of so
many reasons like: acquisition process due to cameras quality and restoration, acquisition
condition, such as illumination level, calibration and positioning or it can be a function of the scene
environment. Noise elimination is a main concern in computer vision and image processing. A
digital filter is used to remove noise from the degraded image. As any noise in the image can be
result in serious errors. Noise is an unwanted signal, which is manifested by undesirable
information. Thus the image, which gets contaminated by the noise, is the degraded image and
using different filters can filter this noise. Thus filter is an important subsystem of any signal
processing system. Thus filters are used for image enhancement, as it removes undesirable signal
components from the signal of interest. Filters are of different type i.e. linear filters or nonlinear
filters. In early times, as the signals handled were analog, filters used are of analog. Gradually
digital filters were took over the analog systems because of their flexibility, low cost,
programmability, reliability, etc. for these reasons digital filters are designed which works with
digital signals.
9|Page
Filtering Techniques
Filtering is a technique for enhancing the image. Linear filter is the filtering in which the value of
an output pixel is a linear combination of neighborhood values, which can produce blur in the
image. Thus a variety of smoothing techniques have been developed that are non linear.
Median Filtering
Median filter (MF) is the one of the most popular non-linear filter. Median filtering is one of the
spatial domain filter methods and as its name suggests that the median of the neighborhood pixel
value is taken and replaced with the neighborhood pixel values. The median of the pixels are taken
in such a way that the values are listed in the order from small value until big ones. Then the value
or values at the center of the list is or are taken as the median of the pixel values. In the case of
where two numbers becoming the median, it is important to take the average of the two values.
Median filtering is a very important and widely used technique of filtering and best known for its
excellent noise reduction ability. During filtering it keeps the edges while removing the noise. This
makes the image not to blur as other smoothening methods.
Spatial Filtering
In spatial filtering a certain filter mask is used in all points in an image. The filter mask is made of
m x n size where the m and n are the matrix sizes. In each case the image points should have the
same matrix size as of the filter mask with size M x N. There are two kinds of filtering, linear and
non-linear spatial filtering. In low-pass filter the attenuation of high frequencies from frequency
domains causes in the blurring of an image. While in high-pass filter the removal of low
frequencies cause in the sharpening of edges. Band-pass filtering is used for image restoration
while removing frequencies between high and low frequencies. There are many filters that are
used for blurring/smoothing, sharpening and edge detection in an image. These different effects
can be achieved by different coefficients in the mask.
Smoothing Spatial Filter
Smoothening filters can be obtained by averaging of pixels in the neighborhood of a filter mask.
It results in the blurring of an image. During noise removal or noise reduction sharp edges are
removed from the image. There are two kinds of filtering, linear and non-linear spatial filtering. In
low-pass filter the attenuation of high frequencies from frequency domains causes in the blurring
of an image.
Inverse Filtering
If we know of or can create a good model of the blurring function that corrupted an image, the
quickest and easiest way to restore that is by inverse filtering. Unfortunately, since the inverse
filter is a form of high pass filer, inverse filtering responds very badly to any noise that is present
10 | P a g e
in the image because noise tends to be high frequency. In this section, we explore two methods of
inverse filtering - a thresholding method and an iterative method.
Wiener Filtering
The inverse filtering is a restoration technique for deconvolution, i.e., when the image is blurred
by a known low pass filter, it is possible to recover the image by inverse filtering or generalized
inverse filtering. However, inverse filtering is very sensitive to additive noise. The approach of
reducing one degradation at a time allows us to develop a restoration algorithm for each type of
degradation and simply combine them. The Wiener filtering executes an optimal tradeoff between
inverse filtering and noise smoothing. It removes the additive noise and inverts the blurring
simultaneously. The Wiener filtering is optimal in terms of the mean square error. In other words,
it minimizes the overall mean square error in the process of inverse filtering and noise smoothing.
The Wiener filtering is a linear estimation of the original image. The approach is based on a
stochastic framework. The orthogonality principle implies that the Wiener filter in Fourier domain
can be expressed as follows:
where
are respectively power spectra of the original image and the additive
noise, and
is the blurring filter. It is easy to see that the Wiener filter has two separate part,
an inverse filtering part and a noise smoothing part. It not only performs the deconvolution by
inverse filtering (high pass filtering) but also removes the noise with a compression operation (low
pass filtering).
f ( x, y )
11 | P a g e
1
mn
g ( s, t )
( s ,t )S x y
This is implemented as the simple smoothing filter. Blurs the image to remove noise.
There are different kinds of mean filters all of which exhibit slightly different behaviour:
(i)
Geometric Mean
(ii)
Harmonic Mean
(iii) Contraharmonic Mean
There are other variants on the mean which can give different performance
Geometric Mean:
Achieves similar smoothing to the arithmetic mean, but tends to lose less image detail
f ( x, y ) g ( s , t )
( s ,t )S x y
1
mn
Harmonic Mean:
The Harmonic Mean works well for salt noise, but fails for pepper noise, Also does well for
other kinds of noise such as Gaussian noise
( x, y )
f
mn
( s ,t )S x y
12 | P a g e
1
g ( s, t )
Contraharmonic Mean:
f ( x, y )
g ( s, t ) Q 1
( s ,t )S x y
g ( s, t ) Q
( s ,t )S x y
Q is the order of the filter and adjusting its value changes the filters behaviour, Positive values
of Q eliminate pepper noise, Negative values of Q eliminate salt noise
Noise Removal Examples:
Original image
13 | P a g e
Choosing the wrong value for Q when using the contraharmonic filter can have drastic results
(iii)Midpoint filter
(iv) Alpha trimmed mean filter
Median Filter:
Excellent at noise removal, without the smoothing effects that can occur with other smoothing
filters, Particularly good when salt and pepper noise is present
f ( x, y ) median{g ( s, t )}
( s ,t )S x y
Max Filter:
f ( x, y )
max { g ( s, t )}
( s ,t )S x y
Min Filter:
f ( x, y )
min {g ( s, t )}
( s ,t )S x y
Max filter is good for pepper noise and min is good for salt noise
Midpoint Filter:
f ( x, y )
max
{
g
(
s
,
t
)}
min
{
g
(
s
,
t
)}
( s ,t )S xy
2
( s ,t )S xy
f ( x, y )
1
mn d
( s ,t )S x y
( s, t )
We can delete the d/2 lowest and d/2 highest grey levels, So gr(s, t) represents the remaining mn
d pixels
15 | P a g e
Image
Corrupted
By Salt And
Pepper Noise
Result of 1
Pass With A
3*3 Median
Filter
Result of 2
Passes With
A 3*3 Median
Filter
Result of 3
Passes With
A 3*3 Median
Filter
16 | P a g e
Image
Corrupted
By Pepper
Noise
Result Of
Filtering
Above
With A 3*3
Max Filter
17 | P a g e
Image
Corrupted
By Salt
Noise
Result Of
Filtering
Above
With A 3*3
Min Filter
Image
Corrupted
By Uniform
Noise
Image
Further
Corrupted
By Salt and
Pepper
Noise
Filtered By
5*5
Arithmetic
Mean Filter
Filtered By
5*5
Geometric
Mean Filter
Filtered By
5*5 Median
Filter
Filtered By
5*5 AlphaTrimmed
Mean Filter
Adaptive Filters
The filters discussed so far are applied to an entire image without any regard for how image
characteristics vary from one point to another, The behaviour of adaptive filters changes
depending on the characteristics of the image inside the filter region, We will take a look at the
adaptive median filter
Adaptive Median Filtering
The median filter performs relatively well on impulse noise as long as the spatial density of the
impulse noise is not large, The adaptive median filter can handle much more spatially dense
impulse noise, and also performs some smoothing for non-impulse noise, The key insight in the
adaptive median filter is that the filter size changes depending on the characteristics of the image
Remember that filtering looks at each original pixel image in turn and generates a new filtered
pixel.
18 | P a g e
zmin
zmax
zmed
zxy
Smax
Level A:
A2 = zmed zmax
Level B:
B2 = zxy zmax
A1 = zmed zmin
B1 = zxy zmin
The key to understanding the algorithm is to remember that the adaptive median filter has three
purposes:
(i) Remove impulse noise
(ii) Provide smoothing of other noise
(iii)Reduce distortion
19 | P a g e
Periodic Noise
Typically arises due to electrical or electromagnetic interference, Gives rise to regular noise
patterns in an image, here Frequency domain techniques in the Fourier domain are most effective
at removing periodic noise
20 | P a g e
H (u , v ) 0
if D (u , v ) D0
W
2
W
W
D (u , v ) D0
2
2
W
if D (u , v ) D0
2
if D0
The ideal band reject filter is shown below, along with Butterworth and Gaussian versions of the
filter
Ideal Band
Reject Filter
Butterworth
Band Reject
Filter (of order 1)
Gaussian
Band Reject
Filter
21 | P a g e
Filtered image
Advantages
Disadvantages
-Manipulation of frequency
-Best method for periodic
noise reduction
- Best method for image
sharpening
- Not a good method for
contrast enhancement
-Only manipulates the
frequency
Table 1 suggested that both methods are important depending on the target needed. Spatial domain
method is advantageous in contrast enhancement, while frequency domain method in periodic
noise reduction and image sharpening.
Conclusion
Image restoration is an important field that is used in different scientific researches and technology
developments. In this paper different filtering techniques were discussed, we have also looked at
image restoration for noise removal, Restoration is slightly more objective than enhancement .
Spatial domain techniques are particularly useful for removing random noise, while Frequency
domain techniques are particularly useful for removing periodic noise. The differences among the
domains and their different methodologies were briefly explained. Generally the methods are both
important and applicable in different technologies. In this paper I tried to show a comparison
between both approaches and tried to show their advantages and disadvantages. This paper
suggests that more researches is needed on many other image processing applications to show the
importance of those methods.
22 | P a g e
References
1. Digital Image Processing by R. C. Gonzales and R. E. Woods, Addison-Wesley Publishing
Company, 1992.
2. Two-Dimensional Signal and Image Processing by J. S. Lim, Prentice Hall, 1990.
3. 'Digital Image Restoration', by M.R. Banham and A.K. Katsaggelos, IEEE Signal Processing
Magazine, pp. 27-41, March 1997.
http://www.sersc.org/journals/IJAST/vol39/5.pdf
http://www.jatit.org/volumes/research-papers/Vol14No2/1Vol14No2.pdf
http://www.owlnet.rice.edu/~elec539/Projects99/BACH/proj2/refs.html
https://publications.theseus.fi/bitstream/handle/10024/29065/thesis_final7.pdf?sequence=1
KADIR, T., BRADY, M. 2001. Saliency, Scale and Image Description. International Journal
of Computer Vision, Volume 45, Number 2.
9. R. Plemmonsa, M. Horvatha, E. Leonhardta, P. Paucaa, S. Prasadb, Computational Imaging
Systems
10. Class Presentation notes provided by Dr Xuewen Ding, Lecturer of Digital Image Processing,
Electrical and Electronics Engineering Dept, Tianjin University of Technology and
Education
4.
5.
6.
7.
8.
Appendices
Appendix 1
Spatial domain Algorithms
%-----contrast intensity manipulation using histogram equalization and certain %other ----------%
load image1
whos %shows the size and parameters
figure(1)
imshow(X,map) %show the image1 image
I = ind2gray(X,map); %creating intensity of an image
figure(2)
imshow(I) %show intensity
A=I.^4; %high contrast created
A = 0.2*I; %low contrast created
figure(3)
subplot(2,1,1)
imshow(A) %show contrast image
subplot(2,1,2)
imhist(A)
grid
C=(A+.085)*3; %histogram stretching
figure(5)
subplot(2,1,1)
23 | P a g e
24 | P a g e
25 | P a g e
Appendix 2
Frequency domain Algorithms
%-------- Analysing an intensity image by Fourier-analysis techniques---------%
load images
I=ind2gray(X,map); % Sample set
figure(1)
imshow(I)
%------------------------Fourier Analysis--------------------------------%
FI=fft2(I); % Complex amplitudes
SFI=fftshift(FI); % Origin in the middle of the matrix
SFI(130,176) is C0 in SFI
Ck=abs(SFI); % Amplitudes
AKE=log10(Ck+1);
figure(2)
imshow(Ck) % Amplitudes with the origin in the middle of the matrix
title('Amplitudes')
a=min(AKE(:));
b=max(AKE(:));
sAKE=(AKE-a)/(b-a); % Linearly scaled logarithms
figure(3)
imshow(sAKE)
title('Scaled amplitudes') % giving titles on the image
%--------------------Simulating Noise in an Image-------------------------% 65
26 | P a g e
MAT=SFI;
MAT(74,100)=800*MAT(74,100); %noise at the given coordinates
MAT(186,252)=800*MAT(186,252); %noise at the given coordinates
Ck=abs(MAT); % Amplitudes
AKE=log10(Ck+1);
a=min(AKE(:))
b=max(AKE(:))
sAKE=(AKE-a)/(b-a); % Linearly scaled logarithms
figure(4)
imshow(sAKE)
title('Scaled amplitudes')
IMG=ifft2(MAT);
figure(5)
imshow(abs(IMG))
%---------------------Ideal Low Pass Filter-------------------------------%
[m,n]=size(I);
M=zeros(m,n); % Initiating the low pass mask
M(130-par:130+par,176-par:176+par)=1;
fMAT=MAT.*M; % Filtering MAT
IMG2=ifft2(fMAT);
figure(6)
imshow(abs(IMG2))
%--------------Mask as an Amplitude Spectrum of an Image----------------%
figure(7) % Amplitude spectrum in frequency domain
subplot(2,1,1)
imshow(M)
subplot(2,1,2)
plot(M(130,:))
grid 66
27 | P a g e
IMG3=fftshift(ifft2(M));
figure(8)
aIMG3=abs(IMG3);
a3=min(aIMG3(:));
b3=max(aIMG3(:));
sIMG3=(aIMG3-a3)/(b3-a3); % enhancing the image with max. and min.values % while
removing the rest of the frequency values
%----------------------Butterworth Low Pass Filter---------------------------%
[V,U]=meshgrid(-175:174,-129:128);
D=sqrt(U.^2+V.^2);
H=1./(1+(D/D0).^(2*N)); % Butterworth Low Pass Filter
figure(9) % Amplitude spectrum in frequency domain
subplot(2,1,1)
imshow(H)
subplot(2,1,2)
plot(H(130,:))
grid
%------------------------------Notch Filter----------------------------------%
D1=sqrt((U+56).^2+(V+76).^2);
D2=sqrt((U-56).^2+(V-76).^2);
H1=1./(1+(D1/D0).^(2*N)); %implementing the notch filter formula
H2=1./(1+(D2/D0).^(2*N)); %implementing the notch filter formula
figure(9)
imshow(D2/max(D2(:)))
Hlow=H1+H2; % Local low pass filter in pole positions
High=1-Hlow;
figure(10)
imshow(High)
Inverse filter code
N=256;
n=.2;
f=freadbin('lenna.256',N,N);
figure(1)
imagesc(f)
colormap(gray)
b=ones(4,4)/4^2;
F=fft2(f);
B=fft2(b,N,N);
G=F.*B;
g=ifft2(G)+10*randn(N,N);
G=fft2(g);
figure(2)
imagesc(abs(ifft2(G)))
28 | P a g e
colormap(gray)
BF=find(abs(B)<n);
%B(BF)=max(max(B))/1.5;
B(BF)=n;
H=ones(N,N)./B;
I=G.*H;
im=abs(ifft2(I));
figure(3)
imagesc(im)
colormap(gray)
Iterative method code
N=256;
lambda=0.1;
f=freadbin('lenna.256',N,N);
figure(1)
imagesc(f)
colormap(gray)
F=fft2(f);
b=ones(4,4)/16;
B=fft2(b,N,N);
G=F.*B;
%g=ifft2(G)+10*randn(N,N);
%G=fft2(g);
figure(2)
imagesc(abs(ifft2(G)))
colormap(gray)
K=lambda*G;
for l=1:1500,
if mod(l,25)==0
lambda=lambda/5;
end
A=G-K.*B;
K=K+lambda*A;
if mod(l,50)==0
l
sum(sum(A))
figure(3)
imagesc(abs(ifft2(K)))
colormap(gray)
pause
end
end
29 | P a g e
Bien plus que des documents.
Découvrez tout ce que Scribd a à offrir, dont les livres et les livres audio des principaux éditeurs.
Annulez à tout moment.