数字图像处理-降噪滤波-大作业要点_第1页
数字图像处理-降噪滤波-大作业要点_第2页
数字图像处理-降噪滤波-大作业要点_第3页
数字图像处理-降噪滤波-大作业要点_第4页
数字图像处理-降噪滤波-大作业要点_第5页
免费预览已结束,剩余22页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1 昆明理工大学信息工程与自动化学院学生实验报告昆明理工大学信息工程与自动化学院学生实验报告 2015 2016 学年学年 第第 一一 学期学期 课程名称 图形图像基础程序设计课程名称 图形图像基础程序设计 开课实验室 开课实验室 20152015 年年 1212 月月 1 1 日日 年级 专业 年级 专业 班班 物联网物联网 131131学号学号 201310410133201310410133 姓名姓名李哲李哲成绩成绩 实验项目名称实验项目名称图像综合处理图像综合处理指导教师指导教师毛存礼毛存礼 教教 师师 评评 语语 教师签名 教师签名 年年 月月 日日 一 实验目的及内容实验目的及内容 目的 掌握和熟悉目的 掌握和熟悉 MatlabMatlab 编程环境及语言 掌握图像降噪算法和用途 编程环境及语言 掌握图像降噪算法和用途 内容 内容 在课程教学和查阅相关文献资料的基础上 选择下面一个数字图像处理技术专题 实现相应算法进行仿真 实验 并完成大作业报告 专题如下 1 图像增强处理技术 2 图像降噪处理技术 2 2 题目分析 题目分析 利用 matlab 的 GUI 程序设计一个简单实用的图像处理程序 该程序应具备图像处理的常用功 能 以满足用户的使用 现设计程序有以下基本功能 1 图像的读取和保存 2 通过自己输入数值 实现图像的旋转 3 图像直方图统计和直方图均衡 要求显示直方图统计 比较直方图均衡后的效果 4 能对图像加入各种噪声 5 并通过几种滤波算法实现去噪并显示结果 6 将图像转化成灰度图像 2 3 3 总体设计总体设计 软件的总体设计界面布局如上图所示 分为显示区域与操作区域 上边为显示区域 显示载入原图 以及通过处理后的图像 操作区域 通过功能键实现对图像的各种处理 设计完成后运行的软件界面如下 3 4 4 具体设计 具体设计 现介绍各个功能模块的功能与实现 4 14 1 图像的读取和保存 图像的读取和保存 1 利用matlab中 uigetfile imread imshow 实现图像文件的读取与显示 实现代码 function pushbutton2 Callback hObject eventdata handles hObject handle to pushbutton2 see GCBO 4 eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA filename pathname uigetfile jpg bmp tif 载入图像 if isequal filename 0 isequal pathname 0 errordlg 没有选中文件 出错 return else file pathname filename global S 设置一个全局变量 S 保存初始图像路径 以便之后的还原操作 S file x imread file set handles axes1 HandleVisibility ON axes handles axes1 imshow x set handles axes1 HandleVisibility OFF axes handles axes2 imshow x handles img x guidata hObject handles end Executes on button press in pushbutton4 function pushbutton4 Callback hObject eventdata handles hObject handle to pushbutton4 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA sfilename sfilepath uiputfile jpg bmp tif 保存图像文件 untitled jpg if isequal sfilename sfilepath 0 0 sfilefullname sfilepath sfilename imwrite handles img sfilefullname else msgbox 你按了取消键 保存失败 end 2 图像保存 利用uiputfile和imwrite函数实现图像文件的保存 5 实现代码 function pushbutton4 Callback hObject eventdata handles hObject handle to pushbutton4 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA sfilename sfilepath uiputfile jpg bmp tif 保存图像文件 untitled jpg if isequal sfilename sfilepath 0 0 sfilefullname sfilepath sfilename imwrite handles img sfilefullname else msgbox 你按了取消键 保存失败 end 3 程序的退出 6 实现代码 function pushbutton5 Callback hObject eventdata handles hObject handle to pushbutton5 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA clc close all close gcf clear 4 24 2图像转化为灰度图像图像转化为灰度图像 因为matlab中较多的图像处理函数支持对灰度图像进行处理 故对图像进行灰度转化十分必要 利用rgb2gray X 函数对其他图像进行灰度图像的转化 7 实现代码 function pushbutton11 Callback hObject eventdata handles hObject handle to pushbutton11 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA global T axes handles axes2 T getimage x rgb2gray handles img RGB imshow x handles img x guidata hObject handles 4 34 3图像直方图统计和直方图均衡图像直方图统计和直方图均衡 1 通过histeq X 函数实现直方图均衡 此函数只能对灰度图像进行直方图均衡所以要先将彩图转为灰度图像 实现代码 function pushbutton12 Callback hObject eventdata handles hObject handle to pushbutton12 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA global T 8 axes handles axes2 T getimage h histeq handles img imshow h handles img h guidata hObject handles 2 直方图统计 通过利用 imhist X 函数来实现直方图统计 实现代码 function pushbutton13 Callback hObject eventdata handles hObject handle to pushbutton13 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA axes handles axes2 x imhist handles img 直方图统计 x1 x 1 10 256 horz 1 10 256 bar horz x1 axis 0 255 0 15000 set handles axes2 xtick 0 50 255 set handles axes2 ytick 0 2000 15000 4 44 4加入各种噪声 并通过几种滤波算法实现去噪加入各种噪声 并通过几种滤波算法实现去噪 1 加入噪声 通过imnoise I type parameters 来加入各种噪声 9 加入椒盐噪声 实现代码 function pushbutton6 Callback hObject eventdata handles hObject handle to pushbutton6 see GCBO eventdata reserved to be defined in a future version of MATLAB 10 handles structure with handles and user data see GUIDATA global T axes handles axes2 T getimage prompt 数日椒盐噪声参数 1 defans 0 02 p inputdlg prompt input 1 defans p1 str2num p 1 f imnoise handles img salt imshow f handles img f guidata hObject handles 加入高斯噪声 11 实现代码 function pushbutton10 Callback hObject eventdata handles hObject handle to pushbutton10 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA global T axes handles axes2 T getimage prompt 输入高斯噪声 1 输入高斯噪声 2 defans 0 0 02 p inputdlg prompt input 1 defans p1 str2num p 1 p2 str2num p 2 f imnoise handles img gaussian p1 p2 imshow f handles img f guidata hObject handles 加入乘性噪声 12 实现代码 function pushbutton8 Callback hObject eventdata handles hObject handle to pushbutton8 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA global T axes handles axes2 13 T getimage prompt 输入乘性噪声 1 defans 0 02 p inputdlg prompt input 1 defans p1 str2num p 1 f imnoise handles img speckle p1 imshow f handles img f guidata hObject handles 2 滤除噪声 椒盐噪声 滤波前 中值滤波后 14 实现代码 function pushbutton14 Callback hObject eventdata handles hObject handle to pushbutton14 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA global T axes handles axes2 T getimage k medfilt2 handles img imshow k handles img k guidata hObject handles 线性滤波后 15 实现代码 function pushbutton16 Callback hObject eventdata handles hObject handle to pushbutton16 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA global T axes handles axes2 T getimage h 1 1 1 1 1 1 1 1 1 H h 9 i double handles img k convn i h imshow k handles img k guidata hObject handles 自适应滤波后 实现代码 function pushbutton18 Callback hObject eventdata handles hObject handle to pushbutton18 see GCBO 16 eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA global T axes handles axes2 T getimage k wiener2 handles img 5 5 imshow k handles img k guidata hObject handles 低通滤波器滤波后 实现代码 function pushbutton19 Callback hObject eventdata handles hObject handle to pushbutton19 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA axes handles axes2 y1 handles img f double y1 数据类型转换 matlab 不支持图像的无符号整型的计算 g fft2 f 傅里叶变换 g fftshift g 转换数据矩阵 M N size g nn 2 二阶巴特沃斯低通滤波器 d0 50 截止频率 50 m fix M 2 n fix N 2 for i 1 M for j 1 N 17 d sqrt i m 2 j n 2 h 1 1 0 414 d d0 2 nn 计算低通滤波器传递函数 result i j h g i j end end result ifftshift result y2 ifft2 result y3 uint8 real y2 imshow y3 显示处理后的图像 高通滤波器滤波后 实现代码 function pushbutton20 Callback hObject eventdata handles hObject handle to pushbutton20 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA axes handles axes2 x handles img f double x 数据类型转换 k fft2 f 傅里叶变换 g fftshift k 转换数据矩阵 M N size g nn 2 d0 25 截止频率 25 18 m fix M 2 n fix N 2 for i 1 M for j 1 N d sqrt i m 2 j n 2 计算高通滤波器传递函数 if d d0 h 0 else h 1 end result i j h g i j end end result ifftshift result y2 ifft2 result y3 uint8 real y2 imshow y3 显示滤波处理后的图像 4 54 5 还原还原 通过一个全局变量保存原始图像路径 在需要还原至原始图像时 重新读取该全局变量即可 实现代码 function pushbutton21 Callback hObject eventdata handles hObject handle to pushbutton21 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA global S 还原 axes handles axes2 y imread S f imshow y handles img y guidata hObject handles 5 5 结果分析 结果分析 软件测试基本成功 课题所要求的功能均能较好实现 但一些功能只支持灰度图像的处理 其中值得一提的是在滤波处理中的低通滤波与高通滤波的效果 由于一般图像中含有较多的 低频信息成分高频成分较少 通过低通滤波后 噪声以及高频成分被滤除 图像虽有少量失真 略显模糊 但尚可辨识 但若是通过高通滤波后 大量的有效低频信息被滤除 图像严重失真 不可辨识 19 当我第一次拿到此次的课题时 感到有些无所适从 虽然 曾经学习过 matlab 的课程 在课程的 考核中也取得了较好的成绩 但由于对 matlab 的学习更多的只是停留在理论上的学习 在课时内 的试验也只是简单的基础性试验 所以对 matlab 实际运用不是很熟练 为此 在实践正式开始前 我利用课余时间 重新复习了 matlab 教材 专门借阅了利用 matlab 进行图像处理的相关教程 通过索引网络上的相关资料 为课设做了较为充分的准备 在 参考了相关材料及源程序 我对自己要做的课设内容有了进一步的了解 并对 matlab 的使用有了 更深的体会 当然 在课设的进行过程中 我还是遇到了不少问题 例如 起初由于我对句柄使用以及一 些函数使用的不恰当 使得在对图像文件的保存上就遇到了问题 不过最后还是在老师的提示下 解决了 随着课设的进行 对 matlab 的的熟悉度逐步加深 总体来说 此次的课程设计 还是较为满意的 它不但鞭策着我去巩固 matlab 的基础理论知 识 还提高了我对 matlab 的实际操作运用 使得理论与实践相结合 为进一步学习 matlab 打下 坚实的基础 同时 在实践的工程中 也让我体会到一种努力付出并得到回报的满足感觉 参考书目参考书目 五号 宋体加粗 1 1 数字图像处理 数字图像处理 MATLABMATLAB 第二版第二版 美美 Rafael Rafael C GonzalezC Gonzalez 电子工业出版社电子工业出版社 附录附录 五号 宋体加粗 function varargout faded varargin FADED MATLAB code for faded fig FADED by itself creates a new FADED or raises the existing singleton H FADED returns the handle to a new FADED or the handle to the existing singleton FADED CALLBACK hObject eventData handles calls the local function named CALLBACK in FADED M with the given input arguments FADED Property Value creates a new FADED or raises the existing singleton Starting from the left property value pairs are applied to the GUI before faded OpeningFcn gets called An unrecognized property name or invalid value makes property application stop All inputs are passed to faded OpeningFcn via varargin See GUI Options on GUIDE s Tools menu Choose GUI allows only one instance to run singleton 20 See also GUIDE GUIDATA GUIHANDLES Edit the above text to modify the response to help faded Last Modified by GUIDE v2 5 29 Dec 2015 22 05 27 Begin initialization code DO NOT EDIT gui Singleton 1 gui State struct gui Name mfilename gui Singleton gui Singleton gui OpeningFcn faded OpeningFcn gui OutputFcn faded OutputFcn gui LayoutFcn gui Callback if nargin end if nargout varargout 1 nargout gui mainfcn gui State varargin else gui mainfcn gui State varargin end End initialization code DO NOT EDIT Executes just before faded is made visible function faded OpeningFcn hObject eventdata handles varargin This function has no output args see OutputFcn hObject handle to figure eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA varargin command line arguments to faded see VARARGIN Choose default command line output for faded handles output hObject Update handles structure guidata hObject handles UIWAIT makes faded wait for user response see UIRESUME uiwait handles figure1 Outputs from this function are returned to the command line function varargout faded OutputFcn hObject eventdata handles varargout cell array for returning output args see VARARGOUT hObject handle to figure eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA 21 Get default command line output from handles structure varargout 1 handles output Executes on button press in pushbutton2 function pushbutton2 Callback hObject eventdata handles hObject handle to pushbutton2 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA filename pathname uigetfile jpg bmp tif 载入图像 if isequal filename 0 isequal pathname 0 errordlg 没有选中文件 出错 return else file pathname filename global S 设置一个全局变量 S 保存初始图像路径 以便之后的还原操作 S file x imread file set handles axes1 HandleVisibility ON axes handles axes1 imshow x set handles axes1 HandleVisibility OFF axes handles axes2 imshow x handles img x guidata hObject handles end Executes on button press in pushbutton4 function pushbutton4 Callback hObject eventdata handles hObject handle to pushbutton4 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA sfilename sfilepath uiputfile jpg bmp tif 保存图像文件 untitled jpg if isequal sfilename sfilepath 0 0 sfilefullname sfilepath sfilename imwrite handles img sfilefullname else msgbox 你按了取消键 保存失败 end Executes on button press in pushbutton5 function pushbutton5 Callback hObject eventdata handles hObject handle to pushbutton5 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA clc close all close gcf 22 clear Executes on button press in pushbutton6 function pushbutton6 Callback hObject eventdata handles hObject handle to pushbutton6 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA global T axes handles axes2 T getimage prompt 数日椒盐噪声参数 1 defans 0 02 p inputdlg prompt input 1 defans p1 str2num p 1 f imnoise handles img salt imshow f handles img f guidata hObject handles Executes on button press in pushbutton7 function pushbutton7 Callback hObject eventdata handles hObject handle to pushbutton7 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA Executes on button press in pushbutton8 function pushbutton8 Callback hObject eventdata handles hObject handle to pushbutton8 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA global T axes handles axes2 T getimage prompt 输入乘性噪声 1 defans 0 02 p inputdlg prompt input 1 defans p1 str2num p 1 f imnoise handles img speckle p1 imshow f handles img f guidata hObject handles Executes on button press in pushbutton9 function pushbutton9 Callback hObject eventdata handles hObject handle to pushbutton9 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA Executes on button press in pushbutton10 function pushbutton10 Callback hObject eventdata handles 23 hObject handle to pushbutton10 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA global T axes handles axes2 T getimage prompt 输入高斯噪声 1 输入高斯噪声 2 defans 0 0 02 p inputdlg prompt input 1 defans p1 str2num p 1 p2 str2num p 2 f imnoise handles img gaussian p1 p2 imshow f handles img f guidata hObject handles Executes on button press in pushbutton11 function pushbutton11 Callback hObject eventdata handles hObject handle to pushbutton11 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA global T axes handles axes2 T getimage x rgb2gray handles img RGB imshow x handles img x guidata hObject handles Executes on button press in pushbutton12 function pushbutton12 Callback hObject eventdata handles hObject handle to pushbutton12 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA global T axes handles axes2 T getimage h histeq handles img imshow h handles img h guidata hObject handles Executes on button press in pushbutton13 function pushbutton13 Callback hObject eventdata handles hObject handle to pushbutton13 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA axes handles axes2 24 x imhist handles img 直方图统计 x1 x 1 10 256 horz 1 10 256 bar horz x1 axis 0 255 0 15000 set handles axes2 xtick 0 50 255 set handles axes2 ytick 0 2000 15000 Executes on button press in pushbutton14 function pushbutton14 Callback hObject eventdata handles hObject handle to pushbutton14 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA global T axes handles axes2 T getimage k medfilt2 handles img imshow k handles img k guidata hObject handles Executes on button press in pushbutton16 function pushbutton16 Callback hObject eventdata handles hObject handle to pushbutton16 see GCBO eventdata reserved to be defined in a future version of MATLAB handles structure with handles and user data see GUIDATA global T axes handles axes2 T getimage h 1 1 1 1 1 1 1 1 1 H h 9 i double handles img k convn i h imshow k handles img k guidata hObject handles Executes on button press in pushbutton18 function pushbutton18 Callback hObject eventdata handles hObjec

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论