欢迎来到三一文库! | 帮助中心 三一文库31doc.com 一个上传文档投稿赚钱的网站
三一文库
全部分类
  • 研究报告>
  • 工作总结>
  • 合同范本>
  • 心得体会>
  • 工作报告>
  • 党团相关>
  • 幼儿/小学教育>
  • 高等教育>
  • 经济/贸易/财会>
  • 建筑/环境>
  • 金融/证券>
  • 医学/心理学>
  • ImageVerifierCode 换一换
    首页 三一文库 > 资源分类 > DOC文档下载  

    数字图像处理 matlab上机作业.doc

    • 资源ID:9997654       资源大小:725.50KB        全文页数:17页
    • 资源格式: DOC        下载积分:4
    快捷下载 游客一键下载
    会员登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录   微博登录  
    二维码
    微信扫一扫登录
    下载资源需要4
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    数字图像处理 matlab上机作业.doc

    数字图像处理实验报告指导老师: 学号 姓名 班级 1. 产生右图所示图像f1(m,n),其中图像大小为256256,中间亮条为12832,暗处=0,亮处=100。对其进行FFT:同屏显示原图f1(m,n)和FFT(f1)的幅度谱图;若令f2(m,n)=(-1)(m+n)f1(m,n),重复以上过程,比较二者幅度谱的异同,简述理由;若将f2(m,n)顺时针旋转90度得到f3(m,n),试显示FFT(f3)的幅度谱,并与FFT(f2)的幅度谱进行比较;若将f1(m,n)顺时针旋转90度得到f4(m,n),令f5(m,n)=f1(m,n)+f4(m,n),试显示FFT(f5)的幅度谱,并指出其与FFT(f1)和FFT(f4)的关系;若令f6(m,n)=f2(m,n)+f3(m,n),试显示FFT(f6)的幅度谱,并指出其与FFT(f2)和FFT(f3)的关系,比较FFT(f6)和FFT(f5)的幅度谱。f1=zeros(256,256);for i=64:1:192 for j=122:1:144 f1(i,j)=100; endendfft_f1=fft2(f1);fft_f1=abs(fft_f1);tmax=fft_f1(1,1);tmin=fft_f1(1,1);for i=1:256 for j=1:256 if tmax<fft_f1(i,j) tmax=fft_f1(i,j); end if tmin>fft_f1(i,j) tmin=fft_f1(i,j); end endenddelta=tmax-tmin; for i=1:256 for j=1:256 fft_f1(i,j)=255*(fft_f1(i,j)-tmin)/delta; endendsubplot(1,2,1);imshow(f1);title(原图);subplot(1,2,2);imshow(fft_f1);title(原图的幅度谱);for i=1:256 for j=1:256 f2(i,j)=(-1)(i+j)*f1(i,j); endendfft_f2=fft2(f2);fft_f2=abs(fft_f2);tmax=fft_f2(1,1);tmin=fft_f2(1,1);for i=1:256 for j=1:256 if tmax<fft_f2(i,j) tmax=fft_f2(i,j); end if tmin>fft_f2(i,j) tmin=fft_f2(i,j); end endenddelta=tmax-tmin; for i=1:256 for j=1:256 fft_f2(i,j)=255*(fft_f2(i,j)-tmin)/delta; endendsubplot(2,2,1);imshow(f1);title(原图); subplot(2,2,2);imshow(fft_f1);title(原图的幅度谱);subplot(2,2,3);imshow(f2);title(原图中心化); subplot(2,2,4);imshow(fft_f2);title(原图中心化的幅度谱);f3=imrotate(f2,-90,bilinear); fft_f3=fft2(f3);fft_f3=abs(fft_f3);tmax=fft_f3(1,1);tmin=fft_f3(1,1);for i=1:256 for j=1:256 if tmax<fft_f3(i,j) tmax=fft_f3(i,j); end if tmin>fft_f3(i,j) tmin=fft_f3(i,j); end endenddelta=tmax-tmin; for i=1:256 for j=1:256 fft_f3(i,j)=255*(fft_f3(i,j)-tmin)/delta; endendsubplot(2,2,1);imshow(f2);title(原图中心化); subplot(2,2,2);imshow(fft_f2);title(原图中心化的幅度谱); subplot(2,2,3);imshow(f3);title(旋转后的图像); subplot(2,2,4);imshow(fft_f3);title(旋转后的幅度谱);图像旋转90度后,幅度谱也旋转了90度。f4=imrotate(f1,-90,bilinear);f5=f1+f4;fft_f5=fft2(f5);fft_f5=abs(fft_f5);tmax=fft_f5(1,1);tmin=fft_f5(1,1);for i=1:256 for j=1:256 if tmax<fft_f5(i,j) tmax=fft_f5(i,j); end if tmin>fft_f5(i,j) tmin=fft_f5(i,j); end endenddelta=tmax-tmin; for i=1:256 for j=1:256 fft_f5(i,j)=255*(fft_f5(i,j)-tmin)/delta; endendsubplot(2,2,1);imshow(f1);title(原图); subplot(2,2,2);imshow(fft_f1);title(原图的幅度谱); subplot(2,2,3);imshow(f5);title(相加后的图像); subplot(2,2,4);imshow(fft_f5);title(相加后的幅度谱);原图与旋转90度后的图像进行叠加后,相应的幅度谱也进行叠加。f6=f2+f3;fft_f6=fft2(f6);fft_f6=abs(fft_f6);tmax=fft_f6(1,1);tmin=fft_f6(1,1);for i=1:256 for j=1:256 if tmax<fft_f6(i,j) tmax=fft_f6(i,j); end if tmin>fft_f6(i,j) tmin=fft_f6(i,j); end endenddelta=tmax-tmin; for i=1:256 for j=1:256 fft_f6(i,j)=255*(fft_f6(i,j)-tmin)/delta; endendsubplot(2,2,1);imshow(fft_f2);title(F2); subplot(2,2,2);imshow(fft_f3);title(F3); subplot(2,2,3);imshow(fft_f5);title(F5); subplot(2,2,4);imshow(fft_f6);title(F6); FFT(2)和FFT(3)相差90度。FFT(6)是FFT(5)的中心化。2. 产生教材104页题图4.18(右图)所示的二值图像(白为1,黑为0),编程实现习题4.18所要求的处理(3*3的平均滤波和中值滤波)功能(图像四周边界不考虑,处理结果按四舍五入仍取0或1),显示处理前后的图像,比较其异同。a=zeros(64,64);f=zeros(256,256);for i=1:1:32 for j=1:1:32 a(i,j)=1; endendfor i=33:1:64 for j=33:1:64 a(i,j)=1; endendfor i=1:64:256 for j=1:64:256 f(i:i+63,j:j+63)=a; endendimshow(f)for i=2:1:255 for j=2:1:255 a=f(i-1,j-1),f(i-1,j),f(i-1,j+1),f(i,j-1),f(i,j),f(i,j+1),f(i+1,j-1),f(i+1,j),f(i+1,j+1); b=f(i-1,j),f(i,j-1),f(i,j),f(i,j+1),f(i+1,j); c=sort(a); d=sort(b); zlf1(i,j)=c(5); zlf2(i,j)=d(5); endendsubplot(1,3,1);imshow(f);title(原图像);subplot(1,3,2);imshow(zlf1);title(方形中值滤波后图像)subplot(1,3,3);imshow(zlf2);title(十字形中值滤波后图像)for i=2:1:255 for j=2:1:255 jlf4(i,j)=(f(i-1,j)+f(i+1,j)+f(i,j-1)+f(i,j+1)/4; jlf8(i,j)=(f(i-1,j-1)+f(i-1,j)+f(i-1,j+1)+f(i,j-1)+f(i,j+1)+f(i+1,j-1)+f(i+1,j)+f(i+1,j+1)/8; jjlf4(i,j)=(f(i-1,j)+f(i+1,j)+f(i,j-1)+f(i,j+1)+f(i,j)/5; jjlf8(i,j)=(f(i-1,j-1)+f(i-1,j)+f(i-1,j+1)+f(i,j-1)+f(i,j+1)+f(i+1,j-1)+f(i+1,j)+f(i+1,j+1)+f(i,j)/9; endendjlf4=round(jlf4);jlf8=round(jlf8);jjlf4=round(jjlf4);jjlf8=round(jjlf8);subplot(2,2,1);imshow(jlf4);title(4邻域平均滤波后图像);subplot(2,2,2);imshow(jlf8);title(8邻域平均滤波后图像)subplot(2,2,3);imshow(jjlf4);title(4邻域加权平均滤波后图像)subplot(2,2,4);imshow(jjlf8);title(8邻域加权平均滤波后图像)放大后可看出区别3.产生教材104页题图4.16所示的灰度图像(白为255,黑为0),分别加入高斯白噪声和椒盐噪声,再分别进行3*3的平均滤波和中值滤波,显示原图像、加噪图像和滤波结果图像,并比较四种滤波结果。f=zeros(256,256);a=255*ones(210,7);for i=0:1:8 f(24:233,(29+24*i):(29+24*i+6)=a;endf1=imnoise(f,gaussian,0,0.1);%加入均值为零方差为0.1的高斯噪声f2=imnoise(f,salt & pepper,0.1);%加入噪声密度为0.1的椒盐噪声 for i=2:1:255 for j=2:1:255 a=f1(i-1,j-1),f1(i-1,j),f1(i-1,j+1),f1(i,j-1),f1(i,j),f1(i,j+1),f1(i+1,j-1),f1(i+1,j),f1(i+1,j+1); b=f2(i-1,j-1),f2(i-1,j),f2(i-1,j+1),f2(i,j-1),f2(i,j),f2(i,j+1),f2(i+1,j-1),f2(i+1,j),f2(i+1,j+1); c=sort(a); d=sort(b); zlf1(i,j)=c(5); %中值滤波 zlf2(i,j)=d(5);%中值滤波 jlf8(i,j)=(f1(i-1,j-1)+f1(i-1,j)+f1(i-1,j+1)+f1(i,j-1)+f1(i,j+1)+f1(i+1,j-1)+f1(i+1,j)+f1(i+1,j+1)+f1(i,j)/9;%平均滤波 jjlf8(i,j)=(f2(i-1,j-1)+f2(i-1,j)+f2(i-1,j+1)+f2(i,j-1)+f2(i,j+1)+f2(i+1,j-1)+f2(i+1,j)+f2(i+1,j+1)+f2(i,j)/9;%平均滤波 endendsubplot(2,4,1);imshow(f);title(原图像);subplot(2,4,2);imshow(f1);title(高斯噪声污染后的图像);subplot(2,4,3);imshow(zlf1);title(中值滤波后的图像);subplot(2,4,4);imshow(jlf8);title(平均滤波后的图像);subplot(2,4,5);imshow(f);title(原图像);subplot(2,4,6);imshow(f2);title(椒盐噪声污染后的图像);subplot(2,4,7);imshow(zlf2);title(中值滤波后的图像);subplot(2,4,8);imshow(jjlf8);title(平均滤波后的图像);5.(第4、5题选做一题)编程实现教材214页所给图像门限化分割的迭代阈值算法,实现对某一灰度图像的二值化。Pic=imread(C:UsersAdministratorDesktop242dd42a2834349bfb0c018ccbea15ce36d3beb5.jpg);%读取RGB格式的图像a= rgb2gray(Pic);%进行RGB到灰度图像的转换T=0.5*(double(min(a(:)+double(max(a(:);do=false;while do g=(a>T); Tnext=0.5*(mean(a(g)+mean(a(g); do=abs(T-Tnext)<0.2; T=Tnext;endfigure;subplot(1,2,1);imshow(a);subplot(1,2,2);imshow(g);6.%Read Input Retina ImageinImg = imread( Input.bmp);if(dim = 3)dim = ndims(inImg);%Input is a color imageinImg = rgb2gray(inImg);end%Extract Blood VesselsThreshold = 10;bloodVessels = VesselExtract(inImg, Threshold);%Output Blood Vessels imagefigure;subplot(121);imshow(inImg);title(Input Image);subplot(122);imshow(bloodVessels);title(Extracted Blood Vessels);VesselExtract.m:function bloodVessels = VesselExtract(inImg, threshold)%Kirschs Templatesh1=5 -3 -3; 5 0 -3; 5 -3 -3/15;h2=-3 -3 5; -3 0 5; -3 -3 5/15;h3=-3 -3 -3; 5 0 -3; 5 5 -3/15;h4=-3 5 5; -3 0 5; -3 -3 -3/15;h5=-3 -3 -3; -3 0 -3; 5 5 5/15;h6= 5 5 5; -3 0 -3; -3 -3 -3/15;h7=-3 -3 -3; -3 0 5; -3 5 5/15;h8= 5 5 -3; 5 0 -3; -3 -3 -3/15;%Spatial Filtering by Kirschs Templatest1=filter2(h1,inImg);t2=filter2(h2,inImg);t3=filter2(h3,inImg);t4=filter2(h4,inImg);t5=filter2(h5,inImg);t6=filter2(h6,inImg);t7=filter2(h7,inImg);t8=filter2(h8,inImg);s=size(inImg);bloodVessels=zeros(s(1),s(2);temp=zeros(1,8);for i=1:s(1) for j=1:s(2) temp(1)=t1(i,j);temp(2)=t2(i,j);temp(3)=t3(i,j);temp(4)=t4(i,j); temp(5)=t5(i,j);temp(6)=t6(i,j);temp(7)=t7(i,j);temp(8)=t8(i,j); if(max(temp)>threshold) bloodVessels(i,j)=max(temp); end endend

    注意事项

    本文(数字图像处理 matlab上机作业.doc)为本站会员(土8路)主动上传,三一文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一文库(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    经营许可证编号:宁ICP备18001539号-1

    三一文库
    收起
    展开