PERTURB M-file for perturb.fig PERTURB, by itself, creates a new PERTURB or raises the existing singleton*. H = PERTURB returns the handle to a new PERTURB or the handle to the existing singleton*. PERTURB('CALLBACK',hObject,eventData,handles,...) calls the local function named PERTURB in PERTURB.M with the given input arguments. PERTURB('Property','Value',...) creates a new PERTURB or raises the existing singleton*. Starting from the left, property value pairs are applied to the GUI before perturb_OpeningFunction gets called. An unrecognized property name or invalid value makes property application stop. All inputs are passed to perturb_OpeningFcn via varargin. *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one instance to run (singleton)". Code construction assisted by GUIDE GENERAL Omitted. INPUT/S - OUTPUT/S - PENDING WORK - KNOWN BUG/S - COMMENT/S - RELATED FUNCTION/S ABOUT -Created: February 12th, 2004 -Last update: -Revision: 0.0.9 -Author: R. S. Schestowitz, University of Manchester ==============================================================
0001 function varargout = perturb(varargin) 0002 % PERTURB M-file for perturb.fig 0003 % PERTURB, by itself, creates a new PERTURB or raises the existing 0004 % singleton*. 0005 % 0006 % H = PERTURB returns the handle to a new PERTURB or the handle to 0007 % the existing singleton*. 0008 % 0009 % PERTURB('CALLBACK',hObject,eventData,handles,...) calls the local 0010 % function named PERTURB in PERTURB.M with the given input arguments. 0011 % 0012 % PERTURB('Property','Value',...) creates a new PERTURB or raises the 0013 % existing singleton*. Starting from the left, property value pairs are 0014 % applied to the GUI before perturb_OpeningFunction gets called. An 0015 % unrecognized property name or invalid value makes property application 0016 % stop. All inputs are passed to perturb_OpeningFcn via varargin. 0017 % 0018 % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one 0019 % instance to run (singleton)". 0020 % 0021 % Code construction assisted by GUIDE 0022 % 0023 % GENERAL 0024 % 0025 % Omitted. 0026 % 0027 % INPUT/S 0028 % 0029 % - 0030 % 0031 % 0032 % OUTPUT/S 0033 % 0034 % - 0035 % 0036 % PENDING WORK 0037 % 0038 % - 0039 % 0040 % KNOWN BUG/S 0041 % 0042 % - 0043 % 0044 % COMMENT/S 0045 % 0046 % - 0047 % 0048 % RELATED FUNCTION/S 0049 % 0050 % 0051 % 0052 % ABOUT 0053 % 0054 % -Created: February 12th, 2004 0055 % -Last update: 0056 % -Revision: 0.0.9 0057 % -Author: R. S. Schestowitz, University of Manchester 0058 % ============================================================== 0059 0060 % Edit the above text to modify the response to help_button register 0061 0062 % Last Modified by GUIDE v2.5 11-Mar-2004 15:26:19 0063 0064 % Begin initialization code - DO NOT EDIT 0065 gui_Singleton = 1; 0066 gui_State = struct('gui_Name', mfilename, ... 0067 'gui_Singleton', gui_Singleton, ... 0068 'gui_OpeningFcn', @perturb_OpeningFcn, ... 0069 'gui_OutputFcn', @perturb_OutputFcn, ... 0070 'gui_LayoutFcn', [] , ... 0071 'gui_Callback', []); 0072 if nargin & isstr(varargin{1}) 0073 gui_State.gui_Callback = str2func(varargin{1}); 0074 end 0075 0076 if nargout 0077 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); 0078 else 0079 gui_mainfcn(gui_State, varargin{:}); 0080 end 0081 % End initialization code - DO NOT EDIT 0082 0083 % --- Executes just before register is made visible. 0084 function perturb_OpeningFcn(hObject, eventdata, handles, varargin) 0085 % This function has no output args, see OutputFcn. 0086 % hObject handle to figure 0087 % eventdata reserved - to be defined in a future version of MATLAB 0088 % handles structure with handles and user data (see GUIDATA) 0089 % varargin command line arguments to register (see VARARGIN) 0090 0091 % Choose default command line output for register 0092 handles.output = hObject; 0093 0094 % Update handles structure 0095 guidata(hObject, handles); 0096 0097 if strcmp(get(hObject,'Visible'),'off') 0098 initialize_gui(hObject, handles); 0099 end 0100 0101 % UIWAIT makes register pause for user response (see UIRESUME) 0102 % uiwait(handles.Advanced_window); 0103 0104 0105 % --- Outputs from this function are returned to the command line. 0106 function varargout = perturb_OutputFcn(hObject, eventdata, handles) 0107 % varargout cell array for returning output args (see VARARGOUT); 0108 % hObject handle to figure 0109 % eventdata reserved - to be defined in a future version of MATLAB 0110 % handles structure with handles and user data (see GUIDATA) 0111 0112 % Get default command line output from handles structure 0113 varargout{1} = handles.output; 0114 0115 0116 0117 function initialize_gui(fig_handle, handles) 0118 0119 set(handles.offset, 'String', getappdata(0, 'perturbation_offset')); 0120 set(handles.offset_slider, 'Value', str2num(get(handles.offset, 'String'))); 0121 0122 set(handles.perturbation_method, 'String', getappdata(0, 'perturbation_method')); 0123 0124 background = imread('background.jpg'); 0125 0126 axes(handles.background); 0127 axis off; 0128 imshow(background,[0,255]); 0129 0130 % --- Executes on button press in ok_botton. 0131 function ok_botton_Callback(hObject, eventdata, handles) 0132 % hObject handle to ok_botton (see GCBO) 0133 % eventdata reserved - to be defined in a future version of MATLAB 0134 % handles structure with handles and user data (see GUIDATA) 0135 0136 0137 setappdata(0, 'perturbation_method', get(handles.perturbation_method, 'String')); 0138 setappdata(0, 'perturbation_offset', get(handles.offset, 'String')); 0139 0140 0141 close; 0142 0143 0144 0145 % --- Executes on button press in cancel_button. 0146 function cancel_button_Callback(hObject, eventdata, handles) 0147 % hObject handle to cancel_button (see GCBO) 0148 % eventdata reserved - to be defined in a future version of MATLAB 0149 % handles structure with handles and user data (see GUIDATA) 0150 close; 0151 0152 % --- Executes on button press in apply_button. 0153 function apply_button_Callback(hObject, eventdata, handles) 0154 % hObject handle to apply_button (see GCBO) 0155 % eventdata reserved - to be defined in a future version of MATLAB 0156 % handles structure with handles and user data (see GUIDATA) 0157 setappdata(0, 'perturbation_method', get(handles.perturbation_method, 'String')); 0158 setappdata(0, 'perturbation_offset', get(handles.offset, 'String')); 0159 0160 0161 0162 % --- Executes during object creation, after setting all properties. 0163 function perturbation_method_menu_CreateFcn(hObject, eventdata, handles) 0164 % hObject handle to perturbation_method_menu (see GCBO) 0165 % eventdata reserved - to be defined in a future version of MATLAB 0166 % handles empty - handles not created until after all CreateFcns called 0167 0168 % Hint: popupmenu controls usually have a white background on Windows. 0169 % See ISPC and COMPUTER. 0170 if ispc 0171 set(hObject,'BackgroundColor','white'); 0172 else 0173 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0174 end 0175 0176 0177 % --- Executes on selection change in perturbation_method_menu. 0178 function perturbation_method_menu_Callback(hObject, eventdata, handles) 0179 % hObject handle to perturbation_method_menu (see GCBO) 0180 % eventdata reserved - to be defined in a future version of MATLAB 0181 % handles structure with handles and user data (see GUIDATA) 0182 0183 % Hints: contents = get(hObject,'String') returns perturbation_method_menu contents as cell array 0184 % contents{get(hObject,'Value')} returns selected item from perturbation_method_menu 0185 contents = get(hObject,'String'); 0186 0187 if (strcmp(contents{get(hObject,'Value')},'CPS Warps')), 0188 set(handles.perturbation_method, 'String', 'CPS warp'); 0189 elseif (strcmp(contents{get(hObject,'Value')},'Random Noise')), 0190 set(handles.perturbation_method, 'String', 'random noise'); 0191 else 0192 error('Wrong values passed from perturbation method menu. Internal error.'); 0193 end 0194 0195 % --- Executes during object creation, after setting all properties. 0196 function offset_slider_CreateFcn(hObject, eventdata, handles) 0197 % hObject handle to offset_slider (see GCBO) 0198 % eventdata reserved - to be defined in a future version of MATLAB 0199 % handles empty - handles not created until after all CreateFcns called 0200 0201 % Hint: slider controls usually have a light gray background, change 0202 % 'usewhitebg' to 0 to use default. See ISPC and COMPUTER. 0203 usewhitebg = 1; 0204 if usewhitebg 0205 set(hObject,'BackgroundColor',[.9 .9 .9]); 0206 else 0207 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor')); 0208 end 0209 0210 0211 % --- Executes on slider movement. 0212 function offset_slider_Callback(hObject, eventdata, handles) 0213 % hObject handle to offset_slider (see GCBO) 0214 % eventdata reserved - to be defined in a future version of MATLAB 0215 % handles structure with handles and user data (see GUIDATA) 0216 0217 % Hints: get(hObject,'Value') returns position of slider 0218 % get(hObject,'Min') and get(hObject,'Max') to determine range of slider 0219 0220 set(handles.offset, 'String', num2str(ceil(get(handles.offset_slider, 'Value')))); 0221 0222 0223 % --- Executes on button press in disable_perturbation. 0224 function disable_perturbation_Callback(hObject, eventdata, handles) 0225 % hObject handle to disable_perturbation (see GCBO) 0226 % eventdata reserved - to be defined in a future version of MATLAB 0227 % handles structure with handles and user data (see GUIDATA) 0228 0229 set(handles.offset, 'String', '0'); 0230 set(handles.offset_slider, 'Value', 0); 0231