A=imread('a.jpg');
B=rgb2gray(A);black=3;
white=253;
NoiseImg = B;
Rmatrix = randint(size(B,1),size(B,2),[0,255]);
NoiseImg(Rmatrix <= black) = 0;
NoiseImg(Rmatrix >=white) = 255;
RImg=medfilt2(NoiseImg);
figure,subplot(2,2,1),imshow(B),title('Original image');
subplot(2,2,2),imshow(NoiseImg),title('Add ''Salt and Pepper'' Noise');
subplot(2,1,2),imshow(RImg),title('After Noise Removal');
Contact:
Mr. Roshan P. Helonde
Mobile: +91-7276355704
WhatsApp: +91-7276355704
Email: roshanphelonde@rediffmail.com