Professional Documents
Culture Documents
FINAL REPORT
DONE BY- FACULTY
HASHIL MUHAMMED (B210047EC) DR. SUDEEP PV
G. SAGAR (B210660EC)
EC 02 B8 Batch
OBJECTIVE
i) To perform uniform and gaussian blurring on images.
ii) Demonstrate the difference between uniform and gaussian blurring.
iii) Recover original image from the blurred image using the Wiener filter.
iv) Study the effects of changing the filter size on blurring and deblurring the images.
v) Study the effects of changing NSR on deblurring images.
THEORETICAL BACKGROUND
UNIFORM BLURRING
Uniform blurring, also known as box blurring, is a technique in image processing where each
pixel in the output image is computed as the average of the neighbourhood. It effectively
reduces noise and smooths images but may lead to a loss of fine details and edges. It's
implemented using a kernel or filter applied to each pixel using a sliding window approach.
Uniform blurring is commonly used for noise reduction and overall image smoothing.
This filter on convolving with the image basically replaces every pixel
with the average value of it’s neighboring pixels. This process often
results in the attenuation of edge pixels, those with significantly different
values compared to their neighboring pixels, leading to a blurred effect.
GAUSSIAN BLURRING
Gaussian blurring is a common technique used in image processing to reduce noise and
smooth images. Unlike uniform blurring, which applies a simple averaging operation over a
neighborhood, Gaussian blurring applies a weighted average using a Gaussian-shaped kernel.
This means that pixels closer to the center of the kernel have more influence on the result than
those farther away, resulting in a smoother and more natural-looking blur. Gaussian blurring
effectively preserves edges and fine details better than uniform blurring. It is widely used in
various image processing tasks, including noise reduction, image smoothing, and
pre-processing for feature extraction and object recognition algorithms.
WIENER FILTER
The Wiener filter is a widely used signal processing technique employed for image
deconvolution, specifically in the context of restoring images degraded by linear and stationary
processes. Named after Norbert Wiener, the filter aims to recover the original, unblurred image
from the observed, degraded image by estimating the inverse filter. It operates by balancing
between noise suppression and signal amplification, leveraging knowledge of the signal and
noise characteristics along with a user-defined noise-to-signal ratio. It looks at the blur and
guesses what the original picture looked like. Then, it uses special math to sharpen the picture
back up, while also getting rid of any unwanted noise. In the end, you get a clearer picture that
looks a lot like the original. The Wiener filter is particularly effective in scenarios where the
degradation process is known or can be accurately modeled, making it a valuable tool in image
restoration, deblurring, and enhancement applications.
BLOCK DIAGRAM
EXPLANATION
CONSTRUCTION OF FILTERS
Filters are constructed using fspecial function in MATLAB
uniform_filter = fspecial('average', filter_size);
The uniform filter is constructed by using the ‘average’ option.
gaussian_filter = fspecial('gaussian',filter_size,sigma);
The gaussian filter is constructed using ‘gaussian’ option. The filter size and standard deviation
are also given as inputs.
EFFECT OF NSR
The NSR is initially set to 0.001 and normalized by dividing with image variance. We try to see
the effect of NSR on deblurred images by changing the value.
estimated_nsr = 0.01/var(A(:));
RESULTS
Here we have convolved the original image with 7x7 filters and standard deviation 2 ( for
gaussian filter) with the original image and produced the blurring effect. It is noticeable that there
are blocking artifacts ( large pixel blocks) in the case of uniform
blurring whereas gaussian blurring produces a more smooth image.
This happens due to averaging effect of uniform blurring where
image is smoothed out too much causing sharp details to become
less distinct and resulting in noticeable artifacts along edges and
boundaries. On the other hand gaussian blur gradually smooths the
image by giving more weight to pixels closer to the center of the filter
kernel and less weight to pixels farther away, applying less blurring
near edges compared to uniform blur. It avoids abrupt changes,
reducing visible artifacts along edges and boundaries.
We note that the wiener filter is able to reconstruct the gaussian blur image better than the
uniform blurred. This is because uniform blurring doesn't match the Wiener filter's expectations
since it creates a more abrupt change in pixel values, whereas the Wiener filter is designed to
work well with smooth, predictable blurring patterns like those produced by Gaussian blurring.
We also notice some lines near the boundaries of the images which might be due to not padding
the images before the deconvolution.
REPEATING THE PROCESS WITH INCREASED FILTER SIZE AND STANDARD DEVIATION
We increased the kernel size to 15x15 and standard deviation to 4 and note that the blurring has
increased as expected. We also note that the deblurring performance is poorer since more
image details are now lost during the blurring process. It is also visible that gaussian blurring still
outperforms uniform blurring
IMPORTANCE OF NSR
Decreasing the NSR
Decreasing the NSR to 0.0001 from 0.001 causes the Wiener filter to give more priority to signal
preservation than noise suppression. Hence we see finer details but with more noise as lines in
the deblurred image.
Increasing the NSR
When we increase the NSR to 0.01 the overall image becomes darker since the algorithm is
now more focused on suppressing the noise by reducing its pixel values, even though it means
the original detail (brightness) of the image is lost. We can also see that the difference between
uniform and gaussian blur decreases since the blocking artifacts are now suppressed more.
CONCLUSION
REFERENCES
Wikipedia
https://en.wikipedia.org/wiki/Wiener_filter#:~:text=In%20signal%20processing%2C%20the%20
Wiener,noise%20spectra%2C%20and%20additive%20noise.
https://en.wikipedia.org/wiki/Box_blur
https://en.wikipedia.org/wiki/Gaussian_blur
https://en.wikipedia.org/wiki/Wiener_filter
http://16385.courses.cs.cmu.edu/spring2024/lecture/filtering
Matlab Documentation
https://in.mathworks.com/help/images/ref/deconvwnr.html
https://in.mathworks.com/help/images/ref/fspecial.html
CODE
% Close all figures, clear workspace, and command window
close all;
clc;
clear;
% Read the image and convert it to double precision
A = im2double(imread('building.png'));
% Define filter parameters
filter_size = [7 7];
sigma = 2;
% Create uniform blur filter
uniform_filter = fspecial('average', filter_size);
% Create Gaussian blur filter
gaussian_filter = fspecial('gaussian',filter_size,sigma);
% Apply uniform blur and Gaussian blur to the image
uni_blur = imfilter(A,uniform_filter,'conv','replicate');
gauss_blur = imfilter(A, gaussian_filter,'conv','replicate');
% Display original image and blurred images
figure;
imshow(A)
title('Original Image');
figure
imshow(uni_blur);
title('Uniform blur');
figure
imshow( gauss_blur);
title('Gaussian Blur');
% Estimate noise-to-signal ratio (NSR) for Wiener filter
estimated_nsr = 0.01/var(A(:)); % Estimated noise-to-signal ratio
% Deblur the uniformly blurred and Gaussian blurred images using Wiener
filter
deblurred_uniform = deconvwnr(uni_blur, uniform_filter,estimated_nsr);
deblurred_gaussian = deconvwnr(gauss_blur,gaussian_filter,estimated_nsr);
% Display deblurred images
figure;
imshow(deblurred_uniform);
title('Deblurred Uniform');
figure;
imshow(deblurred_gaussian);
title('Deblurred Gaussian');