Gaussian filter vs median filter vs wiener filter??Noise tackling performance with image corrupted with salt and pepper noise
Show older comments
I am trying to remove noise in an image usig three different filters,but i am bit confused in output performance of each filter. I think gaussian filter has best performance in this case(please guide me if my observation is wrong)
or median filter also has apparently best performance(but one major drawback that its output appear like binary(black and white image) while originally we had grayscale image,not a binary image)
My matlab code is as follow
clc,clear all close all
im=imread('cameraman.tif');
[r c]=size(im);
t1=randi([0 255],r,c); % Random integers of size r,c in the range 0-255
t2=randi([0 255],r,c);
f=im;
for i=1 : r
for j=1: c
if im(i,j) > t1(i,j)
f(i,j)=255;
else
if im(i,j) < t2(i,j)
f(i,j)=0;
end
end
end
end
%Figure 1 showing f(x,y) and the caption
figure(1), imshow(f); title('Noisy Image Created');
% Gaussian Filter of Variance 1
w=fspecial('gaussian',3,1);
wf=imfilter(f,w);
%Figure 2 showing g(x,y) as the result of Gaussian filtering and the caption
figure(2), imshow(wf); title('Result of 3x3 Gaussian Filter');
mf=medfilt2(f);
%Figure 3 showing g(x,y) as the result of Median filtering and the caption
figure(3), imshow(mf); title('Result of Median Filter');
wf = wiener2(f,[3 3]);
%Figure 4 showing g(x,y) as the result of Wiener filtering and the caption
figure(4), imshow(wf); title('Result of 3x3 Wiener Filter');
Accepted Answer
More Answers (1)
Image Analyst
on 25 May 2020
0 votes
A guassian filter blurs edges and is affected by the noise value itself.
A median filter preserves edges and is not affected by the noise value.
A wiener filter is a stochastic filter that requires that you know the spectrum of the noise.
There are other even more sophisticated denoising routines, like BM3D, non-local means, etc.
2 Comments
ABTJ
on 26 May 2020
Image Analyst
on 26 May 2020
I gave generalities, which is much more useful and informative than telling you which is best for this particular amount of noise and this particular image. You can always compute the MSE with immse() to see which performed best with that particular image - that's trivial so why don't you do it?
Categories
Find more on Deblurring in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!