0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 function varargout = gui_main(varargin)
0015 gui_Singleton = 1;
0016 gui_State = struct('gui_Name', mfilename, ...
0017 'gui_Singleton', gui_Singleton, ...
0018 'gui_OpeningFcn', @gui_main_OpeningFcn, ...
0019 'gui_OutputFcn', @gui_main_OutputFcn, ...
0020 'gui_LayoutFcn', [] , ...
0021 'gui_Callback', []);
0022 if nargin && ischar(varargin{1})
0023 gui_State.gui_Callback = str2func(varargin{1});
0024 end
0025
0026 if nargout
0027 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0028 else
0029 gui_mainfcn(gui_State, varargin{:});
0030 end
0031 end
0032
0033
0034
0035
0036 function gui_main_OpeningFcn(hObject, eventdata, handles, varargin)
0037 handles.output = hObject;
0038 guidata(hObject, handles);
0039
0040
0041 global UserSettings;
0042 UserSettings.dataset = readInput('input/synthesized.mat');
0043 name=fieldnames(UserSettings.dataset);
0044 name=name{1};
0045 UserSettings.dataset = UserSettings.dataset.(name);
0046
0047 for i = 1:size(UserSettings.dataset,2)
0048 UserSettings.dataset(:,i) = mat2gray(UserSettings.dataset(:,i));
0049 end
0050
0051
0052 UserSettings.subcoords= 4;
0053 UserSettings.angle = 1;
0054 UserSettings.distance = 1;
0055 UserSettings.alpha_c = 0.99;
0056
0057
0058 set(handles.sliderAngle, 'Value', UserSettings.angle);
0059 UserSettings.numSteps = 11;
0060 set(handles.sliderAngle, 'Min', 1);
0061 set(handles.sliderAngle, 'Max', UserSettings.numSteps);
0062 set(handles.sliderAngle, 'SliderStep', [1/(UserSettings.numSteps-1) , 1/(UserSettings.numSteps-1) ]);
0063 set(handles.sliderDistance, 'Value', UserSettings.distance);
0064 set(handles.sliderDistance, 'Min', 1);
0065 set(handles.sliderDistance, 'Max', UserSettings.numSteps);
0066 set(handles.sliderDistance, 'SliderStep', [1/(UserSettings.numSteps-1) , 1/(UserSettings.numSteps-1) ]);
0067 set(handles.sliderStraight, 'Value', UserSettings.alpha_c);
0068 set(handles.sliderStraight, 'Min', 0);
0069 set(handles.sliderStraight, 'Max', 1);
0070
0071 guidata(hObject, handles);
0072
0073 updateOutput(hObject, handles);
0074 end
0075
0076
0077
0078
0079 function updateOutput(hObject, handles)
0080
0081 global UserSettings;
0082 UserSettings.angle = get(handles.sliderAngle, 'Value');
0083 UserSettings.distance = get(handles.sliderDistance, 'Value');
0084 UserSettings.alpha_c = get(handles.sliderStraight, 'Value');
0085
0086
0087 try
0088 [subM, valM]=main(UserSettings.dataset, UserSettings.subcoords, UserSettings.angle, UserSettings.distance, UserSettings.alpha_c);
0089 catch err
0090 fprintf(2,[getReport(err) '\n']);
0091 end
0092
0093
0094 axes(handles.axesColor);
0095 cla;
0096 plotSubs(UserSettings.dataset, subM);
0097
0098
0099 axes(handles.axesResult);
0100 cla;
0101 plotBezier(UserSettings.dataset, valM);
0102
0103
0104 set(handles.txtAngle, 'String', num2str(UserSettings.angle));
0105 set(handles.txtDistance, 'String', num2str(UserSettings.distance));
0106 set(handles.txtStraight, 'String', num2str(UserSettings.alpha_c));
0107 set(handles.sliderDistance, 'Min', 1);
0108 set(handles.sliderDistance, 'Max', UserSettings.numSteps);
0109 set(handles.sliderDistance, 'SliderStep', [1/(UserSettings.numSteps-1) , 1/(UserSettings.numSteps-1) ]);
0110 set(handles.sliderAngle, 'Min', 1);
0111 set(handles.sliderAngle, 'Max', UserSettings.numSteps);
0112 set(handles.sliderAngle, 'SliderStep', [1/(UserSettings.numSteps-1) , 1/(UserSettings.numSteps-1) ]);
0113
0114 guidata(hObject, handles);
0115 end
0116
0117 function sliderAngle_Callback(hObject, eventdata, handles)
0118 val=round(hObject.Value);
0119 hObject.Value=val;
0120 updateOutput(hObject, handles);
0121 end
0122
0123 function sliderDistance_Callback(hObject, eventdata, handles)
0124 global UserSettings;
0125 prev=UserSettings.distance;
0126 val=round(hObject.Value);
0127 if (mod(val,2)==0)
0128 if(val>prev)
0129 hObject.Value=val+1;
0130 else
0131 hObject.Value=val-1;
0132 end
0133 else
0134 hObject.Value=val;
0135 end
0136 updateOutput(hObject, handles);
0137 end
0138
0139 function sliderStraight_Callback(hObject, eventdata, handles)
0140 updateOutput(hObject, handles);
0141 end
0142
0143
0144
0145
0146
0147
0148
0149 function btnDataset_Callback(hObject, eventdata, handles)
0150 global UserSettings;
0151 cpy=UserSettings.dataset;
0152
0153 try
0154 data = uigetfile({'*.mat'},'Dataset auswählen');
0155 UserSettings.dataset=load(['input/' char(data)]);
0156 name=fieldnames(UserSettings.dataset);
0157 name=name{1};
0158 UserSettings.dataset = UserSettings.dataset.(name);
0159
0160 for i = 1:size(UserSettings.dataset,2)
0161 UserSettings.dataset(:,i) = mat2gray(UserSettings.dataset(:,i));
0162 end
0163 catch err
0164 UserSettings.dataset=cpy;
0165 fprintf(2,[getReport(err) '\n']);
0166 end
0167
0168 UserSettings.angle=1;
0169 UserSettings.distance=1;
0170 UserSettings.alpha_c=0.75;
0171
0172
0173 set(handles.sliderAngle, 'Value', UserSettings.angle);
0174 set(handles.sliderDistance, 'Value', UserSettings.distance);
0175 set(handles.sliderStraight, 'Value', UserSettings.alpha_c);
0176
0177 updateOutput(hObject, handles);
0178 end
0179
0180 function varargout = gui_main_OutputFcn(hObject, eventdata, handles)
0181 varargout{1} = handles.output;
0182 end