Current location - Recipe Complete Network - Healthy recipes - How to remove salt and pepper noise from matlab color images?
How to remove salt and pepper noise from matlab color images?
% Hello. My program only applies to bmp images. If it is in other formats, please add questions.

The window size of% is 5*5, please adjust it according to the needs of the screen.

clc

All closed;

Clear all;

win =[5 5];

img = imread(' salt pepper . BMP ');

Figure; imshow(img);

x=img(:,:, 1);

y=img(:,:,2);

z=img(:,:,3);

X = medfilt2(x,win);

Y = medfilt2(y,win);

Z = medfilt2(z,win);

new_img=cat(3,X,Y,Z);

Figure; im show(new _ img);