去除图片高斯噪声和椒盐噪声(图像处理)

这篇博客介绍了如何使用MATLAB去除图像中的高斯噪声和椒盐噪声。通过应用不同滤波方法,包括最小值、最大值、中值和均值滤波,有效地改善了图像质量。示例代码展示了处理过程。
摘要由CSDN通过智能技术生成

最小值最大值中值均值滤波去除高斯噪声和椒盐噪声

#代码如下:

clear;clc;
f=imread(‘rice.png’);
f1=imnoise(f,‘gaussian’);
f2=imnoise(f,‘salt & pepper’,0.02);
[m,n]=size(f1);
g1=f1;
g2=f2;
mask=[1 1 1;1 1 1;1 1 1]/9;
for x=2:m-1
for y=2:n-1
subimage=double(f1(x-1:x+1,y-1:y+1));
temp=subimage.*mask;
g1(x,y)=round(sum(sum(temp)));
subimage2=double(f2(x-1:x+1,y-1:y+1));
temp2=subimage2.*mask;
g2(x,y)=round(sum(sum(temp2)));
end
end
g1=uint8(g1);
g2=uint8(g2);
subplot(221),imshow(f1);
subplot(222),imshow(f2);
subplot(223),imshow(g1);
subplot(224),imshow(g2);

clear;clc;
I=imread(‘rice.png’);
f1=imnoise(I,‘gaussian’);
f2=imnoise(I,‘salt & pepper’,0.02);
[m,n]=size(f1);
g1=f1;
g2=f2;
mask=[1 1 1 1 1;1 1 1 1 1;1 1 1 1 1;1 1 1 1 1;1 1 1 1 1]/25;
for x=3:m-2
for y=3:n-2
subimage=double(f1(x-2:x+2,y-2:y+2));
temp=subimage.*mask;
g1(x,y)=round(sum(sum(temp)));
subimage2=double(f2(x-2:x+2,y-2:y+2));
temp2=subimage2.*mask;
g2(x,y)=round(sum(sum(temp2)));
end
end
g1=uint8(g1);
g2=uint8(g2);
subplot(221),imshow(f1);
subplot(222),imshow(f2);
subplot(223),imshow(g1);
subplot(224),imshow(g2);

I = imread(‘pout.tif’);
f1=imnoise(I,‘gaussian’);
f2=imnoise(I,‘salt & pepper’,0.02);
[m,n] = size(I);
g1=f1;
g2=f2;
mask=[1 1 1 1 1;1 1 1 1 1;1 1 1 1 1;1 1 1 1 1;1 1 1 1 1 ]/25;
for x=3:m-2
for y=3:n-

  • 6
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值