matlab實(shí)現(xiàn)數(shù)字圖像處理Photoshop小程序_第1頁(yè)
matlab實(shí)現(xiàn)數(shù)字圖像處理Photoshop小程序_第2頁(yè)
matlab實(shí)現(xiàn)數(shù)字圖像處理Photoshop小程序_第3頁(yè)
matlab實(shí)現(xiàn)數(shù)字圖像處理Photoshop小程序_第4頁(yè)
matlab實(shí)現(xiàn)數(shù)字圖像處理Photoshop小程序_第5頁(yè)
已閱讀5頁(yè),還剩19頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、實(shí) 驗(yàn) 報(bào) 告 課程名稱 數(shù)字圖像處理 分院 班 組 姓名 學(xué)號(hào) 日期 年 月 日 程序所實(shí)現(xiàn)的功能:1)圖像的讀取和保存。 2)設(shè)計(jì)圖形用戶界面,讓用戶能夠?qū)D像進(jìn)行任意的亮度和對(duì)比度變化調(diào)整,顯示和對(duì)比變換前后的圖像。 3)設(shè)計(jì)圖形用戶界面,讓用戶能夠用鼠標(biāo)選取圖像感興趣區(qū)域,顯示和保存該選擇區(qū)域。 4)圖像直方圖均衡,要求顯示直方圖統(tǒng)計(jì),比較直方圖均衡后的效果。 5)能對(duì)圖像加入各種噪聲,并通過(guò)幾種濾波算法實(shí)現(xiàn)去噪并顯示結(jié)果。6) 底片效果7)邊緣信息8)圖像反轉(zhuǎn)程序?qū)崿F(xiàn)的亮點(diǎn)設(shè)計(jì)簡(jiǎn)潔的菜單欄以及常用工具的快捷圖標(biāo)也可以使用對(duì)應(yīng)功能的快捷鍵,包括新建,打開(CTRL+O),保存(CTRL

2、+S);菜單欄里更是增加了操作撤銷與圖像還原的操作,可是實(shí)現(xiàn)返回操作??傮w設(shè)計(jì)圖1軟件的總體設(shè)計(jì)界面布局如上圖所示,主要分為 2 個(gè)部分:顯示區(qū)域與操作區(qū)域。 顯示區(qū)域:顯示載入原圖,以及通過(guò)處理后的圖像。 操作區(qū)域:通過(guò)功能鍵實(shí)現(xiàn)對(duì)圖像的各種處理,為了實(shí)現(xiàn)界面的簡(jiǎn)潔,大部分的功能放到了 菜單欄里。 在截圖中可見,左部為一系列功能按鍵如“對(duì)比度調(diào)節(jié)”、“亮度調(diào)節(jié)”、“裁剪”等等 ;界面正中部分為圖片顯示部分,界面中下方為系列功能切換選擇組。 菜單欄的設(shè)計(jì)展示圖2具體設(shè)計(jì) 現(xiàn)介紹各個(gè)功能模塊的功能與實(shí)現(xiàn)。4.1 菜單欄的設(shè)計(jì)。 通過(guò) Menu Editor 創(chuàng)建如下菜單,通過(guò)以下菜單來(lái)控制顯示或

3、隱藏功能按鍵圖3以“文件”菜單中“打開”為例說(shuō)明實(shí)現(xiàn)用戶界面功能鍵“打開”的顯示與隱藏。 實(shí)現(xiàn)該功能通過(guò)添加callback就可以了: 通過(guò)Toolbar Editor可以添加快捷圖標(biāo),如下圖:圖4 圖像的讀取和保存。 (1) 利用“文件”菜單中的“打開”、“ 保存”或者使用菜單欄下的快捷圖標(biāo)分別實(shí)現(xiàn)圖片的讀取與保存。 圖5如果沒(méi)有選中文件還會(huì)提示圖6(2)圖像保存。 利用“uiputfile”、“imwrite”函數(shù)實(shí)現(xiàn)圖像文件的保存。 圖7同樣按下去下取消鍵會(huì)提示:圖8(3)程序的退出。 你可以在菜單欄使用退出鍵,或者在主界面右下角有關(guān)閉按鈕就可以退出程序。對(duì)圖像進(jìn)行任意的亮度和對(duì)比度變化

4、調(diào)整,顯示和對(duì)比變換前后的圖像。 按下亮度調(diào)節(jié)按鈕會(huì)彈出輸入框,輸入調(diào)節(jié)倍數(shù),如下圖:圖9(注意:這里的倍數(shù)是相反的調(diào)節(jié),你會(huì)發(fā)現(xiàn)輸入0.1后亮度會(huì)變亮)調(diào)節(jié)后的圖像如下:圖11對(duì)比度的調(diào)節(jié)跟亮度一樣,調(diào)節(jié)后的圖像如下:圖12 44 用鼠標(biāo)選取圖像感興趣區(qū)域,顯示和保存該選擇區(qū)域。按下裁剪按鈕把鼠標(biāo)移動(dòng)到處理后的圖像窗口,光標(biāo)會(huì)變成十字形狀,拖動(dòng)光標(biāo)會(huì)出現(xiàn)方框,如下:圖13雙擊方框里的圖像就完成了裁剪。4.5 圖像轉(zhuǎn)化為灰度圖像。由于在matlab中較多的圖像處理函數(shù)支持對(duì)灰度圖像進(jìn)行處理,故對(duì)圖像進(jìn)行灰度轉(zhuǎn)化十分必要??衫胷gb2gray(X)函數(shù)對(duì)其他圖像進(jìn)行灰度圖像的轉(zhuǎn)化。 轉(zhuǎn)化實(shí)例如

