clear;close all;clc;
f=imread('cameraman.tif');
fsap=imnoise(f,'salt & pepper',0.05); %加入椒盐噪声
% fsap=imnoise(f,'gaussian',0.01); %加入高斯噪声
fmed=median_filtering(fsap,6,3); %中值滤波
subplot(121),imshow(f);title('原图')
subplot(122),imshow(fsap);title('加噪图像')
figure;
subplot(121),imshow(fmed);title('中值滤波处理')
subplot(122),fimg=medfilt2(fsap,[3 3]);imshow(fimg);title('medfilt2处理') %对比medfilt2
函数
评论5
最新资源