matlab实现数字图像处理Photoshop小程序_第1页
matlab实现数字图像处理Photoshop小程序_第2页
matlab实现数字图像处理Photoshop小程序_第3页
matlab实现数字图像处理Photoshop小程序_第4页
matlab实现数字图像处理Photoshop小程序_第5页
已阅读5页,还剩24页未读 继续免费阅读

下载本文档

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

文档简介

1、 实验报告课程名称数字图像处理_分院班_组姓名学号_日期_年月_日 程序所实现的功能:1)图像的读取和保存。2)设计图形用户界面,让用户能够对图像进行任意的亮度和对比度变化调整,显示和对比变换前后的图像。3)设计图形用户界面,让用户能够用鼠标选取图像感兴趣区域,显示和保存该选择区域。4)图像直方图均衡,要求显示直方图统计,比较直方图均衡后的效果。5)能对图像加入各种噪声,并通过几种滤波算法实现去噪并显示结果。6)底片效果7)边缘信息8)图像反转程序实现的亮点设计简洁的菜单栏以及常用工具的快捷图标也可以使用对应功能的快捷键,包括新建,打开(CTRL+O),保存(CTRL+S);菜单栏里更是增加了

2、操作撤销与图像还原的操作,可是实现返回操作。总体设计图1软件的总体设计界面布局如上图所示,主要分为2个部分:显示区域与操作区域。显示区域:显示载入原图,以及通过处理后的图像。操作区域:通过功能键实现对图像的各种处理,为了实现界面的简洁,大部分的功能放到了菜单栏里。在截图中可见,左部为一系列功能按键如“对比度调节”“亮度调节”“裁剪”等等;界面正中部分为图片显示部分,界面中下方为系列功能切换选择组。菜单栏的设计展示1宜悴J营扁ZMICEOfUUasBis#Clrt-sChi*轟Kw81LIKf尊Hv-JgUHIss轟ww“轟 untitled图19工具底片效果:图20边缘信息: 图215、结果分

3、析软件测试基本成功,课题所要求的功能均能较好实现。但一些功能只支持灰度图像的处理。其中值得一提的是在滤波处理中的低通滤波与高通滤波的效果。由于一般图像中含有较多的低频信息成分高频成分较少,通过低通滤波后,噪声以及高频成分被滤除,图像虽有少量失真,略显模糊,但尚可辨识。但若是通过高通滤波后,大量的有效低频信息被滤除,图像严重失真,不可辨识。源码:functionduibidu_SelectionChangeFcn(hObject,eventdata,handles)%hObjecthandletotheselectedobjectinduibidu%eventdatastructurewitht

4、hefollowingfields(seeUIBUTTONGROUP)%EventName:stringSelectionChanged(readonly)%OldValue:handleofthepreviouslyselectedobjectorempty讦nonewasselected%NewValue:handleofthecurrentlyselectedobject%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalTglobalstrstr=get(hObject,string);axes(handles.axes2)

5、;switchstrcase增强T=getimage;prompt=输入参数:;defans=T;p=inputdlg(prompt,input,l,defans);pl=str2double(pl);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);ims