5、下: 圖144.8 加入各種噪聲,并通過(guò)幾種濾波算法實(shí)現(xiàn)去噪。(1) 加入噪聲。通過(guò)imnoise(I,type,parameters)來(lái)加入各種噪聲。加入椒鹽噪聲 圖15加入噪聲后:圖16高斯噪聲:乘性噪聲:圖17這幾種噪聲我加入的參數(shù)都是0.02,效果逐漸加深。濾波:選擇線性濾波的結(jié)果如下,可以看出濾去了大部分噪聲,(注意:這幾個(gè)濾波不可以疊加使用,否則出現(xiàn)白屏)圖17翻轉(zhuǎn):左右翻轉(zhuǎn)圖18上下翻轉(zhuǎn):圖19工具底片效果:圖20邊緣信息:圖215、結(jié)果分析 軟件測(cè)試基本成功,課題所要求的功能均能較好實(shí)現(xiàn)。但一些功能只支持灰度圖像的處理。 其中值得一提的是在濾波處理中的低通濾波與高通濾波的效果。

6、由于一般圖像中含有較多的低頻信息成分高頻成分較少,通過(guò)低通濾波后,噪聲以及高頻成分被濾除,圖像雖有少量失真,略顯模糊,但尚可辨識(shí)。但若是通過(guò)高通濾波后,大量的有效低頻信息被濾除,圖像嚴(yán)重失真,不可辨識(shí)。 源碼:function duibidu_SelectionChangeFcn(hObject, eventdata, handles)% hObject handle to the selected object in duibidu % eventdata structure with the following fields (see UIBUTTONGROUP)%EventName: s

7、tring 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

8、 case增強(qiáng) T=getimage; prompt=輸入?yún)?shù):; 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=輸入?yún)?shù):; defans=1; p=inputdlg(prompt,input,1,defans); p1=str2double(p1); f=imdivide(handles.img,

9、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

10、data (see GUIDATA)global T axes(handles.axes2); T=getimage; prompt=調(diào)整倍數(shù); defans=1; p=inputdlg(prompt,input,1,defans); p1=str2double(p1); y=imadjust(handles.img, , ,p1); %亮度調(diào)節(jié) imshow(y); handles.img=y; guidata(hObject,handles);% -function wenjian_Callback(hObject, eventdata, handles)% hObject handle

11、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 MATL

12、AB% handles structure with handles and user data (see GUIDATA)filename,pathname=uigetfile(*.jpg;*.bmp;*.tif;*.*,載入圖像);if isequal(filename,0)|isequal(pathname,0) errordlg(沒(méi)有選中文件,出錯(cuò)); return;else file=pathname,filename; global S %設(shè)置一個(gè)全局變量S,保存初始圖像路徑,以便之后的還原操作? S=file; x=imread(file); set(handles.axes1,

13、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

14、 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 %

15、 -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

16、)% 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

17、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 s

18、trstr=get(hObject,string); axes(handles.axes2); switch str case增強(qiáng) T=getimage; prompt=輸入?yún)?shù):; 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=輸入?yún)?shù):; defans=1; p=inputdlg(prompt,i

19、nput,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

20、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 v

21、ersion 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)% hOb

22、ject 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 selec

23、ted 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

24、 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=數(shù)日椒鹽噪聲參數(shù)1:; defans=0.02; p=inputdlg(prompt,input,

25、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); h

26、andles.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

27、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 selec

28、ted%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

29、=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 自適應(yīng)濾波 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

30、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 MATL

31、AB% 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)

32、; y1=handles.img; f=double(y1); % 數(shù)據(jù)類型轉(zhuǎn)換,matlab不支持圖像的無(wú)符號(hào)整型的計(jì)算 g=fft2(f); % 傅里葉變換 g=fftshift(g); % 轉(zhuǎn)換數(shù)據(jù)矩陣 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); % 計(jì)算低通濾波器傳遞函數(shù) result(i,j)=h*g(i,j); end end result=ifft

33、shift(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

34、(handles.axes2); x=(handles.img); f=double(x); % 數(shù)據(jù)類型轉(zhuǎn)換 k=fft2(f); % 傅里葉變換 g=fftshift(k); % 轉(zhuǎn)換數(shù)據(jù)矩陣 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); % 計(jì)算高通濾波器傳遞函數(shù) if d=d0 h=0; else h=1; end result(i,j)=h*g(i,j); end end result=ifftshift(result); y2=i

35、fft2(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);

36、%撤銷 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 %還

37、原 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 follo

38、wing 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 左右翻轉(zhuǎn) T=handles.img; f=fliplr(handles.img); imshow(f)

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論