Code covered by the BSD License  

Highlights from
filters

filters

by

 

finding the efficiency of various filters

fil.m
clear all;
close all;
a=imread('car.jpg');
i=rgb2gray(a);
subplot(3,2,1);
imshow(i)
title('org image');
n=imnoise(i,'salt & pepper',0.05);%adding salt & pepper noise
subplot(3,2,2);
imshow(n);
title('with noise')
k=medfilt2(n);%applying mean filter
subplot(3,2,3);
imshow(k);
title('mean filter')
h = fspecial('average',5);%averager of 5x5 pixel dimension
h1= uint8(filter2(h,n));%applying 2D filter over the noise image 'n' with the averager 'h' and then converting double to uint8
subplot(3,2,4);
imshow(h1);
title('avg');
m=wiener2(n);%applying wiener filter
subplot(3,2,5);
imshow(m);
title('wiener');
rms1=sqrt(sum(sum(n-i).^2))/length(n);%applying root mean square
PSNR1noise=20 * log10(255/rms1);%finding peak signal to noise ratio
rms2=sqrt(sum(sum(i-k).^2))/length(n);
PSNR2mean=20 * log10(255/rms2);
rms3=sqrt(sum(sum(i-m).^2))/length(n);
PSNR3weiner=20 * log10(255/rms3);
rms4=sqrt(sum(sum(i-h1).^2))/length(n);
PSNRavg=20 * log10(255/rms4);


Contact us