




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1、艮C人了*方lY乞20122013學(xué)年第二學(xué)期課程名稱:教學(xué)實踐II:軟硬件提高訓(xùn)練任課教師:題目:MATLAB數(shù)字圖像處理學(xué)號:ROB12023姓名:年級:2012級專業(yè):自動化設(shè)計目的利用MATLAB的GUI程序設(shè)計一個簡單實用的圖像處理程序。該程序應(yīng)具備圖像處理的常用功能,以滿足要求。設(shè)計要求設(shè)計程序有以下基本功能:1)圖像的讀取、保存和程序退出2)圖像轉(zhuǎn)化為灰度圖像3)底片處理(反色)4)截圖5)亮度和對比度度調(diào)節(jié)6)圖像的翻轉(zhuǎn)與旋轉(zhuǎn)7)添加噪聲8)平滑和銳化9)直方圖均衡化處理1)0圖像的腐蝕和膨脹1)1邊緣檢測1)2還原和撤銷3.總體設(shè)計0數(shù)宇圖辣處理實驗=-5E*TDKiR吒RA
2、ttW!*Ht2A=handles.img;R=A(:,:,1);G=A(:,:,2);B=A(:,:,3);GP(:,:,1)=medfilt2(R,p1p1);GP(:,:,2)=medfilt2(G,p1p1);GP(:,:,3)=medfilt2(B,p1p1);imshow(GP);handles.img=GP;elseA=handles.img;I=medfilt2(A,p1p1);imshow(I);handles.img=I;1)主要程序f=imrotate(handles.img,p1,bilinear,crop);%圖像的旋轉(zhuǎn)2)運行結(jié)果guidata(hObject,ha
3、ndles);end%-Executesonbuttonpressinpushbutton20.functionpushbutton20_Callback(hObject,eventdata,handles)%hObjecthandletopushbutton20(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)clc;closeall;close(gcf);clear;%-Executesonbuttonpressi
4、npushbutton16.functionpushbutton16_Callback(hObject,eventdata,handles)%hObjecthandletopushbutton16(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalTstr=get(handles.popupmenu5,value);axes(handles.axes2);switchstrcase1T=handles.img
5、;prompt=請輸入模版維度:;defans=3;p=inputdlg(prompt,input,1,defans);p1=str2num(p1);h1=fspecial(average,p1p1);I=imfilter(handles.img,h1);imshow(I);handles.img=I;guidata(hObject,handles);case2T=handles.img;prompt=請輸入模版維度:;defans=3;p=inputdlg(prompt,input,1,defans);p1=str2num(p1);ifnumel(size(handles.img)2A=ha
6、ndles.img;R=A(:,:,1);G=A(:,:,2);B=A(:,:,3);GP(:,:,1)=medfilt2(R,p1p1);GP(:,:,2)=medfilt2(G,p1p1);GP(:,:,3)=medfilt2(B,p1p1);imshow(GP);handles.img=GP;elseA=handles.img;I=medfilt2(A,p1p1);imshow(I);handles.img=I;endguidata(hObject,handles);end%-Executesonbuttonpressinpushbutton18.functionpushbutton18
7、_Callback(hObject,eventdata,handles)%銳化%hObjecthandletopushbutton18(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalTstr=get(handles.popupmenu6,value);axes(handles.axes2);T=handles.img;g=handles.img;switchstrcase1h=fspecial(sobel
8、);case2h=fspecial(prewitt);case3h=fspecial(laplacian);endifnumel(size(g)2R=g(:,:,1);G=g(:,:,2);B=g(:,:,3);R1=imfilter(R,h);GP(:,:,1)=imadd(R,R1);G1=imfilter(G,h);GP(:,:,2)=imadd(G,G1);B1=imfilter(B,h);GP(:,:,3)=imadd(B,B1);imshow(GP);handles.img=GP;elseg1=g;g2=imfilter(g1,h);g3=imadd(g2,g1);imshow(g
9、3);handles.img=g3;endguidata(hObject,handles);%-Executesonselectionchangeinpopupmenu5.functionpopupmenu5_Callback(hObject,eventdata,handles)%hObjecthandletopopupmenu5(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:contents=cell
10、str(get(hObject,String)returnspopupmenu5contentsascellarray%contentsget(hObject,Value)returnsselecteditemfrompopupmenu5%-Executesduringobjectcreation,aftersettingallproperties.functionpopupmenu5_CreateFcn(hObject,eventdata,handles)%hObjecthandletopopupmenu5(seeGCBO)%eventdatareserved-tobedefinedinaf
11、utureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:popupmenucontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor)set(hObject,BackgroundColor,white);end%-Executesonselectio
12、nchangeinpopupmenu6.functionpopupmenu6_Callback(hObject,eventdata,handles)%hObjecthandletopopupmenu6(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:contents=cellstr(get(hObject,String)returnspopupmenu6contentsascellarray%conten
13、tsget(hObject,Value)returnsselecteditemfrompopupmenu6%-Executesduringobjectcreation,aftersettingallproperties.functionpopupmenu6_CreateFcn(hObject,eventdata,handles)%hObjecthandletopopupmenu6(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCr
14、eateFcnscalled%Hint:popupmenucontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor)set(hObject,BackgroundColor,white);end%-Executesonbuttonpressinpushbutton10.functionpushbutton10_Callback(hObject,eventdata,
15、handles)%檢測%hObjecthandletopushbutton10(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalTstr=get(handles.popupmenu4,value);axes(handles.axes2);ifnumel(size(handles.img)2I=handles.img;switchstrcase1T=handles.img;img=I;xyz=size(img
16、);ifz=1rslt=edge(img,Roberts);elseifz=3img1=rgb2ycbcr(img);dx1=edge(img1(:,:,1),Roberts);dx1=(dx1*255);img2(:,:,1)=dx1;img2(:,:,2)=img1(:,:,2);img2(:,:,3)=img1(:,:,3);rslt=ycbcr2rgb(uint8(img2);endimshow(rslt);handles.img=rslt;guidata(hObject,handles);case2T=handles.img;img=I;xyz=size(img);ifz=1rslt
17、=edge(img,sobel);elseifz=3img1=rgb2ycbcr(img);dx1=edge(img1(:,:,1),sobel);dx1=(dx1*255);img2(:,:,1)=dx1;img2(:,:,2)=img1(:,:,2);img2(:,:,3)=img1(:,:,3);rslt=ycbcr2rgb(uint8(img2);endimshow(rslt);handles.img=rslt;guidata(hObject,handles);case3T=handles.img;img=I;xyz=size(img);ifz=1rslt=edge(img,Prewi
18、tt);elseifz=3img1=rgb2ycbcr(img);dx1=edge(img1(:,:,1),Prewitt);dx1=(dx1*255);img2(:,:,1)=dx1;img2(:,:,2)=img1(:,:,2);img2(:,:,3)=img1(:,:,3);rslt=ycbcr2rgb(uint8(img2);endimshow(rslt);handles.img=rslt;guidata(hObject,handles);case4T=handles.img;img=I;xyz=size(img);ifz=1rslt=edge(img,log);elseifz=3im
19、g1=rgb2ycbcr(img);dx1=edge(img1(:,:,1),log);dx1=(dx1*255);img2(:,:,1)=dx1;img2(:,:,2)=img1(:,:,2);img2(:,:,3)=img1(:,:,3);rslt=ycbcr2rgb(uint8(img2);endimshow(rslt);handles.img=rslt;guidata(hObject,handles);case5T=handles.img;img=I;xyz=size(img);ifz=1rslt=edge(img,canny);elseifz=3img1=rgb2ycbcr(img)
20、;dx1=edge(img1(:,:,1),canny);dx1=(dx1*255);img2(:,:,1)=dx1;img2(:,:,2)=img1(:,:,2);img2(:,:,3)=img1(:,:,3);rslt=ycbcr2rgb(uint8(img2);endimshow(rslt);handles.img=rslt;guidata(hObject,handles);elseendg1=handles.img;switchstrcase1T=handles.img;g2=edge(g1,Roberts);imshow(g2);handles.img=g2;guidata(hObj
21、ect,handles);case2T=handles.img;g2=edge(g1,sobel);imshow(g2);handles.img=g2;guidata(hObject,handles);case3T=handles.img;g2=edge(g1,Prewitt);imshow(g2);handles.img=g2;guidata(hObject,handles);case4T=handles.img;g2=edge(g1,log);imshow(g2);handles.img=g2;guidata(hObject,handles);case5T=handles.img;g2=e
22、dge(g1,canny);imshow(g2);handles.img=g2;guidata(hObject,handles);endend%-Executesonselectionchangeinpopupmenu4.functionpopupmenu4_Callback(hObject,eventdata,handles)%hObjecthandletopopupmenu4(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUI
23、DATA)%Hints:contents=cellstr(get(hObject,String)returnspopupmenu4contentsascellarray%contentsget(hObject,Value)returnsselecteditemfrompopupmenu4%-Executesduringobjectcreation,aftersettingallproperties.functionpopupmenu4_CreateFcn(hObject,eventdata,handles)%hObjecthandletopopupmenu4(seeGCBO)%eventdat
24、areserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:popupmenucontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor)set(hObject,BackgroundColor,white
25、);end%-Executesonbuttonpressinpushbutton8.functionpushbutton8_Callback(hObject,eventdata,handles)%翻轉(zhuǎn)%hObjecthandletopushbutton8(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalTstr=get(handles.popupmenu2,value);axes(handles.axes2
26、);I=handles.img;ifnumel(size(I)2switchstrcase1T=handles.img;b=I(:,:,1);c=I(:,:,2);d=I(:,:,3);I1(:,:,1)=fliplr(b);I1(:,:,2)=fliplr(c);I1(:,:,3)=fliplr(d);case2T=handles.img;b=I(:,:,1);c=I(:,:,2);d=I(:,:,3);I1(:,:,1)=flipud(b);I1(:,:,2)=flipud(c);I1(:,:,3)=flipud(d);endimshow(I1);handles.img=I1;guidat
27、a(hObject,handles);elseswitchstrcase1T=handles.img;f=fliplr(I);case2T=handles.img;f=flipud(I);endimshow(f);handles.img=f;guidata(hObject,handles);end%-Executesonbuttonpressinpushbutton9.functionpushbutton9_Callback(hObject,eventdata,handles)%旋轉(zhuǎn)%hObjecthandletopushbutton9(seeGCBO)%eventdatareserved-t
28、obedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalTT=handles.img;str=get(handles.popupmenu3,value);axes(handles.axes2);prompt=請輸入旋轉(zhuǎn)角度:;defans=0;p=inputdlg(prompt,input,1,defans);p1=str2num(p1);switchstrcase1p1=-p1;case2p1=p1;endf=imrotate(handles.img,p1,bilin
29、ear,crop);imshow(f);handles.img=f;guidata(hObject,handles);%-Executesonselectionchangeinpopupmenu1.functionpopupmenu2_Callback(hObject,eventdata,handles)%hObjecthandletopopupmenu1(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:
30、contents=cellstr(get(hObject,String)returnspopupmenu1contentsascellarray%contentsget(hObject,Value)returnsselecteditemfrompopupmenu1%-Executesduringobjectcreation,aftersettingallproperties.functionpopupmenu2_CreateFcn(hObject,eventdata,handles)%hObjecthandletopopupmenu1(seeGCBO)%eventdatareserved-to
31、bedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:popupmenucontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor)set(hObject,BackgroundColor,white);end%-Execu
32、tesonselectionchangeinpopupmenu3.functionpopupmenu3_Callback(hObject,eventdata,handles)%hObjecthandletopopupmenu3(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:contents=cellstr(get(hObject,String)returnspopupmenu3contentsascel
33、larray%contentsget(hObject,Value)returnsselecteditemfrompopupmenu3%-Executesduringobjectcreation,aftersettingallproperties.functionpopupmenu3_CreateFcn(hObject,eventdata,handles)%hObjecthandletopopupmenu3(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesempty-handlesnotcreatedun
34、tilafterallCreateFcnscalled%Hint:popupmenucontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor)set(hObject,BackgroundColor,white);end%-Executesonbuttonpressinpushbutton6.functionpushbutton6_Callback(hObject
35、,eventdata,handles)%亮度調(diào)節(jié)%hObjecthandletopushbutton6(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalTaxes(handles.axes2);T=handles.img;prompt=調(diào)整倍數(shù)(0,1:明1,):暗);defans=1;p=inputdlg(prompt,input,1,defans);p1=str2num(p1);y=imadjust(h
36、andles.img,p1);%亮度調(diào)節(jié)imshow(y);handles.img=y;guidata(hObject,handles);%-Executesonbuttonpressinpushbutton7.functionpushbutton7_Callback(hObject,eventdata,handles)%對比度調(diào)節(jié)按鈕%hObjecthandletopushbutton7(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(s
37、eeGUIDATA)globalTstr=get(handles.popupmenu1,value);axes(handles.axes2);T=handles.img;prompt=請輸入?yún)?shù):;defans=1;p=inputdlg(prompt,input,1,defans);p1=str2num(p1);switchstrcase1f=immultiply(handles.img,p1);imshow(f);handles.img=f;guidata(hObject,handles);case2f=imdivide(handles.img,p1);imshow(f);handles.i
38、mg=f;guidata(hObject,handles);end%-Executesonselectionchangeinpopupmenu1.functionpopupmenu1_Callback(hObject,eventdata,handles)%hObjecthandletopopupmenu1(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Hints:contents=cellstr(get(hObje
39、ct,String)returnspopupmenu1contentsascellarray%contentsget(hObject,Value)returnsselecteditemfrompopupmenu1%-Executesduringobjectcreation,aftersettingallproperties.functionpopupmenu1_CreateFcn(hObject,eventdata,handles)%hObjecthandletopopupmenu1(seeGCBO)%eventdatareserved-tobedefinedinafutureversiono
40、fMATLAB%handlesempty-handlesnotcreateduntilafterallCreateFcnscalled%Hint:popupmenucontrolsusuallyhaveawhitebackgroundonWindows.%SeeISPCandCOMPUTER.ifispc&isequal(get(hObject,BackgroundColor),get(0,defaultUicontrolBackgroundColor)set(hObject,BackgroundColor,white);end%-Executesonbuttonpressinpushbutt
41、on4.functionpushbutton4_Callback(hObject,eventdata,handles)%撤消%hObjecthandletopushbutton4(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalThandles.img=T;axes(handles.axes2);imshow(T);guidata(hObject,handles);%-Executesonbuttonpre
42、ssinpushbutton5.functionpushbutton5_Callback(hObject,eventdata,handles)%還原%hObjecthandletopushbutton5(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalSy=imread(S);axes(handles.axes2);imshow(y);handles.img=y;guidata(hObject,handle
43、s);%-Executesonbuttonpressinpushbutton1.functionpushbutton1_Callback(hObject,eventdata,handles)%圖像轉(zhuǎn)化為灰度圖像%hObjecthandletopushbutton1(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)globalT%設(shè)計一個全局變量T,保存初始圖像路徑,以便之后的撤銷操作axes(handles.axes2);T=
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 買賣種子合同范本
- 農(nóng)業(yè)委托種植合同范本
- 體育新城租房合同范本
- 剩余瓷磚售賣合同范本
- 人工包給勞務(wù)公司合同范本
- 協(xié)助出口退稅合同范本
- 農(nóng)資經(jīng)營聘用合同范本
- 3人共同合作合同范本
- lng承運合同范本
- 醫(yī)保專員勞動合同范本
- 小老鼠找朋友 演示文稿
- 2023年青島職業(yè)技術(shù)學(xué)院高職單招(英語)試題庫含答案解析
- 2023年蘇州衛(wèi)生職業(yè)技術(shù)學(xué)院高職單招(數(shù)學(xué))試題庫含答案解析
- GB/T 37864-2019生物樣本庫質(zhì)量和能力通用要求
- 中國國防:新中國國防建設(shè)成就【2】
- 慢性病建檔表系列
- GB 19641-2015食品安全國家標準食用植物油料
- 科室會專用-元治-鹽酸貝尼地平-產(chǎn)品介紹
- 英語四六級翻譯技巧課件
- 讀后續(xù)寫(2022新高考I卷)講解課件 高三英語寫作專項
- 馬工程西方經(jīng)濟學(xué)(第二版)教學(xué)課件-1
評論
0/150
提交評論