6、how(f);handles.img=f;guidata(hObject,handles);end%Executesonbuttonpressinliangdu.functionliangdu_Callback(hObject,eventdata,handles)%hObjecthandletoliangdu(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalTaxes(handles.axes2);T=ge

7、timage;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);%functionwenjian_Callback(hObject,eventdata,handles)%hObjecthandletowenjian(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%

8、handlesstructurewithhandlesanduserdata(seeGUIDATA)%functionopen_Callback(hObject,eventdata,handles)%hObjecthandletoopen(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)filename,pathname=uigetfile(*.jpg;*.bmp;*.tif;*.*,载入图像);讦isequal(fi

9、lename,O)lisequal(pathname,O)errordlg(没有选中文件,出错);return;elsefile=pathname,filename;globalS%设置一个全局变量S,保存初始图像路径,以便之后的还原操作S=file;x=imread(file);set(handles.axesl,HandleVisibility,ON);axes(handles.axesl);imshow(x);set(handles.axes1,HandleVisibility,OFF);axes(handles.axes2);imshow(x);handles.img=x;guidat

10、a(hObject,handles);end%functionsave_Callback(hObject,eventdata,handles)%hObjecthandletosave(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)sfilename,sfilepath=uiputfile(*.jpg;*.bmp;*.tif;*.*,保存图像文件,untitled.jpg);ifisequal(sfilename,sf

11、ilepath,O,O)sfilefullname=sfilepath,sfilename;imwrite(handles.img,sfilefullname);elsemsgbox(你按了取消键,保存失败);end%functionexitCallback(hObject,eventdata,handles)l %hObjecthandletoexit(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)clc;clos

12、eall;close(gcf);clear;%functionIM_Callback(hObject,eventdata,handles)%hObjecthandletoIM(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%functionduibidu_SelectionChangeFcn(hObject,eventdata,handles)%hObjecthandletotheselectedobjectindu

13、ibidu%eventdatastructurewiththefollowingfields(seeUIBUTTONGROUP)%EventName:stringSelectionChanged(readonly)%OldValue:handleofthepreviouslyselectedobjectorempty讦nonewasselected%NewValue:handleofthecurrentlyselectedobject%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalTglobalstrstr=get(hObjec

14、t,string);axes(handles.axes2);switchstrcase增强T=getimage;prompt=输入参数:;defans=T;p=inputdlg(prompt,input,l,defans);pl=str2double(pl);f=immultiply(handles.img,p1);imshow(f);handles.img=f;guidata(hObject,handles);case减弱T=getimage;prompt=输入参数:;defans=1;p=inputdlg(prompt,input,l,defans);pl=str2double(pl);f

15、=imdivide(handles.img,p1);imshow(f);handles.img=f;guidata(hObject,handles);end%functionhuidu_Callback(hObject,eventdata,handles)%hObjecthandletohuidu(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalTaxes(handles.axes2);T=getimage

16、;x=rgb2gray(handles.img);imshow(x);handles.img=x;guidata(hObject,handles);%functioncaijian_Callback(hObject,eventdata,handles)%hObjecthandletocaijian(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalTaxes(handles.axes2);T=getimage

17、;x=imcrop(handles.img);%截图imshow(x);handles.img=x;guidata(hObject,handles);%Executesonbuttonpressinzhifangtu.functionzhifangtu_Callback(hObject,eventdata,handles)%hObjecthandletozhifangtu(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA

18、)globalT axes(handles.axes2);T=getimage;h=histeq(handles.img);imshow(h);handles.img=h;guidata(hObject,handles);%Executeswhenselectedobjectischangedinuipanel4.functionuipanel4_SelectionChangeFcn(hObject,eventdata,handles)%hObjecthandletotheselectedobjectinuipanel4%eventdatastructurewiththefollowingfi

19、elds(seeUIBUTTONGROUP)%EventName:stringSelectionChanged(readonly)%OldValue:handleofthepreviouslyselectedobjectorempty讦nonewasselected%NewValue:handleofthecurrentlyselectedobject%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalTstr=get(hObject,string);axes(handles.axes2);switchstrcase椒盐噪声T=ge

20、timage;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=imno

21、ise(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,l,defans);pl=str2num(pl);f=imnoise(handles.img,speckle,p1);imshow(f);handles.img=f;guidata(hObject,handles);end%Executeswhenselectedobjectischangedi

22、nuipanel5.functionuipanel5_SelectionChangeFcn(hObject,eventdata,handles)%hObjecthandletotheselectedobjectinuipanel5%eventdatastructurewiththefollowingfields(seeUIBUTTONGROUP)%EventName:stringSelectionChanged(readonly)%OldValue:handleofthepreviouslyselectedobjectorempty讦nonewasselected%NewValue:handl

23、eofthecurrentlyselectedobject%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalTstr=get(hObject,string);axes(handles.axes2);switchstrcase中值滤波T=getimage;k=medfilt2(handles.img);imshow(k);handles.img=k;guidata(hObject,handles);case线性滤波T=getimage;h=111;111;111;H=h/9;i=double(handles.img);k=convn

24、(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%functionbianji_Callback(hObject,eventdata,handles)%hObjecthandletobianji(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handless

25、tructurewithhandlesanduserdata(seeGUIDATA)%functiongongju_Callback(hObject,eventdata,handles)%hObjecthandletogongju(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%functionditong_Callback(hObject,eventdata,handles)%hObjecthandletodito

26、ng(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)axes(handles.axes2);yl=handles.img;f=double(yl);%数据类型转换,matlab不支持图像的无符号整型的计算g=fft2(f);%傅里叶变换g=fftshift(g);%转换数据矩阵M,N=size(g);nn=2;%二阶巴特沃斯低通滤波器d0=50;%截止频率50m=fix(M/2);n=fix(N/2);fori=1:

27、Mforj=1:Nd=sqrt(i-m)A2+(j-n)A2);h=1/(1+0.414*(d/d0)人(2*nn);%计算低通滤波器传递函数result(i,j)=h*g(i,j);endendresult=ifftshift(result);y2=ifft2(result);y3=uint8(real(y2);imshow(y3);%显示处理后的图像%functiongaotong_Callback(hObject,eventdata,handles)%hObjecthandletogaotong(seeGCBO)%eventdatareserved-tobedefinedinafutur

28、eversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)axes(handles.axes2);x=(handles.img);f=double(x);k=fft2(f);g=fftshift(k);M,N=size(g);nn=2;d0=25;m=fix(M/2);n=fix(N/2);fori=1:Mforj=1:Nd=sqrt(i-m)A2+(j-n)A2);讦d=d0h=0;elseh=1;endresult(i,j)=h*g(i,j);endendresult=ifftshift(result);y2=if

29、ft2(result);y3=uint8(real(y2);imshow(y3);%数据类型转换%傅里叶变换%转换数据矩阵%截止频率25%计算高通滤波器传递函数%显示滤波处理后的图像%functionchexiao_Callback(hObject,eventdata,handles)%hObjecthandletochexiao(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)axes(handles.axes2);

30、%撤销globalTimshow(T);handles.img=T;guidata(hObject,handles);%functionhuanyuan_Callback(hObject,eventdata,handles)%hObjecthandletohuanyuan(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalS%还原axes(handles.axes2);y=imread(S);f=imshow

31、(y);handles.img=y;guidata(hObject,handles);%Executeswhenselectedobjectischangedinuipanel6.functionuipanel6_SelectionChangeFcn(hObject,eventdata,handles)%hObjecthandletotheselectedobjectinuipanel6%eventdatastructurewiththefollowingfields(seeUIBUTTONGROUP)%EventName:stringSelectionChanged(readonly)%Ol

32、dValue:handleofthepreviouslyselectedobjectorempty讦nonewasselected%NewValue:handleofthecurrentlyselectedobject%handlesstructurewithhandlesanduserdata(seeGUIDATA)str=get(hObject,string);axes(handles.axes2);globalTswitchstrcase左右翻转T=handles.img;f=fliplr(handles.img);imshow(f);handles.img=f;guidata(hObject,handles);case上下翻转T=handles.img;f=flipud(

温馨提示

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

最新文档

评论

0/150

提交评论