欢迎来到天天文库
浏览记录
ID:57707088
大小:311.00 KB
页数:3页
时间:2020-09-01
《中值滤波去噪程序及结果.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、M=imread('2.jpg')%打开图像“csu.jpg”subplot(3,2,1)imshow(M)%在一行一列显示原始图像title('原始图像')P1=imnoise(M,'gaussian',0.02)%加入高斯躁声subplot(3,2,2)imshow(P1)%在一行二列显示加入高斯躁声后的图像title('加入高斯躁声');P2=imnoise(M,'salt&pepper',0.02)%加入椒盐躁声subplot(2,3,3)imshow(P2)%在一行三列显示加入椒盐躁声后的图像title('加入椒盐
2、躁声');P12=im2bw(P1,0.5)P22=im2bw(P2,0.5)%将添加噪音后的图像转为二进制P01=im2bw(M,0.5)subplot(2,3,4)imshow(P01)title('原图像转为二进制')%将原图像转为二进制并于二行一列显示P3=medfilt2(P12)%对高斯躁声中值滤波subplot(2,3,5)imshow(P3)%在二行二列显示高斯躁声中值滤波后的图像title('对高斯躁声中值滤波')P4=medfilt2(P22)%对椒盐躁声中值滤波subplot(2,3,6)imshow(
3、P4)title('对椒盐躁声中值滤波')%在二行三列显示对椒盐躁声中值滤波clearall%删除变量closeall%关闭窗口clc%清除窗口i=imread('2.jpg');%输入图像x=i(:,:,1);%三维转换为二维j=imnoise(x,'gaussian',0,0.02);%给图像加高斯噪声h=ones(3,3);%选择3×3模板h=h/9;k=conv2(j,h);%卷积subplot(231);imshow(x);%显示原图像title('原始图像');axissquare;subplot(232);im
4、show(j);%显示加噪图像title('加入高斯噪声后的图像');axissquare;subplot(233);image(k);%显示去噪后的图像title('去噪图像');axissquare;j=imnoise(x,'salt&pepper',0.02);h=ones(3,3);%3×3模板h=h/9;k=conv2(j,h);subplot(234);imshow(x);title('原始图像');axissquare;subplot(235);imshow(j);title('加入椒盐噪声后的图像');axi
5、ssquare;subplot(236);image(k);title('去噪图像');axissquare;
此文档下载收益归作者所有