matlab_GUI_2 radiobutton
2015-11-27 09:29
429 查看
<span style="font-family: Arial, Helvetica, sans-serif;">添加按钮 作用:选择图片并且可以退出</span>
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global im
%选择图片路径
[filename,pathname] = ...
uigetfile(['*.jpg'],'选择图片');
%合成路径
str=[pathname filename];
%读取图片
im=imread(str);
%使用第一个axes
axes(handles.axes1);
%显示图片
<pre><span style="font-size:18px;">imshow</span>(im);
function uipanel1_SelectionChangeFcn(hObject, eventdata, handles)
% hObject handle to the selected object in uipanel1
% 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 selected
% NewValue: handle of the currently selected object
% handles structure with handles and user data (see GUIDATA)
%在此函数中通常会使用 switch case
global im %使用全局变量im
str=get(hObject,'string');%拿到所选择的按钮的名称
axes(handles.axes1);%从这里开始所有的作图在这个画图板里作图
switch str
case '原图'
imshow(im);
case 'sobel'
BW = edge(rgb2gray(im),'sobel');%func1:rgb转化为灰色图片 然后边缘检测
imshow(BW);
case 'prewitt'
BW = edge(rgb2gray(im),'prewitt');
imshow(BW);
case 'canny'
BW = edge(rgb2gray(im),'canny');
imshow(BW);
end;
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global im
%选择图片路径
[filename,pathname] = ...
uigetfile(['*.jpg'],'选择图片');
%合成路径
str=[pathname filename];
%读取图片
im=imread(str);
%使用第一个axes
axes(handles.axes1);
%显示图片
<pre><span style="font-size:18px;">imshow</span>(im);
function uipanel1_SelectionChangeFcn(hObject, eventdata, handles)
% hObject handle to the selected object in uipanel1
% 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 selected
% NewValue: handle of the currently selected object
% handles structure with handles and user data (see GUIDATA)
%在此函数中通常会使用 switch case
global im %使用全局变量im
str=get(hObject,'string');%拿到所选择的按钮的名称
axes(handles.axes1);%从这里开始所有的作图在这个画图板里作图
switch str
case '原图'
imshow(im);
case 'sobel'
BW = edge(rgb2gray(im),'sobel');%func1:rgb转化为灰色图片 然后边缘检测
imshow(BW);
case 'prewitt'
BW = edge(rgb2gray(im),'prewitt');
imshow(BW);
case 'canny'
BW = edge(rgb2gray(im),'canny');
imshow(BW);
end;
相关文章推荐
- matlab学习笔记(十四)---形态学应用
- bpnn——MATLAB工具箱--newff
- matlab的符号计算
- 验证码识别 matlab
- matlab-mode函数
- bpnn——matlab工具箱-归一化函数 premnmx、tramnmx、postmnmx、mapminmax
- matlab 使用SVM 对鸢尾鼠植物2分类
- matlab学习笔记(十三)---基于对象的操作
- matlab 2010a mex -setup vs 2010找不到的问题
- Matlab中统计矩阵中相同元素的个数的方法
- MatLab2012b/MatLab2013b 分类器大全(svm,knn,随机森林等)
- matlab矩阵分解
- matlab中矩阵的左除右除
- Matlab中的randperm和randsample函数用法总结
- matlab_Gui_1
- 用Matlab GUI设计四则运算
- 一个C编写的机遇matlab的聚类算法
- Fmincon in Matlab 2014a
- opencv、matlab、halcon双目标定汇总
- 第一次博客一些小收获