You are on page 1of 24

Index

Preface
Acknowledgement
Chapter No. Introduction to
Chapter No.
Chapter No.
Chapter No.
Objective:
The objective is to do blind image restoration of a degraded image, i.e. to reconstruct the
original image from a degraded image without the knowledge of either the original image or
the degradation process. If we represent the degradation in a linear model given by equation:
g(x,y) = f(x,y) * h(x,y) + n(x,y)
Where both the original image and the point spreading function (PSF) h are unknown
functions, then the restoration is reduced to a blind image deconolution problem where the
PSF is estimated using the degraded image and deconvolution of degraded image with the
estimated PSF if done to generate the reconstructed image. Blind Image restoration has been
topic a numerous research efforts and various deconvolution methods have been proposed.
Existing blind deconvolution techniques differ from each other mainly by the assumptions
they make about the true signal f(x,y) or the filter h(x,y).
Our aim is to identify different type of blurs in an image and then estimate the PSF based on
the identification and using the PSF to retore the image. Three usual blur types which
degrade an image Motion blur, Defocus blur and Gaussian blur are to be identified and
restored.

Introduction:
The purpose of image restoration is to "compensate for" or "undo" defects which degrade
an image. Degradation or blurring in an image can be caused by several factors like:
a) Relative motion between camera & object during the image capture process
(called motion blur),
b) Optical Blurs, for e.g. Out-of-focus optics ( called defocus blur), etc.,
c) Atmospheric turbulence blur, due to scattering, etc.,
d) Spatial quantization due to discrete pixels,
e) additive intensity noise during image acquisition (digitization) and transmission.,
etc.

The blurring is caused by convolution of original image by a blurring function, called the
Point Spread Function (PSF) (generated by the physical phenomena causing the blur).
During restoration process for all these type of blurs, we should compute a very good
estimate of the actual blurring function i.e. the PSF and remove the blur by
deconvolving the blurred image with this PSF to restore the original image. Also the
restoration process has to take into consideration the noise added to image and
compensate for the degradation it caused.
Linear Image Restoration: Degradation Model
Degradation is modelled as convolution of original image x(m,n) with a linear shift-
invariant filter, h(m,n) and addition of noise, w(m,n). y(m,n) is the degraded image which
we have to restore. Restoration is modelled as convolution of the degraded image, y(m,n)
a linear shift-invariant filter, g(m,n) which gives the estimate of original image x(m,n).

SPATIAL DOMAIN MODEL

FREQUENCY DOMAIN MODEL

Corresponding equations are given by:

X (u , v) H (u , v) + W (u , v) W (u , v)
Xˆ (u , v) = Y (u , v)G (u , v) = = X (u , v) +
H (u , v) H (u , v)
 i2  j2 
h(i, j )  K exp   
 2 2 

DEBLURRING/RESTORATION FILTERS:
1) Inverse Filtering

The quickest and easiest way to restore an image is by inverse filtering. It is a restoration
technique for deconvolution when the image is blurred by a known lowpass filter
Unfortunately, since the inverse filter is a form of high pass filer, inverse filtering
responds very badly to any noise that is present in the image because noise tends to be
high frequency. Thus Inverse filtering accentuates noise.

2) Wiener Filtering

The Wiener filtering executes an optimal trade-off 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 Wiener filter in Fourier
domain can be expressed as follows:
3)Lucy- Richardson Filtering
Both Wiener and Lucy-Richardson Filters are adaptive filters. The Lucy-Richardson
algorithm generates a restored image through an iterative method. Lucy-Richardson
denoising accounts on photon counting noise with a Poisson distribution. The essence of
the iteration is as follows: the (n+1)th estimate of the restored image is given by the nth
estimate of the restored image multiplied by a correction image. With no noise
information, the Wiener filter do a poor job at realizing the original, non degraded, image.
However, the Lucy-Richardson filter works really good, despite having no information
about the noise in the image.

4) Wavelet-based Image Restoration

