[image,map]=imread('y.jpg');
[m,n]=size(image);
figure,imshow(image,map),title('initiative image')
I=imnoise(image,'salt & pepper',0.02);%椒盐噪声处理
% I = imnoise(image,'gaussian',0,0.002);%高斯噪声处理
figure,imshow(I,map),title('noised image')
%均值滤波
image1=image;
H=ones(3)*1/9;
I=double(I(:,:,1));
[m,n]=size(I);
for i=2:m-1
for j=2:n-1
temp=I(i-1:i+1,j-1:j+1);
image1(i,j)=sum(sum(temp.*H));
end
end
figure,imshow(image1,map),title('均值滤波');
%中值滤波
image2=image;
for i=2:m-1
for j=2:n-1
temp=I(i-1:i+1,j-1:j+1);
image2(i,j)=median(sort(temp(:)));
end
end
figure,imshow(image2,map),title('中值滤波');
%SNN
image3=image;
for i=2:m-1
for j=2:n-1
temp1=I(i-1:i+1,j-1:j+1);
temp=temp1-I(i,j);
if abs(temp(1,1))<abs(temp(3,3))
t1=temp1(1,1);
else t1=temp1(3,3);
end
if abs(temp(1,2))<abs(temp(3,2))
t2=temp1(1,2);
else t2=temp1(3,2);
end
if abs(temp(1,3))<abs(temp(3,1))
t3=temp1(1,3);
else t3=temp1(3,1);
end
if abs(temp(2,1))<abs(temp(2,3))
t4=temp1(1,1);
else t4=temp1(3,3);
end
t=[t1,t2 t3 t4];
image3(i,j)=mean(t);
end
end
figure,imshow(image3,map),title('SNN');
%KNN
%Sigma
image4=image;
for i=3:m-2
for j=3:n-2
temp=I(i-2:i+2,j-2:j+2);
sigma=stdd(temp(:));
t1=round(I(i,j)-2*sigma);
t2=round(I(i,j)+2*sigma);
for ii=1:5
for jj=1:5
if temp(ii,jj)<=t2&temp(ii,jj)>=t1
temp1(ii,jj)=temp(ii,jj);
else temp1(ii,jj)=0;
end
end
end
mean0=mean(temp1(:));
image4(i,j)=round(mean0);
end
end
figure,imshow(image4,map),title('Sigma');
zaosheng.rar_加入噪声_噪声
版权申诉
142 浏览量
2022-09-22
20:00:56
上传
评论
收藏 725B RAR 举报
weixin_42651887
- 粉丝: 80
- 资源: 1万+
最新资源
- html实现儿童节庆祝项目源码
- Typora-1.3.8(含激活文件)
- Python爬取百度贴吧数据.zip
- Python爬取大众点评数据.zip
- 计算机视觉(CV)open CV 人脸识别程序.docx
- python 端午节游戏,选择三个传统的端午节活动之一:包粽子、赛龙舟或挂艾草 根据玩家的选择,游戏会描述相应的情节,并在完成后
- C语言各版块实验题库、实验汇报以及实验教学案例资源
- 数据库连接(MySQL与VS2022)_vs2022 mysql-CSDN博客 (2024_6_1 19_11_34).html
- Flappy bird小游戏
- 数电实验五:555单稳态触发电路、555单稳态触发电路、555构成的施密特触发器
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