欢迎来到天天文库
浏览记录
ID:22281062
大小:195.43 KB
页数:5页
时间:2018-10-28
《实验4图像平滑算法实现》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、南京信息工程大学实验(实习)报告实验(实)名称实验4图像平滑算法实现实验(实:>」)曰期2015.6得分_指导教师张辉计算机系专业科学与技术年级12班次j_姓名学号_2_一、实验目的:理解图像平滑的相关算法,并掌握算法的实现。二、实验内容:1.读入一幅灰度图像。2.对原始图片添加噪声(随机噪声和椒盐噪声)(imnoise函数)。3.利用均值滤波算法(取模板分别为3X3,5X5)去除噪声(自己编写一段代码实现此功能),显示去噪前后的阁像。4.利用中值滤波算法对图像去除噪声(自己编写一段代码实现此功能),显示去噪前后的图像。三、实验要求:1.用Matlab语言进行编程,实现上述功能,并尽量
2、使得程序具有通用性。2.撰写实验报告并附上所用程序和结果。P4、实验结果:clear;clc;f=imread(,eight,tif’);f2=imnoise(f,’salt&pepper’,0.02);[r,c]=size(f2);g=f2;fori=2:r~lforj=2:c-lnei=f2(i-l:i+l,j-l:j+l);avg=sum(sum(nei))/9;g(i,j)=avg;endendg=uint8(g);subplot(131),imshow(f);subplot(132),imshow(f2);subplot(133),imshow(g);clear;clc;f=
3、imread(Jeight,tif’);f2=imnoise(f,’salt&pepper’,0.02);[r,c]=size(f2);g=f2;fori=3:r-2forj=3:c~2nei=f2(i-2:i+2,j-2:j+2);avg=sum(sum(nei))/25;g(i,j)=avg;endendg=uint8(g);subplot(131),imshow(f);subplot(132),imshow(f2);subplot(133),imshow(g);)FigureEileEditMiewInsertloolsHesktopWindowHelp□运H曇<±<€4、subplot(132),imshow(f2);subplot(133),imshow(g);clear;clc;f=imread(,eight,tif’);f2=imnoise(f,’salt&pepper’,0.02);[rc]=size(f2)g=f2;u=zeros(1,9);fori=2:r~lforj=2:c-lWl)=g(i,j);u(2)=g(i,j+1);u(3)=g(i-l,j+1);u(4)=g(i-l,j);u(5)=g(i-l,j_l);u(6)=g(i,j-1);u(7)=g(i+l,j-1);u(8)=g(i+l,j);u(9)=g(i+l,j+1);fo5、rp=l:8forq=l:8-pifu(q)>u(q+1)k=u(q);u(q)=u(q+l);u(q+l)=k;endendendrg(i,j)=u(5);endendg=uint8(rg);subplot(131),imshow(f);subplot(132),imshow(f2);subplot(133),imshow(g);EileEdityiewInsertToolsHesktopWindowHelp一LLJIX6、7、叹叹O®卜<8、口
4、subplot(132),imshow(f2);subplot(133),imshow(g);clear;clc;f=imread(,eight,tif’);f2=imnoise(f,’salt&pepper’,0.02);[rc]=size(f2)g=f2;u=zeros(1,9);fori=2:r~lforj=2:c-lWl)=g(i,j);u(2)=g(i,j+1);u(3)=g(i-l,j+1);u(4)=g(i-l,j);u(5)=g(i-l,j_l);u(6)=g(i,j-1);u(7)=g(i+l,j-1);u(8)=g(i+l,j);u(9)=g(i+l,j+1);fo
5、rp=l:8forq=l:8-pifu(q)>u(q+1)k=u(q);u(q)=u(q+l);u(q+l)=k;endendendrg(i,j)=u(5);endendg=uint8(rg);subplot(131),imshow(f);subplot(132),imshow(f2);subplot(133),imshow(g);EileEdityiewInsertToolsHesktopWindowHelp一LLJIX
6、
7、叹叹O®卜<
8、口
此文档下载收益归作者所有