Although the Wiener filtering is the optimal tradeoff of inverse filtering and noise
smoothing, in the case when the blurring filter is singular, the Wiener filtering actually
amplify the noise. This suggests that a denoising step is needed to remove the amplified
noise. Wavelet-based denoising scheme is a successful approach provides a natural
technique for this purpose. Therefore, the image restoration contains two separate steps:
Fourier-domain inverse filtering and wavelet-domain image denoising. The diagram is
shown as follows.

This for image restoration improves the performance, however, in the case when the
blurring function is not invertible, the algorithm is not applicable. Furthermore, since the
two steps are separate, there is no control over the overall performance of the restoration.
Adaptive blind Image Restoration Algorithm: Implementation

Basic Principle:

In this project we have extracted features of degraded image while working in frequency
domain. It has been seen through many researches that certain type of blur may lead to
the specific frequency component distortion of the image Fourier spectrum, i.e the
Fourier spectrum of motion blur, Gaussian blur or any other type of blur will have
different features. This has been exploited in the project to identify the type of blur and
estimate the PSF accordingly. The degraded images are classified for three type of blurs:
Motion blur, Defocus blur and Gaussian blur. After identification of blur, PSF is
estimated and then decovolution is done of the estimated PSF and the degraded image to
restore the image. Restoration methods of Wiener filter and Lucy-Richardson’s filter have
been employed and compared & contrasted for different type of blurs.
The algorithm is computationally less extensive, effective and good adaptively.

Algorithm for Adaptive blind Image Restoration:

Figure: Adaptive Blind Image Restoration Algorithm

Any degraded image (may be caused by any degradation factor) is input to the algorithm.
The Blur identification of degraded image is an automatic blur recognization method.
This is the primary and most important step for adaptive blind image restoration
algorithm.
Figure: Blur type identification of degraded image

Two-step Fourier transform of the a degraded image can distinguish the various kinds of
Blurs present in degraded images. Fourier spectrum for three blur types (motion,
Gaussian, defocus) are different.

Figure: Spectrum Features of Blur Images


After Fourier transform, the image pretreatment module follows. The task of this
module is to enhance the image’s quality. The image which is characterized with two-step
Fourier transform has the problems of low contrast and blur edge, if it is binarized
directly, the result will be not very effective. So it must be enhanced edge before
binarization. The morphology method for image enhancement has been adopted and the
structural element used is se = [0 1 0; 1 1 1; 0 1 0]

Figure: Image enhancement results

After enhancement,image binarization is done using a threshold value. A dynamic


iterative threshold selection method has been adopted calculate the gray threshold. In this
method , the average of maximum gray-scales and minimum grayscales is used as the
original estimation of the threshold, and then the image is segmented with this threshold
to gain its sub-image. This process is continued until the incorrect segmentation image
pixels are the minimum.

Figure: Image Binarization results

After Binarization, post-treatment by morphology is done to deal with the pit, tip and
voids of spectrum.

Feature extraction is done for binarized images. The purpose of feature extraction is to
gain the characteristic information outstanding other images, and achieve the image
recognition. The two-step Fourier Transform of blur images with the same blur type but
different blur scale may be different in the size, scale and even the direction. But we hope
the feature extracted can ignore these differences, and have some outstanding differences
among these different blur types. For this, the seven moment invariants based on internal
domain and build with central moments by Hu[4]are used as the image feature, the
invariants means rotate invariants, shift invariants and scale invariants. Their formulas as
follows:
where

is scale & translation invariant moments

and, all Ii are scale, translation, as well as rotation invariant moments

where

is the central moment of a digital image f(x,y)

After feature extraction the classification & decision is done. The images are
automatically identified according to the image features. Using some the discrimination
functions and decision rules, the images are classified and identified, and the results are
obtained. The minimum distance classifier is introduced as the classifier in this paper.
The seven moment invariants of images are used as the retrieval shape features, the
European distance is used as the similarity measure. Calculating the similarity measuring
of two images, when the distance is less than the given threshold, the two images are
judged as similarity and belong to the same blur type. Threshold taken here is 1.5.
Seven moment invariants for three type of blur types are saved in computer as Sj , where
S1 is motion blur retrieval feature, S2 is defocus blur retrieval feature, and S3 is Gaussian
blur retrieval feature.. Then for any input degraded image the seven moment invariants
are computed. The European distance distj between the the saved values Sj and the
degraded image’s computed value S is computed as follows:
Where, Sj = {Mi | i = 1,2,3,….7}, j = 1,2,3

