




已阅读5页,还剩7页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
2013-1014第一学期MATLAB课程期末考核作业20120511048 王晨晨基于MATLAB GUI的图片的数字化处理界面设计1、 设计目标:利用GUI设计工具设计一个界面,该界面包括两个用于显示图片的坐标轴对象。用户通过单击相应的按钮,可以对图片进行灰度处理、均值化处理、直方图显示、亮度调节、颜色调节、旋转角度、背景颜色调节的功能。2、 打开GUI设计设计窗口,添加相关控件对象,并设置相应的属性。3、 编写代码,实现控件的功能。1、加载图片按钮的代码: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)filename,pathname =uigetfile(*.jpg;*.bmp;*.tif,加载图片);file=pathname,filename;global S; %设置一个全局变量S,S=file;x=imread(file); %选中图片axes(handles.axes1);imshow(x); %用axes1 显示原图axes(handles.axes2);imshow(x); %用axes2 显示处理后对比图handles.img=x; %用handles(句柄)存储当前图像guidata(hObject,handles); %保存handles 的内容 % - Executes on button press in pushbutton6.2、灰度处理按钮的代码;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; %获取当前图像(上一次操作后的图片)x=rgb2gray(handles.img); %二值化imshow(x); %显示二值化后图片handles.img=x; %用handles(句柄)存储当前图像guidata(hObject,handles); %保存handles(句柄)的内容3、反化按钮的代码: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)global T %设置全局变量axes(handles.axes2); %启用axes2T=getimage; %获取上次操作图片f=imcomplement(handles.img); %对图像数据进行取反运算(实现底片效果)。imshow(f); %显示之handles.img=f; %储存在句柄中guidata(hObject,handles); %保存句柄内容4、亮度调节的代码: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); %启用axes2T=getimage; %获取上一步图像prompt=调节倍数; %调节倍数对话框defans=1; %默认值设为1p=inputdlg(prompt,input,1,defans); %输入框由用户输入数值p1=str2double(p1); %把字符串转换数值y=imadjust(handles.img, , ,p1); %调节灰度图像的亮度或彩色图像imshow(y); %显示之handles.img=y;guidata(hObject,handles);5、直方图的代码:function pushbutton9_Callback(hObject, eventdata, % 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; %X轴范围设置bar(horz,x1); %调用bar函数显示直方图axis(0 255 0 15000); %设置Y轴示值范围set(handles.axes2,xtick,0:10:255); %X轴范围及分度set(handles.axes2,ytick,0:2000:15000); %Y值范围及分度6、均值按钮的代码: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)T=getimage; %获取上一步图像h=histeq(handles.img,64); %均衡化后的直方图只有64 个灰度值imshow(h); %显示之handles.img=h; %储存在句柄中guidata(hObject,handles); %保存句柄内容 7、撤销上步按钮的代码: 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) global T %全局变量axes(handles.axes2); %启用axes2imshow(T); %显示上一步图像(即撤销当前步骤的操 handles.img=T;guidata(hObject,handles); 8、恢复原图按钮的代码:function pushbutton3_Callback(hObject, eventdata, handles)% hObject handle to pushbutton3 (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); %选择原图imshow(y); %显示原图handles.img=y;guidata(hObject,handles);9、旋转图片按钮代码:function togglebutton2_Callback(hObject, eventdata, handles)% hObject handle to togglebutton2 (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);a=imread(S); %选择原图a1=imrotate(a,-45,bilinear);%旋转函数,45为旋转角度,bilinear为旋转后不是整数点的像素值 通过双线性插值得到。当旋转角度为正时,逆时针旋转;当旋转角度为负时,顺时针旋转imshow(a1);10:改变背景颜色代码:function radiobutton6_Callback(hObject, eventdata, handles)% hObject handle to radiobutton6 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) set(gcf, color, blue);11、适当调整图片颜色的代码: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 S %原图的全局变量axes(handles.axes2);a=imread(S); %选择原图b = imadjust(a,.0 .2 0; .5 .6 .5,);Heigh
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 新解读《GB-T 32552-2016无缝和焊接钢管(埋弧焊除外)的自动全圆周超声厚度检测》
- 乡下住房产权合同范本4篇
- 专业版办营业执照租房合同5篇
- 新解读《GB-T 31055-2014谷糙分离筛板》
- 新解读《GB-T 31207-2014机械产品再制造质量管理要求》
- 租房入学合同范本
- 汽修类员工合同范本
- 合作门窗项目合同范本
- 安全知识测试题(含答案)
- 合同签署中需要注意的法律问题
- 买家赎楼签协议签合同
- 2025至2030年中国虹膜识别市场深度调查分析及投资前景研究预测报告
- 《3-6岁幼儿学习与发展指南》试题及答案
- (2025年标准)合作办厂简单协议书
- 2025年新职工院感防控及传染病防治知识培训试题及答案
- 2025-2026学年人教版(2024)初中信息科技七年级(全一册)教学计划及进度表(第一学期)
- 2025年公安局招聘警务辅助人员考试笔试试题(含答案)
- 2025国家公务员考试真题(附答案)
- (标准)干洗店转让合同协议书
- Q∕GDW 11304.2-2021 电力设备带电检测仪器技术规范 第2部分:红外热像仪
- 部编版一年级道德与法治上册第1课《开开心心上学去》精品课件
评论
0/150
提交评论