Matlab数字图像处理尝试之:[7]邻域中值
1、
计算去噪前后的峰值信噪比,做出主观和客观评价。
1),邻域平均化法:
clear all;
>> I=imread('C:\Users\zjy\Desktop\test1.tif');
subplot(2,3,1),imshow(I);
>> xlabel('a)原始图像');
>> J=imnoise(I,'gaussian',0,0.025);
subplot(2,3,2),imshow(J);
>> xlabel('b)添加白噪声');
>> K=imnoise(I,'salt & pepper',0.025);
subplot(2,3,3),imshow(K);
xlabel('b)添加椒盐噪声');
>> subplot(2,3,4)
>> subplot(2,3,4),imshow(I);
xlabel('a)原始图像');
>> h=[1 1 1;1 0 1;1 1 1];
>> h=h/8;
>> J1=conv2(J,h);
>> subplot(2,3,5),imshow(J1,[]);
>> xlabel('邻域平均除白噪声');
>> K1=conv2(K,h);
>> subplot(2,3,6),imshow(K1,[]);
>> xlabel('邻域平均除椒盐噪声');
以上程序段实现了用邻域平均化去除高斯白噪声和椒盐噪声,效果如下图所示。
![Matlab数字图像处理尝试之:[7]邻域中值](https://exp-picture.cdn.bcebos.com/b442d6d246fe474e287ebe0bb0ef354f51b81f56.jpg)
2、
从上图可以看出,邻域平均法对高斯白噪声的消除效果比较好,对椒盐噪声的消除效果不理想。
3、
2),中值滤波法:
clear all;
I=imread('C:\Users\zjy\Desktop\test1.tif');
subplot(2,3,1),imshow(I);
xlabel('a)原始图像');
J=imnoise(I,'gaussian',0,0.025);
subplot(2,3,2),imshow(J);
xlabel('b)添加白噪声');
K=imnoise(I,'salt & pepper',0.025);
subplot(2,3,3),imshow(K);
xlabel('b)添加椒盐噪声');
subplot(2,3,4)
subplot(2,3,4),imshow(I);
xlabel('a)原始图像');
J1=medfilt2(J);
subplot(2,3,5),imshow(J1,[]);
xlabel('中值滤波除白噪声');
J2=medfilt2(K);
subplot(2,3,6),imshow(J2,[]);
xlabel('中值滤波除椒盐噪声');
以上程序段实现了用邻域平均化去除高斯白噪声和椒盐噪声,效果如下图所示。
![Matlab数字图像处理尝试之:[7]邻域中值](https://exp-picture.cdn.bcebos.com/340e4eb8b43ea8dba6b77786189c2cf7deb21656.jpg)
4、
从上图可以看出,中值滤波法对高斯白噪声如果用5*5窗口滤波效果好于3*3窗口滤波窗口,但图像模糊会加重。中值滤波法对椒盐噪声的消除效果很理想。