Then distj is compared for all the three blur types and the distance is minimum for j = i
then we say that the blur present in the degraded image is of ith type.

This completes the automatic identification of blur types in the degraded images.
When the degraded images’ blur types are classified by the algorithm, we then
deconvolve the degraded image with the corresponding PSF. For e.g. if blur type
identified is motion blur, then we deconvolve the degraded image with the motion blur
PSF (which is already saved in computer). This gives the restored image.

Implementation of Adaptive blind Image Restoration Algorithm:

Above algorithm for adaptive blind image restoration has been implemented in
MATLAB. The algorithm has been tested with different images having different type of
blurs. The algorithm is properly identifying the type of blur present in an degraded image.
Restoration methods of Wiener filter and Lucy-Richardson’s filter have been employed
and compared & contrasted for different type of blurs.

Simulation Results:

Original Image

Motion Blurred Image Gaussian Blurred Image Defocus Blurred Image


STEP 1: Two- Step Fourier Transform of Images

STEP 2: Image Enhancement by Morphology


STEP 3: Image Binarization

Motion Blurred Image Gaussian Blurred Image Defocus Blurred Image

STEP 4: Image Feature Extraction

Images M1 M2 M3 M4 M5 M6 M7

Lena 5.4439 10.8863 16.3348 16.3377 32.6739 21.7812 47.6222


Cameraman 6.5108 13.0207 19.5317 19.5334 39.0659 26.0433 57.2140
Moment Invariants for two different Motion Blurred Image

Images M1 M2 M3 M4 M5 M6 M7
Lena 5.1333 10.263 15.3951 15.4020 30.8005 20.5344 44.8094
Camerama 6.4580 12.914 19.3714 19.3753 38.7487 25.8312 56.7400
n
Moment Invariants for two different Gaussian Blurred Image

Images M1 M2 M3 M4 M5 M6 M7
Lena 4.3236 8.6419 12.9625 12.9732 25.9411 17.2939 37.5238
Camerama 6.4580 12.914 19.3714 19.3753 38.7487 25.8312 25.8312
n
Moment Invariants for two different Defocus Blurred Image

STEP 5: European Distance Computation


From the simulation results it is clear that the distance computed is minimum when
the degraded input image blur type and the corresponding blur of the saved image
is matched. Thus by comparing these distances for any degraded image we can
easily classify the type of blur present in the input degraded image, i.e. if

dist1 is minimum => Motion blur present


dist2 is minimum => Gaussian blur present
dist3 is minimum => Defocus blur present

STEP 6: Image Restoration by Deconvolution


Motion Blurred Image Restored Image: Wiener Filter Restored Image: LR Filter

Gaussian Blurred Image Restored Image: Wiener Filter Restored Image: LR Filter

Defocus Blurred Image Restored Image: Wiener Filter Restored Image: LR Filter

Thus we can see that Wiener Filter works well for Motion Blurred Images, but for
other two type of blurs, Lucy- Richardson Filter gives better results. For Gaussian
and defocus blurred images, Wiener filter accentuates noise which appear is form of
line patterns in the restored images.
MATLAB Code
1. TOP MODULE (imrestore.m)

clc;
close all;
clear all;

%--------------------------------------IMAGE READ------------------------------------------------------%

% im_org = imread('cameraman.tif');
% im_org = imread('rice.png');
% im_org = imread('pout.tif');
im_org = imread('lena512.bmp');

im_org = imresize(im_org , [256 256]);


figure; imshow(im_org ); title('Original Image');

%-------------ADDING DIFFERENT TYPE OF BLURS TO AN IMAGE----------------------%

%-------------------ADDING MOTION BLUR TO THE IMAGE--------------------------------------%


