1、matlab毕业编程谷速软件动态轮廓的实施和测试平台的GUIfunction varargout = ActiveCountorsGUI(varargin)% ACTIVECOUNTORSGUI M-file for ActiveCountorsGUI.fig% ACTIVECOUNTORSGUI, by itself, creates a new ACTIVECOUNTORSGUI or raises the existing% singleton*.% H = ACTIVECOUNTORSGUI returns the handle to a new ACTIVECOUNTORSGUI o
2、r the handle to% the existing singleton*.% ACTIVECOUNTORSGUI(CALLBACK,hObject,eventData,handles,.) calls the local% function named CALLBACK in ACTIVECOUNTORSGUI.M with the given input arguments.% ACTIVECOUNTORSGUI(Property,Value,.) creates a new ACTIVECOUNTORSGUI or raises the% existing singleton*.
3、Starting from the left, property value pairs are% applied to the GUI before ActiveCountorsGUI_OpeningFunction gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to ActiveCountorsGUI_OpeningFcn via varargin.% *See GUI Options on GUIDEs
4、 Tools menu. Choose GUI allows only one% instance to run (singleton).% See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above NoiseLambdaText to modify the response to help ActiveCountorsGUI% Last Modified by GUIDE v2.5 28-Jun-2011 11:26:19% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui
5、_State = struct(gui_Name, mfilename, . gui_Singleton, gui_Singleton, . gui_OpeningFcn, ActiveCountorsGUI_OpeningFcn, . gui_OutputFcn, ActiveCountorsGUI_OutputFcn, . gui_LayoutFcn, , . gui_Callback, );if nargin & ischar(varargin1) gui_State.gui_Callback = str2func(varargin1);endif nargout varargout1:
6、nargout = gui_mainfcn(gui_State, varargin:);else gui_mainfcn(gui_State, varargin:);end% End initialization code - DO NOT EDIT% - Executes just before ActiveCountorsGUI is made visible.function ActiveCountorsGUI_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see
7、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 ActiveCountorsGUI (see VARARGIN)% Choose default command line output for ActiveCountorsGUIhandles.out
8、put = hObject;% subplot(Position,0.29,0.12,0.79,0.79);X=zeros(300,250,3);X(:,:,2)=200;imshow(uint8(X),Parent,handles.Axes);txt_hndl=zeros(1,2);txt_hndl(1)=text(20,146,Welcome to our GUI!,. ,1. Choose image file for segmentation, using Load Image File button.,. ,2. Choose noise model parameters in ,
9、Noise Model panel.,. ,3. Choose the Gaussian blur filter Sigma value in , Blur denoise panel.,. ,4. Choose the color space and colr element in , Color space panel.,. ,5. Choose the contour based segmentation algorithm , to apply and set desired algorithm parameters.,. ,6. Choose your display setting
10、s in the, Display Menu panel.,. ,7. Choose refresh rate of displayed images, and save rate of saved images.,. ,8. Choose output path for saved images during, algorithm application (default - current directory).,. ,9. Finally, press Run below, and enjoy the magic.,. FontSize,12); txt_hndl(2)=text(50,
11、308,copyright Nikolay S. & Alex B.,FontSize,10,FontAngle,italic,Color,r); set(txt_hndl,Units,Normalized);set(txt_hndl,FontUnits,Normalized);% Update handles structureguidata(hObject, handles);% UIWAIT makes ActiveCountorsGUI wait for user response (see UIRESUME)% uiwait(handles.GUIfig);% - Outputs f
12、rom this function are returned to the command line.function varargout = ActiveCountorsGUI_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 stru
13、cture with handles and user data (see GUIDATA)% Get default command line output from handles structurevarargout1 = handles.output;% - Executes during object creation, after setting all properties.function GUIfig_CreateFcn(hObject, eventdata, handles)% hObject handle to GUIfig (see GCBO)% eventdata r
14、eserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% - Executes on button press in ShowContour.clc;clear all;warning off;fprintf(%snn,Active Contours GUI started.); % - Executes on selection change in popupmenu2.function popupm
15、enu2_Callback(hObject, eventdata, handles)% hObject handle to popupmenu2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: contents = get(hObject,String) returns popupmenu2 contents as cell array% contents
16、get(hObject,Value) returns selected item from popupmenu2% - Executes during object creation, after setting all properties.function popupmenu2_CreateFcn(hObject, eventdata, handles)% hObject handle to popupmenu2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles emp
17、ty - handles not created until after all CreateFcns called% Hint: popupmenu controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);end% - Executes during obj
18、ect creation, after setting all properties.function OutDir_CreateFcn(hObject, eventdata, handles)% hObject handle to OutDir (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns calledhandles=guidata(hObject);dire
19、ctory_name=cd; %default value is current directoryhandles.OutDirPath=directory_name;guidata(hObject,handles);% - Executes on button press in OutDir.function OutDir_Callback(hObject, eventdata, handles)% hObject handle to OutDir (see GCBO)% eventdata reserved - to be defined in a future version of MA
20、TLAB% handles structure with handles and user data (see GUIDATA)handles=guidata(hObject);directory_name = uigetdir;handles.OutDirPath=directory_name;guidata(hObject,handles);% - Executes on button press in LoadFileButton.function LoadFileButton_Callback(hObject, eventdata, handles) % hObject handle
21、to LoadFileButton (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)handles=guidata(hObject);FilterSpec=*.jpg;*.jpeg;*.gif;*.bmp;*.png;*.tiff;*.tif,Image Files (*.jpg;*.jpeg;*.gif;*.bmp;*.png;*.tiff;*.tif); DialogT
22、itle=Select image file; FileName,PathName = uigetfile(FilterSpec,DialogTitle); if (isequal(FileName,0) disp(File could not be loaded); return; endhandles.ImageFileAddr=PathName,FileName;guidata(hObject,handles);handles.ImageData=add_noise2image(hObject);set(handles.AlgParamsPanel,handles.AlgTypePane
23、l,handles.NoiseModelPanel,. handles.DispMenuPanel,handles.RunPanel,handles.ColorSpacePanel,. handles.BlurUipanel,Visible,on); % for each new image, demand a new mask definitionhandles.UserMask=;set(handles.UserDefineMaskButton,String,Define Mask);guidata(hObject,handles);function MiuAlgEdit_Callback
24、(hObject, eventdata, handles)% hObject handle to MiuAlgEdit (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,String) returns contents of MiuAlgEdit as NoiseLambdaText% str2num(get(hObject,Stri
25、ng) returns contents of MiuAlgEdit as a doublehandles=guidata(hObject);set(hObject,Value,str2num(get(hObject,String); % set value property equal to string numerical value propertyguidata(hObject,handles);% - Executes during object creation, after setting all properties.function MiuAlgEdit_CreateFcn(
26、hObject, eventdata, handles)% hObject handle to MiuAlgEdit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if is
27、pc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);endfunction NuAlgEdit_Callback(hObject, eventdata, handles)% hObject handle to NuAlgEdit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structur
28、e with handles and user data (see GUIDATA)% Hints: get(hObject,String) returns contents of NuAlgEdit as NoiseLambdaText% str2num(get(hObject,String) returns contents of NuAlgEdit as a doublehandles=guidata(hObject);set(hObject,Value,str2num(get(hObject,String); % set value property equal to string n
29、umerical value propertyguidata(hObject,handles);% - Executes during object creation, after setting all properties.function NuAlgEdit_CreateFcn(hObject, eventdata, handles)% hObject handle to NuAlgEdit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handl
30、es not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc & isequal(get(hObject,BackgroundColor), get(0,defaultUicontrolBackgroundColor) set(hObject,BackgroundColor,white);endfunction DeltaTAlgEdit_Callback(hObject, eventdata, handles)% hObject handle to DeltaTAlgEdit (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,String) returns contents of DeltaTAlgEdit as NoiseLambdaText% str2num(get(hObject