版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、实用标准文案 信息工程学院实验报告成 绩:指导老师(签名):课程名称:数字图像处理 实验项目名称:实验四 图像增强 实验时间:2016.11.08 班级: 姓名: 学号: 一、实验目的1.了解图像增强的目的及意义,加深对图像增强的感性认识,巩固所学理论知识。2. 掌握图像空域增强算法的基本原理。3. 掌握图像空域增强的实际应用及matlab实现。4. 掌握频域滤波的概念及方法。5. 熟练掌握频域空间的各类滤波器。6.掌握怎样利用傅立叶变换进行频域滤波。7. 掌握图像频域增强增强的实际应用及matlab实现。二、实验步骤及结果分析1. 基于幂次变换的图像增强 程序代码:精彩文档clear all
2、;close all;i1=double(imread('fig534b.tif');i1=i1/255;figure,subplot(2,4,1);imshow(i1,);hold oni2=double(imread('room.tif');i2=i2/255;subplot(2,4,5);imshow(i2,);hold onfor m=1:2 index=0; for lemta=0.5 5 index=index+1; fmindex=im.lemta;subplot(2,4,(m-1)*4+index+1),imshow(fmindex,)enden
3、d执行结果:图1 幂次变换增强结果实验结果分析:由实验结果可知,当r<1时,黑色区域被扩展,变的清晰;当r>1时,黑色区域被压缩,变的几乎不可见。2. 直方图规定化处理程序代码:clear allclc close all%0.读图像i=double(imread('lena.tiff');subplot(2,4,1);imshow(i,);title('原图')n=32;hist_image=hist(i(:),n);hist_image=hist_image/sum(hist_image);hist_image_cumulation=cumsum
4、(hist_image);%累计直方图subplot(245);stem(0:n-1,hist_image);title('原直方图');%1.设计目标直方图index=0:n-1;%正态分布直方图hist1=exp(-(index-n/2).2/n);hist1=hist1/sum(hist1);hist_cumulation1=cumsum(hist1);subplot(242);stem(0:n-1,hist1);title('规定化直方图1');%倒三角形状直方图hist2=abs(2*n-1-2*index);hist2=hist2/sum(hist2
5、);hist_cumulation2=cumsum(hist2);subplot(246);stem(0:n-1,hist2);title('规定化直方图2');%2. 规定化处理project1=zeros(n);project2=zeros(n);hist_result1=zeros(n);hist_result2=zeros(n);for m=1:2 image=i;%sml处理(sml,single mapping law单映射规则 for k=1:ntemp=abs(hist_image_cumulation(k)-hist_cumulationm); temp1,p
6、rojectm(k)=min(temp); end%2.2 变换后直方图 for k=1:n temp=find(projectm=k); if isempty(temp) hist_resultm(k)=0; else hist_resultm(k)=sum(hist_image(temp); end end subplot(2,4,(m-1)*4+3); stem(0:n-1,hist_resultm); title('变换后的直方图',num2str(m); %2.3结果图step=256/n;for k=1:n index=find(i>=step*(k-1)&a
7、mp;i<step*k); image(index)=projectm(k);endsubplot(2,4,(m-1)*4+4),imshow(image,); title('变换后的结果图',num2str(m);end执行结果:图2 直方图规定化实验结果分析:由实验结果可知,采用直方图规定化技术后,原图的直方图逼近规定化的直方图,从而有相应的变换后的结果图1和变换后的结果图2。3. 灰度图像常用平常、锐化滤波程序代码:clear all;close all;%0.原图i=double(imread('lena.tiff');subplot(2,4,1)
8、;imshow(i,);title('原图');%1.均值低通滤波h=fspecial('average',5);f1=double(filter2(h,i);subplot(2,4,2);imshow(f1,);title('均值低通滤波');%2.gaussian 低通滤波h=fspecial('gaussian',7,3);f2=double(filter2(h,i);subplot(2,4,3);imshow(f2,);title('高斯低通滤波');%3.增强图像=原图-均值低通滤波f3=2*i-f1;s
9、ubplot(2,4,4);imshow(uint8(f3),);title('原图-均值低通滤波');%4.增强图像=原图-高斯低通滤波f4=2*i-f2;subplot(2,4,5);imshow(uint8(f4),);title('原图-高斯低通滤波');%5.'prewitt'边缘算子增强h=fspecial('prewitt');f5=uint8(i+filter2(h,i);subplot(2,4,6);imshow(f5,);title('prewitt边缘算子增强');%6.'soble&
10、#39;边缘算子增强h=fspecial('sobel');f6=uint8(i+filter2(h,i);subplot(2,4,7);imshow(f6,);title('sobel边缘算子增强');执行结果:图3 灰色图像平滑、锐化实验结果分析:由实验结果可知,均值和高斯滤波都使原图模糊,而采用原图减去低通滤波图像方法、prewitt算子、sobel算子都可以增强图像边缘。4. 频率域滤波:对于给定图像+噪声,使用不同的频域滤波器对图像进行滤波处理。(1)用butterworth低通滤波器实现图像信号的滤波运算。程序代码:clear all;close a
11、ll;%(a)读入并显示图像electric.tif;i=imread('electric.tif');subplot(2,3,1),imshow(i);title('原图像');%(b)利用imnoise 命令在图electric.tif 上加入高斯(gaussian) 噪声;j=imnoise(i,'gaussian',0,0.01);subplot(2,3,2),imshow(j);title('加入高斯噪声的图像');%(c)用butterworth低通滤波器实现图像信号的滤波运算,变换不同的截止频率di1=fftshif
12、t(fft2(j);m,n=size(i1);n=2;d1=30;d2=50;d3=70;d4=90;n1=floor(m/2);n2=floor(n/2);for i=1:m for j=1:n d=sqrt(i-n1)2+(j-n2)2); h1=1/(1+(d/d1)(2*n); h2=1/(1+(d/d2)(2*n); h3=1/(1+(d/d3)(2*n); h4=1/(1+(d/d4)(2*n); i3(i,j)=h1*i1(i,j); i5(i,j)=h2*i1(i,j); i7(i,j)=h3*i1(i,j); i9(i,j)=h4*i1(i,j); endendi3=ifft
13、shift(i3);i4=real(ifft2(i3);i5=ifftshift(i5);i6=real(ifft2(i5);i7=ifftshift(i7);i8=real(ifft2(i7);i9=ifftshift(i9);i10=real(ifft2(i9);subplot(2,3,3),imshow(i4,),title('butterworth低通滤波器d1=30');subplot(2,3,4),imshow(i6,),title('butterworth低通滤波器d2=50');subplot(2,3,5),imshow(i8,),title(&
14、#39;butterworth低通滤波器d3=70');subplot(2,3,6),imshow(i10,),title('butterworth低通滤波器d4=90');执行结果:图4 butterworth低通滤波器滤波结果实验结果分析:由实验结果可知,采用butterworth低通滤波器对加噪声的图像进行滤波运算,滤波器的截止频率d越小,滤波后的图像越模糊。(2)用理想低通滤波器实现图像信号的滤波运算程序代码:clear all;close all;i=imread('electric.tif');subplot(2,3,1),imshow(i)
15、;title('原图像');f=imnoise(i,'gaussian',0,0.01);subplot(2,3,2),imshow(f);title('加入高斯噪声的图像');%傅里叶变换并把频谱中心移到中点f1=fft2(f);i1=fftshift(f1);%构建理想低通滤波器m,n=size(i1);d1=30;d2=50;d3=70;d4=90;n1=floor(n/2);n2=floor(m/2);for u=1:m for v=1:n if sqrt(u-n1)2+(v-n2)2)<=d1 h1(u,v)=1; else h1
16、(u,v)=0; end end endfor u=1:m for v=1:n if sqrt(u-n1)2+(v-n2)2)<=d2 h2(u,v)=1; else h2(u,v)=0; end end endfor u=1:m for v=1:n if sqrt(u-n1)2+(v-n2)2)<=d3 h3(u,v)=1; else h3(u,v)=0; end end endfor u=1:m for v=1:n if sqrt(u-n1)2+(v-n2)2)<=d4 h4(u,v)=1; else h4(u,v)=0; end end endj1=i1.*h1;j2=
17、i1.*h2;j3=i1.*h3;j4=i1.*h4;k1=ifft2(ifftshift(j1);k2=ifft2(ifftshift(j2);k3=ifft2(ifftshift(j3);k4=ifft2(ifftshift(j4);c1=real(k1);c2=real(k2); c3=real(k3);c4=real(k4);subplot(2,3,3);imshow(c1,);title('滤波结果图像,d1=30');subplot(2,3,4);imshow(c2,);title('滤波结果图像,d2=50');subplot(2,3,5);ims
18、how(c3,);title('滤波结果图像,d3=70');subplot(2,3,6);imshow(c4,);title('滤波结果图像,d4=90');执行结果:图5 理想低通滤波器滤波结果实验结果分析:由实验结果可知,采用理想低通滤波器对加噪声的图像进行滤波运算,滤波器的滤波半径d越小,滤波后的图像越模糊,且出现明显的振铃现象,相比于巴特沃斯低通滤波器,理想低通滤波器的滤波效果会比较差。(3) 采用巴特沃斯高通滤波器对room.tif图像进行锐化滤波,并显示滤波结果图像。程序代码:clear all;close all;%(d)读入并显示原始图像roo
19、m.tif;i=imread('room.tif');subplot(1,3,1),imshow(i);title('原图像room');%(e)采用巴特沃斯高通滤波器对room.tif图像进行锐化滤波,变换不同的滤波半径i1=fftshift(fft2(i);m,n=size(i1);n=2;d1=10;d2=50;n1=floor(m/2);n2=floor(n/2);for i=1:m for j=1:n d=sqrt(i-n1)2+(j-n2)2); h1=1/(1+(d1/d)(2*n); h2=1/(1+(d2/d)(2*n); i3(i,j)=h1
20、*i1(i,j); i5(i,j)=h2*i1(i,j); endendi3=ifftshift(i3);i4=real(ifft2(i3);i5=ifftshift(i5);i6=real(ifft2(i5);subplot(1,3,2),imshow(i4,),title('butterworth高通滤波器d1=30');subplot(1,3,3),imshow(i6,),title('butterworth高通滤波器d2=50');执行结果:图6 巴特沃斯高通滤波器锐化滤波结果实验结果分析:由实验结果可知,采用butterworth高通滤波器对图像进行滤
21、波运算,滤波后图像的边缘和细节变的更加突出,是一种对图像的锐化处理。三、实验中遇到问题及解决方法实验中遇到的问题有:初期对图像在频域空间的滤波不太了解,不懂得如何利用傅立叶变换进行频域滤波;解决的方法:通过参考课本中例题及参考程序,逐步分析,加深理解。四、实验心得体会通过此次试验,初步掌握图像空域增强算法的基本原理并能在实际应用及matlab中实现;通过熟悉各类滤波器对图像处理的应用;加深对图像增强的感性认识,巩固所学理论知识。五、源程序清单%1.基于幂次变换的图像增强clear all;close all;i1=double(imread('fig534b.tif');i1=
22、i1/255;figure,subplot(2,4,1);imshow(i1,);hold oni2=double(imread('room.tif');i2=i2/255;subplot(2,4,5);imshow(i2,);hold onfor m=1:2 index=0; for lemta=0.5 5 index=index+1; fmindex=im.lemta;subplot(2,4,(m-1)*4+index+1),imshow(fmindex,)endend%2. 直方图规定化处理clear allclc close all%0.读图像i=double(imre
23、ad('lena.tiff');subplot(2,4,1);imshow(i,);title('原图')n=32;hist_image=hist(i(:),n);hist_image=hist_image/sum(hist_image);hist_image_cumulation=cumsum(hist_image);%累计直方图subplot(245);stem(0:n-1,hist_image);title('原直方图');%1.设计目标直方图index=0:n-1;%正态分布直方图hist1=exp(-(index-n/2).2/n);h
24、ist1=hist1/sum(hist1);hist_cumulation1=cumsum(hist1);subplot(242);stem(0:n-1,hist1);title('规定化直方图1');%倒三角形状直方图hist2=abs(2*n-1-2*index);hist2=hist2/sum(hist2);hist_cumulation2=cumsum(hist2);subplot(246);stem(0:n-1,hist2);title('规定化直方图2');%2. 规定化处理project1=zeros(n);project2=zeros(n);hi
25、st_result1=zeros(n);hist_result2=zeros(n);for m=1:2 image=i;%sml处理(sml,single mapping law单映射规则 for k=1:n temp=abs(hist_image_cumulation(k)-hist_cumulationm); temp1,projectm(k)=min(temp); end%2.2 变换后直方图 for k=1:n temp=find(projectm=k); if isempty(temp) hist_resultm(k)=0; else hist_resultm(k)=sum(hist
26、_image(temp); end end subplot(2,4,(m-1)*4+3); stem(0:n-1,hist_resultm); title('变换后的直方图',num2str(m); %2.3结果图step=256/n;for k=1:n index=find(i>=step*(k-1)&i<step*k); image(index)=projectm(k);endsubplot(2,4,(m-1)*4+4),imshow(image,); title('变换后的结果图',num2str(m);end%3. 灰度图像常用平常、
27、锐化滤波clear all;close all;%0.原图i=double(imread('lena.tiff');subplot(2,4,1);imshow(i,);title('原图');%1.均值低通滤波h=fspecial('average',5);f1=double(filter2(h,i);subplot(2,4,2);imshow(f1,);title('均值低通滤波');%2.gaussian 低通滤波h=fspecial('gaussian',7,3);f2=double(filter2(h,i)
28、;subplot(2,4,3);imshow(f2,);title('高斯低通滤波');%3.增强图像=原图-均值低通滤波f3=2*i-f1;subplot(2,4,4);imshow(uint8(f3),);title('原图-均值低通滤波');%4.增强图像=原图-高斯低通滤波f4=2*i-f2;subplot(2,4,5);imshow(uint8(f4),);title('原图-高斯低通滤波');%5.'prewitt'边缘算子增强h=fspecial('prewitt');f5=uint8(i+filte
29、r2(h,i);subplot(2,4,6);imshow(f5,);title('prewitt边缘算子增强');%6.'soble'边缘算子增强h=fspecial('sobel');f6=uint8(i+filter2(h,i);subplot(2,4,7);imshow(f6,);title('sobel边缘算子增强'); %4(1)butterworth低通滤波器实现图像信号的滤波运算clear all;close all;%(a) 读入并显示图像electric.tif;i=imread('electric.t
30、if');subplot(2,3,1),imshow(i);title('原图像');%(b) 利用imnoise 命令在图像electric.tif 上加入高斯(gaussian) 噪声;j=imnoise(i,'gaussian',0,0.01);subplot(2,3,2),imshow(j);title('加入高斯噪声的图像');%(c) 用butterworth低通滤波器实现图像信号的滤波运算,变换不同的截止频率d:d1=30;d2=50;d3=70;d4=90i1=fftshift(fft2(j);m,n=size(i1);n
31、=2;d1=30;d2=50;d3=70;d4=90;n1=floor(m/2);n2=floor(n/2);for i=1:m for j=1:n d=sqrt(i-n1)2+(j-n2)2); h1=1/(1+(d/d1)(2*n); h2=1/(1+(d/d2)(2*n); h3=1/(1+(d/d3)(2*n); h4=1/(1+(d/d4)(2*n); i3(i,j)=h1*i1(i,j); i5(i,j)=h2*i1(i,j); i7(i,j)=h3*i1(i,j); i9(i,j)=h4*i1(i,j); endendi3=ifftshift(i3);i4=real(ifft2(
32、i3);i5=ifftshift(i5);i6=real(ifft2(i5);i7=ifftshift(i7);i8=real(ifft2(i7);i9=ifftshift(i9);i10=real(ifft2(i9);subplot(2,3,3),imshow(i4,),title('butterworth低通滤波器d1=30');subplot(2,3,4),imshow(i6,),title('butterworth低通滤波器d2=50');subplot(2,3,5),imshow(i8,),title('butterworth低通滤波器d3=7
33、0');subplot(2,3,6),imshow(i10,),title('butterworth低通滤波器d4=90'); % 4.(2)用理想低通滤波器实现图像信号的滤波运算clear all;close all;i=imread('electric.tif');subplot(2,3,1),imshow(i);title('原图像');f=imnoise(i,'gaussian',0,0.01);subplot(2,3,2),imshow(f);title('加入高斯噪声的图像');%傅里叶变换并把
34、频谱中心移到中点f1=fft2(f);i1=fftshift(f1);%构建理想低通滤波器m,n=size(i1);d1=30;d2=50;d3=70;d4=90;n1=floor(n/2);n2=floor(m/2);for u=1:m for v=1:n if sqrt(u-n1)2+(v-n2)2)<=d1 h1(u,v)=1; else h1(u,v)=0; end end endfor u=1:m for v=1:n if sqrt(u-n1)2+(v-n2)2)<=d2 h2(u,v)=1; else h2(u,v)=0; end end endfor u=1:m fo
35、r v=1:n if sqrt(u-n1)2+(v-n2)2)<=d3 h3(u,v)=1; else h3(u,v)=0; end end endfor u=1:m for v=1:n if sqrt(u-n1)2+(v-n2)2)<=d4 h4(u,v)=1; else h4(u,v)=0; end end endj1=i1.*h1;j2=i1.*h2;j3=i1.*h3;j4=i1.*h4;k1=ifft2(ifftshift(j1);k2=ifft2(ifftshift(j2);k3=ifft2(ifftshift(j3);k4=ifft2(ifftshift(j4);c1
36、=real(k1);c2=real(k2); c3=real(k3);c4=real(k4);subplot(2,3,3);imshow(c1,);title('滤波结果图像,d1=30');subplot(2,3,4);imshow(c2,);title('滤波结果图像,d2=50');subplot(2,3,5);imshow(c3,);title('滤波结果图像,d3=70');subplot(2,3,6);imshow(c4,);title('滤波结果图像,d4=90');%4(*)用理想低通滤波器和butterworth低通滤波器对加噪图像进行滤波对比clear all;close all;i=imread('electric.tif');subplot(2,2,1),imshow(i);title(
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 阳泉市郊区2025-2026学年第二学期五年级语文第七单元测试卷(部编版含答案)
- 2026年山东体育专升本考试试题及答案
- 2026年加州叉车培训考试试题及答案
- 国际市场营销策略考试及答案
- 2026年宁夏化工总控工考试试题及答案
- 员工绩效管理标准化流程目标设定及评价方法
- 职业生涯终身学习承诺函7篇
- 个人发展成长目标承诺书5篇
- 合作企业生产质量承诺书4篇
- 回复2026年客户满意度调查结果及改进措施函3篇
- 【MOOC】中医与辨证-暨南大学 中国大学慕课MOOC答案
- JJF 1049-2024温度传感器动态响应校准规范
- 起重机械安装维修程序文件及表格-符合TSG 07-2019特种设备质量保证管理体系
- 年产330万吨生铁(其中炼钢生铁78%,铸造生铁22%)的高炉炼铁车间工艺设计
- 110kV-GIS安装专项方案内容
- AQ-T 2081-2023 金属非金属矿山在用带式输送机安全检测检验规范
- 犹太复国主义
- 销售培训:利用故事营造销售情境
- 绿色建材评价 室内木门
- 漫画人物表情画法
- 贵州省情教程 第一章 特殊的地理环境
评论
0/150
提交评论