已阅读5页,还剩19页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Matlab GUI要求利用MATLAB GUI设计实现图像处理的图形用户界面,利用MATLAB图像处理工具箱实现以下的图像处理功能: 1.实现图像的读取和保存。 2.让用户能够对图像进行任意亮度和对比度变化调整,显示变换前后的图像。 3.让用户能够用鼠标选取图像感兴趣区域,显示和保存该选择区域。 4.编写程序通过最近邻插值和双线性插值等算法将用户所选取的图像区域进行放大和缩小。整数倍的操作,并保存,比较几种插值的效果。 5.实现图像直方图统计均衡,要求显示直方图统计,比较直方图均衡后的效果。 6.对图像加入各种噪声,通过几种滤波算法实现去噪并比较去噪效果。总体GUI效果图(菜单部分功能为要求功能,界面部分及菜单部分功能为扩展功能):第一小题:(读取)代码: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;*.*,Open file,100,100);file=pathname,filename;global G %save path to restoreG=file;x=imread(file);axes(handles.axes1); %show image as reference in axes1imshow(x);axes(handles.axes2); %show image as edit in axes2imshow(x);handles.img=x;guidata(hObject,handles);截图:分析:通过uigetfile()实现打开文件对话框,并且获取选中对象的路径及文件名,将其打开。(保存)代码: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)savename,savepath=uiputfile(*.jpg;*.*,Save file,untitled.jpg,100,100);file=savepath ,savename;global HH=getimage;imwrite(H,file);handles.img=H;guidata(hObject,handles);imwrite(H,file,Quality,100);截图:分析:通过uiputfile()打开保存文件对话框,imwrite()写入磁盘。第二小题:(亮度调整)代码:function rgb_Callback(hObject, eventdata, handles)% hObject handle to rgb (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global Haxes(handles.axes2);H=getimage;defans=1;p=inputdlg(input number(more than 1 is to strengthen dark,else light),input parameter,1,defans,off);p1=str2double(p1);I=imadjust(handles.img,0,1,0,1,p1);imshow(I);handles.img=I;guidata(hObject,handles);截图:(处理前)(处理后)分析:通过inputdlg()打开输入信息对话框,输入参数,在调用imadjust()函数改变其亮度(对比度调整)代码:function strengthen_gray_Callback(hObject, eventdata, handles)% hObject handle to strengthen_gray (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)persistent aif isempty(a) a=1endif a=1 helpdlg(The effect gets better for gray,Tip);a=0;endglobal Haxes(handles.axes2);H=getimage; f=imadjust(handles.img,stretchlim(H),);imshow(f);handles.img=f;guidata(hObject,handles);截图:(处理前)(处理后)分析:通过helpdlg()输出信息对话框提示用户相关操作,imadjust(),结合stretchlim(H)调整最佳对比度。第三小题:代码:function crop_Callback(hObject, eventdata, handles)% hObject handle to crop (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global Haxes(handles.axes2);H=getimage;x=imcrop;imshow(x);handles.img=x;guidata(hObject,handles);截图:(处理前)(处理后)(保存)分析:通过imcrop函数剪取图像部分区域,getimage获取当前处理图像,打开文件保存对话框,读取路径,写入磁盘。第四小题:(最邻近插值)代码:function nearest_Callback(hObject, eventdata,handles)% hObject handle to nearest (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global H%axes(handles.axes2);H=getimage;prompt=Input Number:;defans=2;p=inputdlg(prompt,input,1,defans);p1=str2num(p1);f=imresize(H,p1);figure,imshow(f);handles.img=f;guidata(hObject,handles);截图:(处理前)(处理后)(双线性插值)代码:function bilinear_Callback(hObject, eventdata, handles)% hObject handle to bilinear (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global H%axes(handles.axes2);H=getimage;prompt=Input Number:;defans=0.5;p=inputdlg(prompt,input,1,defans);p1=str2num(p1);f=imresize(handles.img,p1,bilinear);figureimshow(f);handles.img=f;guidata(hObject,handles);(处理前)截图:(处理后)分析:通过这两种插值方法,对于最邻近插值只是简单在行列间直接插入临近若干行列,使得图像失真,对于双线性插值算法,通过X与Y方向上通过成比例插值,这样使得像素值比较连续,图像质量比较高,显得平滑,但由于高频分量值受损,图像会显得比较模糊。第五小题代码(统计):function statistics_Callback(hObject, eventdata, handles)% hObject handle to statistics (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)persistent aif isempty(a) a=1endif a=1 warndlg(Please transform it to gray,Warning,modal);a=0;endaxes(handles.axes2);x=imhist(handles.img);%xlabel(value)%ylabel(number)%legend(statistics,0)x1=x(1:10:256);y1=1:10:256;bar(y1,x1,grouped);axis(0,255,0,10000);set(handles.axes2,xtick,0:51:255); %to adapt to the changeset(handles.axes2,ytick,0:1000:10000);截图:(处理前)(统计)分析:通过调用imhist()函数将不同像素值的点进行统计,画出对应直方图,在用bar()函数将直方图调整为条状图。(代码均衡)代码:function self_adapt_Callback(hObject, eventdata, handles)% hObject handle to self_adapt (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)persistent aif isempty(a) a=1endif a=1 warndlg(Please transform it to gray,Warning,modal);a=0;endglobal Haxes(handles.axes2);H=getimage;J=adapthisteq(H);f=imshow(J);handles.img=f;guidata(hObject,handles);截图:(处理后)分析:通过dapthisteq()函数自适应调整灰度值,进行图像均衡。第六小题:代码(椒盐噪声):function pepper_Callback(hObject, eventdata, handles)% hObject handle to pepper (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global Haxes(handles.axes2);H=getimage; defans=0.05;p=inputdlg(Input density of noise:,Input parameter,1,defans);d=str2num(p1);f=imnoise(handles.img,salt & pepper,d);imshow(f);handles.img=f;guidata(hObject,handles);截图:(处理前)(处理后)(中值滤波)代码:function median_Callback(hObject, eventdata, handles)% hObject handle to median (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)persistent aif isempty(a) a=1endif a=1 warndlg(Please transform it to gray,Warning,modal);a=0;endglobal Haxes(handles.axes2);H=getimage;A=medfilt2(handles.img);imshow(A);handles.img=A;guidata(hObject,handles);截图:(高斯噪声)代码:function gaussian_Callback(hObject, eventdata, handles)% hObject handle to gaussian (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUID
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 结肠乙状扭转异物内镜复位取出术方案
- 托管老师管理协议书
- 扣税指定分摊协议书
- 2025年中职建筑工程技术(建筑技术)试题及答案
- 2025-2026学年人教版(三年级起点PEP)五年级英语上学期必刷常考题之阅读理解
- 2025年中职机械装备制造技术(机械装备制造)试题及答案
- 2025年中职机电一体化技术(机电技术应用)试题及答案
- 2025-2026学年苏科版九年级数学上册期中重难点检测卷(第1-2章)含解析
- 2025-2026学年七年级地理上学期第一次月考卷02(全解全析)
- 医院行政办公成本管控策略
- 上肢CT检查技术
- 2025年军队文职统一考试《专业科目》会计学考试题库含答案
- 技术人员向管理者的转型路径
- DB44∕T 988-2012 《地理标志产品 梅州金柚》
- 学堂在线 自我认知与情绪管理 章节测试答案
- 超市6S管理课件
- 电机外修管理办法
- 采购限价管理办法
- 格塞尔发育量表(Gesell)在儿童神经心理发育评估中的应用
- 呼吸内科咯血护理
- 智能化超声波检测与诊断系统-洞察及研究
评论
0/150
提交评论