LEN = 100;
THETA = 30;
PSF = fspecial('motion',LEN,THETA); % create PSF
im= imfilter(im_org ,PSF,'circular');
figure; imshow(im);
title('Blurred Image Motion Blur');

%-------------------ADDING GAUSSIAN BLUR TO THE IMAGE-----------------------------------%


h = fspecial('gaussian',20,10);
im = imfilter(im_org,h);
figure;imshow(im);
title('blurred image Gaussian Blur');

%-----------------ADDING DEFOCUS BLUR TO THE IMAGE--------------------------------------%

H = fspecial('disk',10);
im = imfilter(im_org ,H,'replicate');
figure; imshow(im);
title('Blurred Image Defocus Blur');

%-------------TWO STEP FOURIER TRANSFORM OF BLURRED IMAGE-----------------%

fft_mtbl=fftshift(fft2(double(im)));
% subplot(2,2,4);imshow(log(1+abs(fft_dfbl2)),[]);
% title('FFT of Defocussed Blurred image2');
%------------- --------------IMAGE PRETREATMENT MODULE------------ --------------------%
%-------------CONTRAST ENHANCEMENT USING MORPHOLOGICAL FILTER------------%

se = [0 1 0;1 1 1;0 1 0]; %%Structuring element

eroded_mtbl = imerode(abs(fft_mtbl),se);
dilated_mtbl = imdilate(abs(fft_mtbl),se);
[y,x] = size(eroded_mtbl);
for i = 1:y
for j = 1:x
if ( ( (dilated_mtbl(i,j)) - (abs(fft_mtbl(i,j))) ) < ( (abs(fft_mtbl(i,j))) - (eroded_mtbl(i,j)) ) )

enhanced_mtbl_img(i,j) = dilated_mtbl(i,j);

elseif ( ( (dilated_mtbl(i,j)) - (abs(fft_mtbl(i,j))) ) > ( (abs(fft_mtbl(i,j))) - (eroded_mtbl(i,j)) ) )

enhanced_mtbl_img(i,j) = eroded_mtbl(i,j);

elseif ( ( (dilated_mtbl(i,j)) - (abs(fft_mtbl(i,j))) ) == ( (abs(fft_mtbl(i,j))) - (eroded_mtbl(i,j)) ) )

enhanced_mtbl_img(i,j) = abs(fft_mtbl(i,j));

end
end
end

