已阅读5页,还剩19页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
实 验 报 告 课程名称 数字图像处理 分院 班 组 姓名 学号 日期 年 月 日 程序所实现的功能:1)图像的读取和保存。 2)设计图形用户界面,让用户能够对图像进行任意的亮度和对比度变化调整,显示和对比变换前后的图像。 3)设计图形用户界面,让用户能够用鼠标选取图像感兴趣区域,显示和保存该选择区域。 4)图像直方图均衡,要求显示直方图统计,比较直方图均衡后的效果。 5)能对图像加入各种噪声,并通过几种滤波算法实现去噪并显示结果。6) 底片效果7)边缘信息8)图像反转程序实现的亮点设计简洁的菜单栏以及常用工具的快捷图标也可以使用对应功能的快捷键,包括新建,打开(CTRL+O),保存(CTRL+S);菜单栏里更是增加了操作撤销与图像还原的操作,可是实现返回操作。总体设计图1软件的总体设计界面布局如上图所示,主要分为 2 个部分:显示区域与操作区域。 显示区域:显示载入原图,以及通过处理后的图像。 操作区域:通过功能键实现对图像的各种处理,为了实现界面的简洁,大部分的功能放到了 菜单栏里。 在截图中可见,左部为一系列功能按键如“对比度调节”、“亮度调节”、“裁剪”等等 ;界面正中部分为图片显示部分,界面中下方为系列功能切换选择组。 菜单栏的设计展示图2具体设计 现介绍各个功能模块的功能与实现。4.1 菜单栏的设计。 通过 Menu Editor 创建如下菜单,通过以下菜单来控制显示或隐藏功能按键图3以“文件”菜单中“打开”为例说明实现用户界面功能键“打开”的显示与隐藏。 实现该功能通过添加callback就可以了: 通过Toolbar Editor可以添加快捷图标,如下图:图4 图像的读取和保存。 (1) 利用“文件”菜单中的“打开”、“ 保存”或者使用菜单栏下的快捷图标分别实现图片的读取与保存。 图5如果没有选中文件还会提示图6(2)图像保存。 利用“uiputfile”、“imwrite”函数实现图像文件的保存。 图7同样按下去下取消键会提示:图8(3)程序的退出。 你可以在菜单栏使用退出键,或者在主界面右下角有关闭按钮就可以退出程序。对图像进行任意的亮度和对比度变化调整,显示和对比变换前后的图像。 按下亮度调节按钮会弹出输入框,输入调节倍数,如下图:图9(注意:这里的倍数是相反的调节,你会发现输入0.1后亮度会变亮)调节后的图像如下:图11对比度的调节跟亮度一样,调节后的图像如下:图12 44 用鼠标选取图像感兴趣区域,显示和保存该选择区域。按下裁剪按钮把鼠标移动到处理后的图像窗口,光标会变成十字形状,拖动光标会出现方框,如下:图13双击方框里的图像就完成了裁剪。4.5 图像转化为灰度图像。由于在matlab中较多的图像处理函数支持对灰度图像进行处理,故对图像进行灰度转化十分必要。可利用rgb2gray(X)函数对其他图像进行灰度图像的转化。 转化实例如下: 图144.8 加入各种噪声,并通过几种滤波算法实现去噪。(1) 加入噪声。通过imnoise(I,type,parameters)来加入各种噪声。加入椒盐噪声 图15加入噪声后:图16高斯噪声:乘性噪声:图17这几种噪声我加入的参数都是0.02,效果逐渐加深。滤波:选择线性滤波的结果如下,可以看出滤去了大部分噪声,(注意:这几个滤波不可以叠加使用,否则出现白屏)图17翻转:左右翻转图18上下翻转:图19工具底片效果:图20边缘信息:图215、结果分析 软件测试基本成功,课题所要求的功能均能较好实现。但一些功能只支持灰度图像的处理。 其中值得一提的是在滤波处理中的低通滤波与高通滤波的效果。由于一般图像中含有较多的低频信息成分高频成分较少,通过低通滤波后,噪声以及高频成分被滤除,图像虽有少量失真,略显模糊,但尚可辨识。但若是通过高通滤波后,大量的有效低频信息被滤除,图像严重失真,不可辨识。 源码:function duibidu_SelectionChangeFcn(hObject, eventdata, handles)% hObject handle to the selected object in duibidu % eventdata structure with the following fields (see UIBUTTONGROUP)%EventName: string SelectionChanged (read only)%OldValue: handle of the previously selected object or empty if none was selected%NewValue: handle of the currently selected object% handles structure with handles and user data (see GUIDATA)global T global strstr=get(hObject,string); axes(handles.axes2); switch str case增强 T=getimage; prompt=输入参数:; defans=1; p=inputdlg(prompt,input,1,defans); p1=str2double(p1); f=immultiply(handles.img,p1); imshow(f); handles.img=f; guidata(hObject,handles); case减弱 T=getimage; prompt=输入参数:; defans=1; p=inputdlg(prompt,input,1,defans); p1=str2double(p1); f=imdivide(handles.img,p1); imshow(f); handles.img=f; guidata(hObject,handles); end% - Executes on button press in liangdu.function liangdu_Callback(hObject, eventdata, handles)% hObject handle to liangdu (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=调整倍数; defans=1; p=inputdlg(prompt,input,1,defans); p1=str2double(p1); y=imadjust(handles.img, , ,p1); %亮度调节 imshow(y); handles.img=y; guidata(hObject,handles);% -function wenjian_Callback(hObject, eventdata, handles)% hObject handle to wenjian (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% -function open_Callback(hObject, eventdata, handles)% hObject handle to open (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% -function save_Callback(hObject, eventdata, handles)% hObject handle to save (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 % -function exit_Callback(hObject, eventdata, handles)% hObject handle to exit (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; % -function IM_Callback(hObject, eventdata, handles)% hObject handle to IM (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% -function duibidu_SelectionChangeFcn(hObject, eventdata, handles)% hObject handle to the selected object in duibidu % eventdata structure with the following fields (see UIBUTTONGROUP)%EventName: string SelectionChanged (read only)%OldValue: handle of the previously selected object or empty if none was selected%NewValue: handle of the currently selected object% handles structure with handles and user data (see GUIDATA)global T global strstr=get(hObject,string); axes(handles.axes2); switch str case增强 T=getimage; prompt=输入参数:; defans=1; p=inputdlg(prompt,input,1,defans); p1=str2double(p1); f=immultiply(handles.img,p1); imshow(f); handles.img=f; guidata(hObject,handles); case减弱 T=getimage; prompt=输入参数:; defans=1; p=inputdlg(prompt,input,1,defans); p1=str2double(p1); f=imdivide(handles.img,p1); imshow(f); handles.img=f; guidata(hObject,handles); end% -function huidu_Callback(hObject, eventdata, handles)% hObject handle to huidu (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); imshow(x); handles.img=x; guidata(hObject,handles); % -function caijian_Callback(hObject, eventdata, handles)% hObject handle to caijian (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=imcrop(handles.img); %截图 imshow(x); handles.img=x; guidata(hObject,handles); % - Executes on button press in zhifangtu.function zhifangtu_Callback(hObject, eventdata, handles)% hObject handle to zhifangtu (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global Taxes(handles.axes2); T=getimage; h=histeq(handles.img); imshow(h); handles.img=h; guidata(hObject,handles); % - Executes when selected object is changed in uipanel4.function uipanel4_SelectionChangeFcn(hObject, eventdata, handles)% hObject handle to the selected object in uipanel4 % eventdata structure with the following fields (see UIBUTTONGROUP)%EventName: string SelectionChanged (read only)%OldValue: handle of the previously selected object or empty if none was selected%NewValue: handle of the currently selected object% handles structure with handles and user data (see GUIDATA)global T str=get(hObject,string); axes(handles.axes2); switch str case 椒盐噪声 T=getimage; prompt=数日椒盐噪声参数1:; defans=0.02; p=inputdlg(prompt,input,1,defans); p1=str2num(p1); f=imnoise(handles.img,salt & pepper,p1); imshow(f); handles.img=f; guidata(hObject,handles); case 高斯噪声 T=getimage; prompt=输入高斯噪声1:,输入高斯噪声2; defans=0,0.02; p=inputdlg(prompt,input,1,defans); p1=str2num(p1); p2=str2num(p2); f=imnoise(handles.img,gaussian,p1,p2); imshow(f); handles.img=f; guidata(hObject,handles); case 乘性噪声 T=getimage; prompt=输入乘性噪声1:; defans=0.02; p=inputdlg(prompt,input,1,defans); p1=str2num(p1); f=imnoise(handles.img,speckle,p1); imshow(f); handles.img=f; guidata(hObject,handles); end % - Executes when selected object is changed in uipanel5.function uipanel5_SelectionChangeFcn(hObject, eventdata, handles)% hObject handle to the selected object in uipanel5 % eventdata structure with the following fields (see UIBUTTONGROUP)%EventName: string SelectionChanged (read only)%OldValue: handle of the previously selected object or empty if none was selected%NewValue: handle of the currently selected object% handles structure with handles and user data (see GUIDATA)global T str=get(hObject,string); axes(handles.axes2);switch str case 中值滤波 T=getimage; k=medfilt2(handles.img); imshow(k); handles.img=k; guidata(hObject,handles); case 线性滤波 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); case 自适应滤波 T=getimage; k=wiener2(handles.img,5,5); imshow(k); handles.img=k; guidata(hObject,handles); end % -function bianji_Callback(hObject, eventdata, handles)% hObject handle to bianji (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% -function gongju_Callback(hObject, eventdata, handles)% hObject handle to gongju (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% -function ditong_Callback(hObject, eventdata, handles)% hObject handle to ditong (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 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 gaotong_Callback(hObject, eventdata, handles)% hObject handle to gaotong (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 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); % 显示滤波处理后的图像 % -function chexiao_Callback(hObject, eventdata, handles)% hObject handle to chexiao (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); %撤销 global T imshow(T); handles.img=T; guidata(hObject,handles); % -function huanyuan_Callback(hObject, eventdata, handles)% hObject handle to huanyuan (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); % - Executes when selected object is changed in uipanel6.function uipanel6_SelectionChangeFcn(hObject, eventdata, handles)% hObject handle to the selected object in uipanel6 % eventdata structure with the following fields (see UIBUTTONGROUP)%EventName: string SelectionChanged (read only)%OldValue: handle of the previously selected object or empty if none was selected%NewValue: handle of the currently selected object% handles structure with handles and user data (see GUIDATA)str=get(hObject,string); axes(handles.axes2); global T switch str case 左右翻转 T=handles.img; f=fliplr(handles.img); imshow(f)
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年军事分析师招聘面试题库及参考答案
- 2025年制图师招聘面试参考题库及答案
- 2025年新闻采编招聘面试参考题库及答案
- 2025年健康服务专员招聘面试参考题库及答案
- 宁波消防中级考试题库及答案
- 2025年轮胎设计工程师招聘面试参考题库及答案
- 2025年品牌策略专员招聘面试题库及参考答案
- 2025年技术文档编写管理员招聘面试参考题库及答案
- 2025年外国驻华人员招聘专员招聘面试参考题库及答案
- 2025年医疗健康专员招聘面试参考题库及答案
- 护理求职展示
- 高中选科规划课件
- 2025年互联网信息审核员考试题库及答案
- 2025年乡村振兴面试题及答案
- 2025年《新课程标准解读》标准课件
- 2024年普通高中学业水平选择性考试(福建卷)物理试题含答案
- 交流发言:深入实施数字化转型条件下税费征管“强基工程”推动县税务局工作高质量发展
- 1与食品经营相适应的操作流程
- 高考数学专项复习:导数压轴大题归类(解析版)
- DB52-T1626-2021水利工程调整概算报告编制导则
- 第九章 幼儿园组织文化建设课件
评论
0/150
提交评论