write a program for image enhancement using blurring and deblurrring

4
EXPERIMENT NO. 5 Objective: Write a program for image enhancement using blurring and deblurrring. Software Used: MATLAB R2010a About the Experiment: In practical imaging systems the acquired image often suffers from effects of blurring and noise. Image restoration algorithms are aimed to restore the original undistorted image from its blurry and noisy version. Theory: Blurring an Image Matlab has a command fspecial for generating different types of blur kernels. The command imfilter can then be used to blur the image with this kernel, it is equivalent to a 2D convolution. The code below blurs the cameraman image with a Gaussian blur with standard deviation 1.0. A = imread('cameraman.tif'); h = fspecial('gaussian', size(A), 1.0); g = imfilter(A, h); Note that we made the kernel h the same size as our original image, so that the sizes match up when we multiply the Fourier transforms. Note that the matrix h is mostly zeros. Deblurring with the Wiener Filter Use the deconvwnr function to deblur an image using the Wiener filter. Wiener deconvolution can be used effectively when the frequency characteristics of the image and additive noise are known, to at least some degree. In the absence of noise, the Wiener filter reduces to the ideal inverse filter. This example deblurs the blurred flower image, created in Deblurring Model, specifying the same PSF function that was used to create the blur. This example illustrates the importance of knowing the PSF, the function that caused the blur. When you know the exact PSF, as in this example, the results of deblurring can be quite effective.

Upload: anish-bansal

Post on 29-Nov-2015

36 views

Category:

Documents


1 download

DESCRIPTION

In practical imaging systems the acquired image often suffers from effects of blurring and noise. Image restoration algorithms are aimed to restore the original undistorted image from its blurry and noisy version.

TRANSCRIPT

Page 1: Write a program for image enhancement using blurring and deblurrring

EXPERIMENT NO. 5

Objective: Write a program for image enhancement using blurring and deblurrring.

Software Used: MATLAB R2010a

About the Experiment: In practical imaging systems the acquired image often suffers from effects of blurring and noise. Image restoration algorithms are aimed to restore the original undistorted image from its blurry and noisy version.

Theory:

Blurring an Image

Matlab has a command fspecial for generating different types of blur kernels. The command imfilter can then be used to blur the image with this kernel, it is equivalent to a 2D convolution. The code below blurs the cameraman image with a Gaussian blur with standard deviation 1.0.A = imread('cameraman.tif');h = fspecial('gaussian', size(A), 1.0);g = imfilter(A, h);Note that we made the kernel h the same size as our original image, so that the sizes match up when we multiply the Fourier transforms. Note that the matrix h is mostly zeros.

Deblurring with the Wiener Filter

Use the deconvwnr function to deblur an image using the Wiener filter. Wiener deconvolution can be used effectively when the frequency characteristics of the image and additive noise are known, to at least some degree. In the absence of noise, the Wiener filter reduces to the ideal inverse filter.

This example deblurs the blurred flower image, created in Deblurring Model, specifying the same PSF function that was used to create the blur.

This example illustrates the importance of knowing the PSF, the function that caused the blur. When you know the exact PSF, as in this example, the results of deblurring can be quite effective.

You can affect the deconvolution results by providing values for the optional arguments supported by the deconvwnr function. Using these arguments you can specify the noise-to-signal power value and/or provide autocorrelation functions to help refine the result of deblurring. To see the impact of these optional arguments, view the Image Processing Toolbox Deblurring Demos.

Syntax

Page 2: Write a program for image enhancement using blurring and deblurrring

1) J = deconvwnr(I,PSF,NSR)

It deconvolves image I using the Wiener filter algorithm, returning deblurred image J. Image I can be an N-dimensional array. PSF is the point-spread function with which I was convolved. NSR is the noise-to-signal power ratio of the additive noise. NSR can be a scalar or a spectral-domain array of the same size as I. Specifying 0 for the NSR is equivalent to creating an ideal inverse filter

2) h = fspecial('motion', len, theta)

It returns a filter to approximate, once convolved with an image, the linear motion of a camera by len pixels, with an angle of theta degrees in a counterclockwise direction. The filter becomes a vector for horizontal and vertical motions. The default len is 9 and the default theta is 0, which corresponds to a horizontal motion of nine pixels.

MATLAB Program:

I = imread('C:\Users\Public\Pictures\Sample Pictures\Hydrangeas.jpg');

subplot(3,1,1); imshow(I); title('Original Image');

LEN = 31;

THETA = 11;

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

Blurred = imfilter(I,PSF,'circular','conv');

subplot(3,1,2); imshow(Blurred); title('Blurred Image');

wnr1 = deconvwnr(Blurred,PSF);

subplot(3,1,3);imshow(wnr1);

title('Restored, True PSF');

Result:

Page 3: Write a program for image enhancement using blurring and deblurrring