Matlab圖像分割算子GUI

雞你太美警告!入門GUI。



讀取圖片按鈕函數;

設置全局變量BW,后來調用非常方便。

function pushbutton1_Callback(hObject, eventdata, handles)

% hObject? ? handle to pushbutton1 (see GCBO)

% eventdata? reserved - to be definedina future version of MATLAB

% handles? ? structure with handles and user data (see GUIDATA)

global BW

global filename

global pathname

[filename,pathname]=uigetfile({'*.jpg';'*.bmp';'*.tif';'*.*'},'載入圖像');

ifisequal(filename,0)|isequal(pathname,0)

errordlg('沒有選中文件','出錯');

return;

else

file=[pathname,filename];

end

BW = imread(file);

axes(handles.axes1);

imshow(BW);

title(date,'color','r');

保存圖片按鈕函數:

function pushbutton5_Callback(hObject, eventdata, handles)

% hObject? ? handle to pushbutton5 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? structure with handles and user data (see GUIDATA)

%global BW

[filename,pathname]=...

? ? uiputfile({'*.tif';'*.jpg';'*.png';'*.bmp'},'save pictrue');

if isequal(filename,0)||isequal(pathname,0)

? ? return

else

? ? str=[pathname filename]

? ? axes(handles.axes2);

? ? im=getimage(handles.axes2);

? ? imwrite(im,str);

end

退出按鈕函數:

function pushbutton6_Callback(hObject, eventdata, handles)

% hObject? ? handle to pushbutton6 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? structure with handles and user data (see GUIDATA)

close(gcf)? %關閉當前Figure窗口句柄

canny算子示例:

function radiobutton20_Callback(hObject, eventdata, handles)

% hObject? ? handle to radiobutton20 (see GCBO)

% eventdata? reserved - to be defined in a future version of MATLAB

% handles? ? structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of radiobutton20

global BW;

global pathname;

global filename;

% axis off? %%關閉坐標軸顯示

str=[pathname filename];

%%打開圖像

im=BW;

%%打開axes1的句柄 進行axes1的操作

axes(handles.axes1);

%%在axes1中顯示 圖像

imshow(im);

%圖像處理部分

I=im2bw(im);

BW1=edge(I,'canny'); %用canny算子進行邊緣檢測

axes(handles.axes2);

imshow(BW1);

彩蛋

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • 轉自 http://www.kylen314.com/archives/412 不顯示坐標刻度: set(gca,...
    天之道天知道閱讀 2,084評論 0 2
  • NAME dnsmasq - A lightweight DHCP and caching DNS server....
    ximitc閱讀 2,906評論 0 0
  • Lua 5.1 參考手冊 by Roberto Ierusalimschy, Luiz Henrique de F...
    蘇黎九歌閱讀 13,877評論 0 38
  • Pathname lookup in Linux. This write-up is based on three...
    朔飛閱讀 685評論 0 0
  • 又在時間節點前,這一周恰好安排在廈門培訓。出發前出了點小意外,那就是預算打少了(哭)。記下幾個要點,一是行程單...
    陳拯007閱讀 133評論 0 0