Friday, 13 June 2014

how to read an image and remove noise using median filter


This program reads the image of cameraman.
imnoise- adds salts and pepper noise to the read image
This can be removed using median filter.

x=imread('cameraman.tif');
y=imnoise(x,'salt & pepper',0.2);
I=find(x==0|x==255);
x1=medfilt2(x);
x2=x;
x2(I)=x1(I);
imshow([y x1 x2],[]);



No comments:

Post a Comment