figure;imshow(log(1+abs(fft_mtbl)),[]);title(‘Original image');

figure,imshow(log(1+enhanced_mtbl_img) ,[]);title('sharpened image');

%----------------------------------IMAGE BINARIZATION----------------------------------------------%

ihis = imhist(abs(fft_mtbl));
dim = size(abs(fft_mtbl));
leng = length(ihis);
para = zeros(1,leng);
for k = 2:leng-1
% intensity of class A
classa = ihis(1:k);
ind = (classa==0);
classa = classa+ind;
clear ind
% intensity of class B
classb = ihis(k+1:end);
ind = (classb==0);
classb = classb+ind;
clear ind
% probability distribution of class A
Pa = classa/(dim(1,1)*dim(1,2));
% probability distribution of class B
Pb = classb/(dim(1,1)*dim(1,2));
% parameters to decide threshold
para1 = log2(sum(Pa));
para2 = log2(sum(Pb));
logpa = log2(Pa);
logpb = log2(Pb);
para3 = -sum(Pa.*logpa)/sum(Pa);
para4 = -sum(Pb.*logpb)/sum(Pb);
% parameter which has to be maximized
para(1,k) = abs(para1+para2+para3+para4);
clear classa classb logpa logpb
end

% find threshold
[maxv,row] = max(para);
thresh = row-1;
% segment input image
BW1 = (abs(fft_mtbl)>=thresh);
figure;imshow(BW1);title('Binary Image - Motion Blur');

%--------------------------POST TREATMENT BY MORPHOLOGY---------------------------------%

se1 = strel('diamond',5);

BW11 = imerode(BW1,se1);

figure;imshow(BW11);

%--------------------------------IMAGE FEATURE EXTRACTION---------------------------------%

[n1 n2 n3 n4 n5 n6 n7]=findmoment(double(BW11));

m1 = 6.0011; m2 =12.0012; m3 =18.0026, m4 =18.0045; m5 =35.3155; m6 =24.0048; m7=


52.6264;
m12 = 3.0924; m22=6.1571 ; m32=9.2411; m42=9.2954; m52= 17.8877; m62=12.3662;
m72=26.4746;
m13=2.0139; m23=3.8537; m33= 5.7975; m43=6.1199; m53=11.4433; m63=8.0105;
m73=16.7531;

%------------------EUROPEAN DISTANCE CALCULATION-------------------------------------------


dist = 0;
dist1 = sqrt( ((m1-n1).^2)+ ((m2-n2).^2)+ ((m3-n3).^2)+ ((m4-n4).^2)+ ((m5-n5).^2)+ ((m6-
n6).^2)+ ((m7-n7).^2) )
dist2 = sqrt( ((m12-n1).^2)+ ((m22-n2).^2)+ ((m32-n3).^2)+ ((m42-n4).^2)+ ((m52-n5).^2)+
((m62-n6).^2)+ ((m72-n7).^2) )
dist3 = sqrt( ((m13-n1).^2)+ ((m23-n2).^2)+ ((m33-n3).^2)+ ((m43-n4).^2)+ ((m53-n5).^2)+
((m63-n6).^2)+ ((m73-n7).^2) )
%-------------------------------------------------------------------------------------------------------------------
%----------------------IMAGE CLASSIFICATION & RESTORATION--------------------------%

if ((dist1 < dist2) & (dist1 < dist3))


LEN = 100;
THETA = 30;
PSF = fspecial('motion',LEN,THETA); % create PSF

%Wiener Filter %LR Filter


wnr1 = deconvwnr(im,PSF);
lucy1 = deconvlucy(im,PSF);
reg1 = deconvreg(im,PSF);
figure;imshow(wnr1);
title('Restored Image - Type of Blur was Motion Blur');
figure;imshow(lucy1);
title('Restored Image - Type of Blur was Motion Blur-LR');

sharpFilter = fspecial('unsharp');
sharp = imfilter(wnr1, sharpFilter, 'replicate');
figure;imshow(sharp), title('Sharpened');

elseif ((dist2 < dist1) & (dist2 < dist3))

PSF = fspecial('gaussian',10,5);
%Wiener Filter %LR Filter
wnr1 = deconvwnr(im,PSF);
lucy1 = deconvlucy(im,PSF);

figure;imshow(wnr1);
title('Restored Image - Type of Blur was Gaussian Blur-Wiener');
figure;imshow(lucy1);
title('Restored Image - Type of Blur was Gaussian Blur-LR');

sharpFilter = fspecial('unsharp');

sharp = imfilter(lucy1, sharpFilter, 'replicate');


figure;imshow(sharp), title('Sharpened');
sharpMore = imfilter(sharp, sharpFilter, 'replicate');
figure; imshow(sharpMore), title('Excessive sharpening attenuates noise');

elseif ((dist3 < dist1) & (dist3 < dist2))


PSF = fspecial('disk',10);

%Wiener Filter %LR Filter


wnr1 = deconvwnr(im,PSF);
figure;imshow(wnr1);
title('Restored Image - Type of Blur was Defocus Blur-Wiener');

lucy1 = deconvlucy(im,PSF);
figure;imshow(lucy1);
title('Restored Image - Type of Blur was Defocus Blur-LR');

sharpFilter = fspecial('unsharp');
sharp = imfilter(lucy1, sharpFilter, 'replicate');
figure;imshow(sharp), title('Sharpened');

end

%---------------------------------------------END of TOP MODULE------------------------------------%

2. MOMENT COMPUTATION MODULE (findmoment.m)

function [m1 m2 m3 m4 m5 m6 m7]=findmoment(im)

im=im/max(max(im));

cx = immoment(im, 1, 0);
cy = immoment(im, 0, 1);

u20= immoment(im,2,0,cx,cy);
u02= immoment(im,0,2,cx,cy);
u30= immoment(im,3,0,cx,cy);
u03= immoment(im,0,3,cx,cy);

u11= immoment(im,1,1,cx,cy);

u12= immoment(im,1,2,cx,cy);
u21= immoment(im,2,1,cx,cy);

m1= (u20+u02);

m2=((u20-u02).^2) + 4*(u11.^2);

m3=((u30-3*u12).^2 )+ (3*u21-u03).^2;

m4=((u30+u12).^2) + ((u21+u03).^2);

m5=(u30- 3*u12)*(u30+u12)*( ((u30+u12).^2) - (3* ((u21+u03).^2)) ) + (3*u21-


u03)*(u21+u03)*(3*((u30+u12).^2) - ((u21+u03).^2));

m6= (u20-u02) * ( ((u30+u12).^2) - (3* ((u21+u03).^2)) ) + (4*u11*(u30+u12)*(u21+u03));


m7= (3*u12-u03)*(u30+u12)*( ((u30+u12).^2) - (3*((u12+u03).^2) ) + (3*u21-
u30)*(u21+u03)*( 3*((u30+u12).^2) - ((u21+u03).^2) ));

m1 = log (abs(m1));
m2 = log (abs(m2));
m3 = log (abs(m3));
m4 = log (abs(m4));
m5 = log (abs(m5));
m6 = log (abs(m6));
m7 = log (abs(m7));

%----------------------END of MOMENT COMPUTATION MODULE--------------------------%

3. MOMENT FUNCTION CALLING MODULE (immoment.m)

function m = immoment(im, p, q, cx, cy)

% Compute image moment

[y x v] = find(im);

if nargin == 5 % no of arguments passed == 5


x = x - cx;
y = y - cy;
m = sum(x.^p .* y.^q .* v)/(sum(v).^(1+ ((p+q)/2)));

elseif nargin == 3

m = sum(x.^p .* y.^q .* v)/(sum(v).^(1+ ((p+q)/2)));

end

%-----------------END of MOMENT FUNCTION CALLING MODULE----------------------%

%---------------------------------------------------------------------------------------------------------------%
CONCLUSION:

With reference to the paper on “Adaptive Blind Image Restoration Algorithm of


Degraded Image” by BI Xiao-jun, and WANG Ting, College of Information and
Communication Engineering, Harbin Engineering University, Harbin 150001, China,
published in, 2008 Congress on Image and Signal Processing, we have implemented in
MATLAB the algorithm on adaptive blind image restoration of degraded images. The
simulation results show that this algorithm is very efficient in identification of different
type of blurs present in degraded images. Also the restored images were found to be
having improved quality compared to the degraded images. This algorithm is
computationally not very extensive and very efficient. For restoration of motion blurs,
Wiener filter has been used while for restoration of two other type of blurs (Gaussian blur
and Defocus Blur) Lucy-Richardson filter has been used.
REFERENCES:

[1] Katsaggelos A.K., Maximum likelihood image identification and restoration based on
the EM algorithm, Multidirnensional Signal Processing workshop,1989,pp. 183- 184.

[2] Ayers G R, J C.Iterative blind deconvolution method and its applications, Optics
Letters, 1998,pp.547-549.

[3] M Schave maker. Image sharpening by morphological filtering .Pattern Recognition.


2000,pp.997-1012.

[4] Hu M.K. Visual pattern recognition by moment invariant. IEEE Trans on Information
Theory, 1962,pp.179-187.

[5] CHEN Qianrong, LU Qisheng, CHENG Zhili. Identification the scale of the point
spread function from the motion blurred image.Computer Engineering and Applications,
2004,pp.15-19.

[6] TAO Qingchuan, DENG Hongbin. Wavelet transform based Gaussian point spread
function estimation.Optical Technique,2004,pp.284-288.

[7] TANG Ting,TAO Qingchuan.An improved NAS-RIF algotrithm based on wavelet


denoising and image segmentation.Journal of Chengdu University of Information
Technology.2004,pp.372-376.

You might also like