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,117评论 0 2
  • NAME dnsmasq - A lightweight DHCP and caching DNS server....
    ximitc阅读 2,936评论 0 0
  • Lua 5.1 参考手册 by Roberto Ierusalimschy, Luiz Henrique de F...
    苏黎九歌阅读 13,937评论 0 38
  • Pathname lookup in Linux. This write-up is based on three...
    朔飞阅读 701评论 0 0
  • 又在时间节点前,这一周恰好安排在厦门培训。出发前出了点小意外,那就是预算打少了(哭)。记下几个要点,一是行程单...
    陈拯007阅读 145评论 0 0