function varargout = DIPGUI(varargin)
% DIPGUI MATLAB code for DIPGUI.fig
% DIPGUI, by itself, creates a new DIPGUI or raises the existing
% singleton*.
%
% H = DIPGUI returns the handle to a new DIPGUI or the handle to
% the existing singleton*.
%
% DIPGUI('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DIPGUI.M with the given input arguments.
%
% DIPGUI('Property','Value',...) creates a new DIPGUI or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before DIPGUI_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to DIPGUI_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help DIPGUI
% Last Modified by GUIDE v2.5 30-Nov-2018 12:21:38
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @DIPGUI_OpeningFcn, ...
'gui_OutputFcn', @DIPGUI_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before DIPGUI is made visible.
function DIPGUI_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to DIPGUI (see VARARGIN)
% Choose default command line output for DIPGUI
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes DIPGUI wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = DIPGUI_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in getpic.
function getpic_Callback(hObject, eventdata, handles)
% hObject handle to getpic (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global I
[filename,pathname]=...
uigetfile({'*.*';'*.bmp';'*.tif';'*.png'},'select picture'); %选择图片路径
str=[pathname filename]; %合成路径+文件名
I=imread(str);
axes(handles.yuantu); %使用第一个axes
imshow(I); %显示图片
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in savepic.
function savepic_Callback(hObject, eventdata, handles)
% hObject handle to savepic (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[FileName,PathName] = uiputfile({'*.jpg','JPEG(*.jpg)';...
'*.bmp','Bitmap(*.bmp)';...
'*.gif','GIF(*.gif)';...
'*.*', 'All Files (*.*)'},...
'Save Picture','Untitled');
if FileName==0
return;
else
h=getframe(handles.chulihou);
imwrite(h.cdata,[PathName,FileName]);
end
% --- Executes on button press in radiobutton1.
function radiobutton1_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton1 (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 radiobutton1
% --- Executes on button press in radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton2 (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 radiobutton2
% --- Executes on button press in radiobutton3.
function radiobutton3_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton3 (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 radiobutton3
% --- Executes on button press in radiobutton4.
function radiobutton4_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton4 (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 radiobutton4
% --- Executes on button press in radiobutton5.
function radiobutton5_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton5 (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 radiobutton5
% --- Executes during object creation, after setting all properties.
function uibuttongroup2_CreateFcn(hObject, eventdata, handles)
% hObject handle to uibuttongroup2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes when selected object is changed in uibuttongroup2.
function uibuttongroup2_SelectionChangedFcn(hObject, eventdata, handles)
% hObject handle to the selected object in uibuttongroup2
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global I
global BW %定义全局变量
str=get(hObject,'string'); %拿到所选按钮的名称
axes(handles.chulihou); %使用第二个axes
switch str %选择语句
case'Initial' %点击原图按钮
imshow(I); %显示原图
case'roberts算子' %点击Roberts边缘检测按钮
I_gray=rgb2gray(I);
BW=edge( I_gray,'roberts');
imshow(BW);
case'sobel算子' %点击Sobel边缘检测按钮
I_gray=rgb2gray(I);
BW=edge(I_gray,'sobel');
imshow(BW);
case'prewitt算子' %点击Prewitt边缘检测按钮
I_gray=rgb2gray(I);
BW=edge(I_gray,'prewitt');
imshow(BW);
case'log算子' %点击Log边缘检测按钮
I_gray=rgb2gray(I);
BW=edge(I_gray,'log');
imshow(BW);
case'canny算子' %点击Canny边缘检测按钮
I_gray=rgb2gray(I);
BW=edge(I_gray,'canny');
imshow(BW);
end;
% --- Executes on slider movement.
function zuixiaozhibanjing0_Callback(hObject, eventdata, handles)
% hObject handle to zuixiaozhibanjing0 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to de