1、數位影像處理實習-GUI基本介面介紹指導教授:沈岱範 老師投影片製作:許進宗參考書籍:Matlab程式設計與應用 張智星著開啟GUI開啟GUI點選Axes產生兩個axes框框點選兩次Axes視窗以顯示其屬性視窗修改Tag屬性點選Push Button產生Push Button框框顯示屬性視窗並修改屬性顯示屬性視窗並修改屬性顯示屬性視窗並修改屬性顯示屬性視窗並修改屬性顯示屬性視窗並修改屬性點選Edit Text點選Static Text修改Edit Text屬性修改Static Text屬性點選Menu Editor修改屬性建立一個子列修改屬性存檔存檔後會顯示出M-file檔主程式程式碼clc;
2、image=zeros(3,3);axes(handles.pixel);imshow(uint8(image);handles.output=hObject;handles.data=;handles.i=0;handles.fv=0;handles.bv=0;back1副程式程式碼if handles.bv=250 handles.bv=handles.bv+5;set(handles.edit1,string,handles.bv);image(1:3,1:3)=handles.bv;image(2,2)=handles.fv;axes(handles.pixel);imshow(uin
3、t8(image);guidata(hObject,handles);elseif handles.bv=255 fprintf(The value of background is less than 0.n);else handles.bv=handles.bv+10;set(handles.edit1,string,handles.bv);image(1:3,1:3)=handles.bv;image(2,2)=handles.fv;axes(handles.pixel);imshow(uint8(image);guidata(hObject,handles);endback2副程式程式
4、碼if handles.bv=255 handles.bv=handles.bv-5;set(handles.edit1,string,handles.bv);image(1:3,1:3)=handles.bv;image(2,2)=handles.fv;axes(handles.pixel);imshow(uint8(image);guidata(hObject,handles);elseif handles.bv=0 fprintf(The value of background is less than 0.n);else handles.bv=handles.bv-10;set(han
5、dles.edit1,string,handles.bv);image(1:3,1:3)=handles.bv;image(2,2)=handles.fv;axes(handles.pixel);imshow(uint8(image);guidata(hObject,handles);endfront1副程式程式碼if handles.fv=255 fprintf(The value is lager than 255.n);else handles.fv=handles.fv+1;set(handles.edit2,string,handles.fv);image(1:3,1:3)=hand
6、les.bv;image(2,2)=handles.fv;axes(handles.pixel);imshow(uint8(image);guidata(hObject,handles);endfront2副程式程式碼if handles.fv=0 fprintf(The value of front is less than 0.n);else handles.fv=handles.fv-1;set(handles.edit2,string,handles.fv);image(1:3,1:3)=handles.bv;image(2,2)=handles.fv;axes(handles.pix
7、el);imshow(uint8(image);guidata(hObject,handles);endedit1副程式程式碼handles.bv=round(str2num(get(handles.edit1,string);set(handles.edit1,string,handles.bv);image(1:3,1:3)=handles.bv;image(2,2)=handles.fv;axes(handles.pixel);imshow(uint8(image);guidata(hObject,handles);edit2副程式程式碼handles.fv=round(str2num(
8、get(handles.edit2,string);set(handles.edit2,string,handles.fv);image(1:3,1:3)=handles.bv;image(2,2)=handles.fv;axes(handles.pixel);imshow(uint8(image);guidata(hObject,handles);record副程式程式碼handles.i=handles.i+1;guidata(hObject,handles);handles.data(1,handles.i)=handles.bv;handles.data(2,handles.i)=ha
9、ndles.fv-handles.bv;guidata(hObject,handles);close副程式程式碼close(gcbf);reset副程式程式碼handles.fv=0;handles.bv=0;image(1:3,1:3)=handles.bv;image(2,2)=handles.fv;axes(handles.pixel);imshow(uint8(image);set(handles.edit1,string,int2str(handles.bv)set(handles.edit2,string,int2str(handles.fv)guidata(hObject,handles);plot副程式程式碼axes(handles.show);plot(handles.data(1,:),handles.data(2,:),b:+);title(JND);xlabel(back pixl);ylabel(add pixel);Run結果