1 | %'civ_input': function associated with the GUI 'civ_input.fig' to set the input parameters for civ_series |
---|
2 | %------------------------------------------------------------------------ |
---|
3 | % function ParamOut = civ_input(Param) |
---|
4 | % |
---|
5 | % OUPUT: |
---|
6 | % ParamOut: Matlab structure containing the parameters set by the GUI civ_input |
---|
7 | % |
---|
8 | % INPUT: |
---|
9 | % Param: Matlab structure containing the input parameters set by the GUI |
---|
10 | |
---|
11 | %======================================================================= |
---|
12 | % Copyright 2008-2014, LEGI UMR 5519 / CNRS UJF G-INP, Grenoble, France |
---|
13 | % http://www.legi.grenoble-inp.fr |
---|
14 | % Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr |
---|
15 | % |
---|
16 | % This file is part of the toolbox UVMAT. |
---|
17 | % |
---|
18 | % UVMAT is free software; you can redistribute it and/or modify |
---|
19 | % it under the terms of the GNU General Public License as published |
---|
20 | % by the Free Software Foundation; either version 2 of the license, |
---|
21 | % or (at your option) any later version. |
---|
22 | % |
---|
23 | % UVMAT is distributed in the hope that it will be useful, |
---|
24 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
25 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
26 | % GNU General Public License (see LICENSE.txt) for more details. |
---|
27 | %======================================================================= |
---|
28 | |
---|
29 | function varargout = civ_input(varargin) |
---|
30 | |
---|
31 | gui_Singleton = 1; |
---|
32 | gui_State = struct('gui_Name', mfilename, ... |
---|
33 | 'gui_Singleton', gui_Singleton, ... |
---|
34 | 'gui_OpeningFcn', @civ_input_OpeningFcn, ... |
---|
35 | 'gui_OutputFcn', @civ_input_OutputFcn, ... |
---|
36 | 'gui_LayoutFcn', [] , ... |
---|
37 | 'gui_Callback', []); |
---|
38 | |
---|
39 | if nargin && ischar(varargin{1}) && ~isempty(regexp(varargin{1},'_Callback$','once')) |
---|
40 | gui_State.gui_Callback = str2func(varargin{1}); |
---|
41 | end |
---|
42 | |
---|
43 | if nargout |
---|
44 | [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
45 | else |
---|
46 | gui_mainfcn(gui_State, varargin{:}); |
---|
47 | end |
---|
48 | |
---|
49 | % End initialization code - DO NOT EDIT |
---|
50 | |
---|
51 | %------------------------------------------------------------------------ |
---|
52 | % --- Executes just before civ_input is made visible. |
---|
53 | function civ_input_OpeningFcn(hObject, eventdata, handles, Param) |
---|
54 | %------------------------------------------------------------------------ |
---|
55 | % This function has no output args, see OutputFcn. |
---|
56 | |
---|
57 | %% General settings |
---|
58 | handles.output = Param; |
---|
59 | guidata(hObject, handles); % Update handles structure |
---|
60 | set(hObject,'WindowButtonDownFcn',{'mouse_down'}) % allows mouse action with right button (zoom for uicontrol display) |
---|
61 | set(hObject,'WindowKeyPressFcn',{@keyboard_callback,handles})%set keyboard action function |
---|
62 | %set(hObject,'KeyPressFcn',{@KeyPressFcn,handles})%set keyboard action function |
---|
63 | set(handles.ref_i,'KeyPressFcn',{@ref_i_KeyPressFcn,handles})%set keyboard action function |
---|
64 | set(handles.ref_j,'KeyPressFcn',{@ref_i_KeyPressFcn,handles})%set keyboard action function |
---|
65 | %set(hObject,'WindowKeyPressFcn',{'keyboard_callback',handles})%set keyboard action function |
---|
66 | hseries=findobj(allchild(0),'Tag','series');% find the parent GUI 'series' |
---|
67 | hhseries=guidata(hseries); %handles of the elements in 'series' |
---|
68 | SeriesData=get(hseries,'UserData');% info stored in the GUI series |
---|
69 | |
---|
70 | %% set visibility options depending on the calling function (Param.Action.ActionName): |
---|
71 | if strcmp(Param.Action.ActionName,'civ_series')||strcmp(Param.Action.ActionName,'stereo_civ') |
---|
72 | set(handles.num_MaxDiff,'Visible','on') |
---|
73 | set(handles.num_MaxVel,'Visible','on') |
---|
74 | set(handles.title_MaxVel,'Visible','on') |
---|
75 | set(handles.title_MaxDiff,'Visible','on') |
---|
76 | set(handles.num_Nx,'Visible','off') |
---|
77 | set(handles.num_Ny,'Visible','off') |
---|
78 | set(handles.title_Nx,'Visible','off') |
---|
79 | set(handles.title_Ny,'Visible','off') |
---|
80 | set(handles.num_CorrSmooth,'Style','popupmenu') |
---|
81 | set(handles.num_CorrSmooth,'Value',1) |
---|
82 | set(handles.num_CorrSmooth,'String',{'1';'2'}) |
---|
83 | set(handles.CheckThreshold,'Visible','on') |
---|
84 | set(handles.CheckDeformation,'Value',0)% desactivate (work in progress) |
---|
85 | %set(handles.CheckDecimal,'Value',0)% desactivate (work in progress) |
---|
86 | end |
---|
87 | switch Param.Action.ActionName |
---|
88 | case 'stereo_civ' |
---|
89 | set(handles.ListCompareMode,'Visible','off') |
---|
90 | set(handles.PairIndices,'Visible','off') |
---|
91 | case 'civ_series' |
---|
92 | set(handles.ListCompareMode,'Visible','on') |
---|
93 | set(handles.PairIndices,'Visible','on') |
---|
94 | end |
---|
95 | |
---|
96 | %% input file info |
---|
97 | NomTypeInput=Param.InputTable{1,4}; |
---|
98 | FileType='image';%fdefault |
---|
99 | FileInfo=[]; |
---|
100 | if isfield(SeriesData,'FileType')&&isfield(SeriesData,'FileInfo') |
---|
101 | FileType=SeriesData.FileType{1};%type of the first input file series |
---|
102 | FileInfo=SeriesData.FileInfo{1};% info on the first input file series |
---|
103 | else |
---|
104 | set(hhseries.REFRESH,'BackgroundColor',[1 0 1])% indicate that the file input in series needs to be refreshed |
---|
105 | end |
---|
106 | |
---|
107 | %% case of netcdf file as input, read the processing stage and look for corresponding images |
---|
108 | ind_opening=0;%default |
---|
109 | NomTypeNc=''; |
---|
110 | NomTypeImaA=NomTypeInput; |
---|
111 | iview_image=1;%line # for the input images |
---|
112 | switch FileType |
---|
113 | case {'image','multimage','video','mmreader','netcdf'} |
---|
114 | % NomTypeImaA=NomTypeInput; |
---|
115 | % iview_image=1;%line # for the input images |
---|
116 | case 'civdata' |
---|
117 | if ~strcmp(Param.Action.ActionName,'civ_series') |
---|
118 | msgbox_uvmat('ERROR','bad input data file: open an image or a nc file from civ_series') |
---|
119 | return |
---|
120 | end |
---|
121 | NomTypeNc=NomTypeInput; |
---|
122 | ind_opening=FileInfo.CivStage; |
---|
123 | if isempty(regexp(NomTypeInput,'[ab|AB|-]', 'once')) |
---|
124 | set(handles.ListCompareMode,'Value',2) %mode displacement advised if the nomencalture does not involve index pairs |
---|
125 | else |
---|
126 | set(handles.ListCompareMode,'Value',1) |
---|
127 | end |
---|
128 | [Data,tild,tild,errormsg]=nc2struct(FileInfo.FileName,[]); |
---|
129 | if ~isempty(errormsg) |
---|
130 | msgbox_uvmat('ERROR',['error in netcdf input file: ' errormsg]) |
---|
131 | return |
---|
132 | end |
---|
133 | [PathCiv1_ImageA,Civ1_ImageA,FileExtA]=fileparts(Data.Civ1_ImageA);%look for the source image A |
---|
134 | [PathCiv1_ImageB,Civ1_ImageB,FileExtA]=fileparts(Data.Civ1_ImageB);%look for the source image B |
---|
135 | if isfield(Data,'Civ2_ImageA') |
---|
136 | [PathCiv2_ImageA,Civ2_ImageA,FileExtA]=fileparts(Data.Civ2_ImageA); |
---|
137 | [PathCiv2_ImageB,Civ2_ImageB,FileExtA]=fileparts(Data.Civ2_ImageB); |
---|
138 | end |
---|
139 | if size(Param.InputTable,1)==1 |
---|
140 | series('display_file_name',hhseries,Data.Civ1_ImageA,'append');%append the image series to the input list |
---|
141 | end |
---|
142 | [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaA]=fileparts_uvmat(Data.Civ1_ImageA); |
---|
143 | [RootPath,SubDir,RootFile,i1,i2,j1,j2,FileExt,NomTypeImaB]=fileparts_uvmat(Data.Civ1_ImageB); |
---|
144 | iview_image=2;%line # for the input images |
---|
145 | case 'civxdata'% case of civx data, |
---|
146 | msgbox_uvmat('ERROR','old civX convention, use the GUI civ') |
---|
147 | return |
---|
148 | otherwise |
---|
149 | msgbox_uvmat('ERROR','civ_series needs images, scalar fields in netcdf format, or civ data as input') |
---|
150 | return |
---|
151 | end |
---|
152 | |
---|
153 | %% reinitialise menus |
---|
154 | set(handles.ListPairMode,'Value',1) |
---|
155 | set(handles.ListPairMode,'String',{''}) |
---|
156 | set(handles.ListPairCiv1,'Value',1) |
---|
157 | set(handles.ListPairCiv1,'String',{''}) |
---|
158 | set(handles.ListPairCiv2,'Value',1) |
---|
159 | set(handles.ListPairCiv2,'String',{''}) |
---|
160 | |
---|
161 | %% prepare the GUI with input parameters |
---|
162 | % |
---|
163 | set(handles.ref_i,'String',num2str(Param.IndexRange.first_i)) |
---|
164 | if isfield(Param.IndexRange,'first_j') |
---|
165 | set(handles.ref_j,'String',num2str(Param.IndexRange.first_j)) |
---|
166 | end |
---|
167 | set(handles.ConfigSource,'String','\default') |
---|
168 | |
---|
169 | %% set the menus of image pairs and default selection for civ_input %%%%%%%%%%%%%%%%%%% |
---|
170 | |
---|
171 | %% display the min and max indices for the whole file series |
---|
172 | if isempty(Param.IndexRange.MaxIndex_i)|| isempty(Param.IndexRange.MinIndex_i) |
---|
173 | msgbox_uvmat('ERROR','REFRESH the input files in the GUI series') |
---|
174 | return |
---|
175 | end |
---|
176 | MaxIndex_i=Param.IndexRange.MaxIndex_i(iview_image); |
---|
177 | MinIndex_i=Param.IndexRange.MinIndex_i(iview_image); |
---|
178 | MaxIndex_j=1;%default |
---|
179 | MinIndex_j=1; |
---|
180 | if isfield(Param.IndexRange,'MaxIndex_j')&&isfield(Param.IndexRange,'MinIndex_j')... |
---|
181 | && numel(Param.IndexRange.MaxIndex_j')>=iview_image &&numel(Param.IndexRange.MinIndex_j')>=iview_image |
---|
182 | MaxIndex_j=Param.IndexRange.MaxIndex_j(iview_image); |
---|
183 | MinIndex_j=Param.IndexRange.MinIndex_j(iview_image); |
---|
184 | end |
---|
185 | %update the bounds if possible |
---|
186 | if isfield(SeriesData,'i1_series')&&numel(SeriesData.i1_series)>=iview_image |
---|
187 | if size(SeriesData.i1_series{iview_image},2)==2 && min(min(SeriesData.i1_series{iview_image}(:,1,:)))==0 |
---|
188 | MinIndex_j=1;% index j set to 1 by default |
---|
189 | MaxIndex_j=1; |
---|
190 | MinIndex_i=find(SeriesData.i1_series{iview_image}(1,2,:), 1 )-1;% min ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index) |
---|
191 | MaxIndex_i=find(SeriesData.i1_series{iview_image}(1,2,:),1,'last' )-1;%max ref index i detected in the series (corresponding to the last non-zero value of i1_series) |
---|
192 | else |
---|
193 | ref_i=squeeze(max(SeriesData.i1_series{iview_image}(1,:,:),[],2));% select ref_j index for each ref_i |
---|
194 | ref_j=squeeze(max(SeriesData.j1_series{iview_image}(1,:,:),[],3));% select ref_i index for each ref_j |
---|
195 | MinIndex_i=min(find(ref_i))-1; |
---|
196 | MaxIndex_i=max(find(ref_i))-1; |
---|
197 | MaxIndex_j=max(find(ref_j))-1; |
---|
198 | MinIndex_j=min(find(ref_j))-1; |
---|
199 | end |
---|
200 | end |
---|
201 | if ~isfield(Param.IndexRange,'first_j')||isequal(MaxIndex_j,MinIndex_j)% no possibility of j pairs |
---|
202 | set(handles.ListPairMode,'Value',1) |
---|
203 | set(handles.ListPairMode,'String',{'series(Di)'}) |
---|
204 | elseif MaxIndex_i==1 && MaxIndex_j>1% simple series in j |
---|
205 | set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)'}) |
---|
206 | if MaxIndex_j <= 10 |
---|
207 | set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large |
---|
208 | end |
---|
209 | else |
---|
210 | set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice |
---|
211 | if strcmp(NomTypeNc,'_1-2_1') |
---|
212 | set(handles.ListPairMode,'Value',3)% advise 'series(Di)' |
---|
213 | elseif MaxIndex_j <= 10 |
---|
214 | set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large |
---|
215 | end |
---|
216 | end |
---|
217 | |
---|
218 | %% transfer the time from the GUI series, or use file index by default |
---|
219 | time=[]; |
---|
220 | TimeUnit='frame'; %default |
---|
221 | CoordUnit='';%default |
---|
222 | pxcm_search=1; |
---|
223 | if isfield(SeriesData,'Time') && ~isempty(SeriesData.Time{1}) |
---|
224 | time=SeriesData.Time{1}; |
---|
225 | end |
---|
226 | if isfield(Param.IndexRange,'TimeUnit')&&~isempty(Param.IndexRange.TimeUnit) |
---|
227 | TimeUnit=Param.IndexRange.TimeUnit; |
---|
228 | end |
---|
229 | % if isfield(SeriesData,'TimeSource') |
---|
230 | % set(handles.TimeSource,'String',SeriesData.TimeSource) |
---|
231 | % end |
---|
232 | if isfield(SeriesData,'GeometryCalib') |
---|
233 | tsai=SeriesData.GeometryCalib; |
---|
234 | if isfield(tsai,'fx_fy') |
---|
235 | pxcm_search=max(tsai.fx_fy(1),tsai.fx_fy(2));%pixels:cm estimated for the search range |
---|
236 | end |
---|
237 | if isfield(tsai,'CoordUnit') |
---|
238 | CoordUnit=tsai.CoordUnit; |
---|
239 | end |
---|
240 | end |
---|
241 | |
---|
242 | %% timing display |
---|
243 | %show the reference image edit box if relevant (not needed for movies or in the absence of time information |
---|
244 | if numel(time)>=2 % if there are at least two time values to define dt |
---|
245 | if size(time,1)<MaxIndex_i; |
---|
246 | msgbox_uvmat('WARNING','maximum i index restricted by the timing of the xml file'); |
---|
247 | elseif size(time,2)<MaxIndex_j |
---|
248 | msgbox_uvmat('WARNING','maximum j index restricted by the timing of the xml file'); |
---|
249 | end |
---|
250 | MaxIndex_i=min(size(time,1),MaxIndex_i);%possibly adjust the max index according to time data |
---|
251 | MaxIndex_j=min(size(time,2),MaxIndex_j); |
---|
252 | set(handles.TimeSource,'String',Param.IndexRange.TimeSource); |
---|
253 | else |
---|
254 | set(handles.TimeSource,'String',''); %xml file not used for timing |
---|
255 | TimeUnit='frame'; |
---|
256 | time=ones(MaxIndex_j-MinIndex_j+1,1)*(MinIndex_i:MaxIndex_i); |
---|
257 | time=time+0.001*(MinIndex_j:MaxIndex_j)'*ones(1,MaxIndex_i-MinIndex_i+1); |
---|
258 | end |
---|
259 | CivInputData.Time=time; |
---|
260 | CivInputData.NomTypeIma=NomTypeImaA; |
---|
261 | set(handles.civ_input,'UserData',CivInputData) |
---|
262 | set(handles.dt_unit,'String',['dt in m' TimeUnit]);%display dt in unit 10-3 of the time (e.g ms) |
---|
263 | set(handles.TimeUnit,'String',TimeUnit); |
---|
264 | %set(handles.CoordUnit,'String',CoordUnit) |
---|
265 | set(handles.SearchRange,'UserData', pxcm_search); |
---|
266 | |
---|
267 | % indicate the min and max indices i and j on the GUI |
---|
268 | set(handles.MinIndex_i,'String',num2str(MinIndex_i)) |
---|
269 | set(handles.MaxIndex_i,'String',num2str(MaxIndex_i)) |
---|
270 | set(handles.MinIndex_j,'String',num2str(MinIndex_j)) |
---|
271 | set(handles.MaxIndex_j,'String',num2str(MaxIndex_j)) |
---|
272 | |
---|
273 | |
---|
274 | %% set the civ_input options, depending on the input file content if a nc file has been opened |
---|
275 | ListOptions={'CheckCiv1', 'CheckFix1' 'CheckPatch1', 'CheckCiv2', 'CheckFix2', 'CheckPatch2'}; |
---|
276 | checkbox=zeros(size(ListOptions));%default |
---|
277 | checkrefresh=0; |
---|
278 | if ind_opening==0 %case of image opening, start with Civ1 |
---|
279 | for index=1:numel(ListOptions) |
---|
280 | checkbox(index)=get(handles.(ListOptions{index}),'Value'); |
---|
281 | end |
---|
282 | index_max=find(checkbox, 1, 'last' ); |
---|
283 | if isempty(index_max),index_max=1;end |
---|
284 | for index=1:index_max |
---|
285 | set(handles.(ListOptions{index}),'Value',1)% select all operations starting from CIV1 |
---|
286 | end |
---|
287 | else %case of netcdf file opening, start with the stage read in the file if the input file is being refreshed |
---|
288 | if isequal(get(hhseries.REFRESH,'BackgroundColor'),[1 1 0]) &&... |
---|
289 | ~(isfield(Param,'ActionInput') && isfield(Param.ActionInput,'ConfigSource')) |
---|
290 | % answer=msgbox_uvmat('INPUT_Y-N',['import the civ parameters from the netcdf file']); |
---|
291 | % if strcmp(answer,'Yes') |
---|
292 | for index = 1:min(ind_opening,5) |
---|
293 | set(handles.(ListOptions{index}),'value',0) |
---|
294 | fill_civ_input(Data,handles); %fill civ_input with the parameters retrieved from an input Civ file |
---|
295 | end |
---|
296 | set(handles.ConfigSource,'String',FileInfo.FileName); |
---|
297 | set(handles.(ListOptions{min(ind_opening+1,6)}),'value',1) |
---|
298 | for index = ind_opening+2:6 |
---|
299 | set(handles.(ListOptions{index}),'value',0) |
---|
300 | end |
---|
301 | checkrefresh=1; |
---|
302 | % end |
---|
303 | end |
---|
304 | if ind_opening>=3 |
---|
305 | set(handles.CheckCiv3,'Visible','on')% make visible the switch 'iterate/repet' for Civ2. |
---|
306 | else |
---|
307 | set(handles.CheckCiv3,'Visible','off') |
---|
308 | end |
---|
309 | end |
---|
310 | |
---|
311 | %% introduce the stored Civ parameters if available (from previous input or ImportConfig in series) |
---|
312 | if ~checkrefresh && isfield(Param,'ActionInput')&& strcmp(Param.ActionInput.Program,Param.Action.ActionName)% the program fits with the stored data |
---|
313 | fill_GUI(Param.ActionInput,hObject);%fill the GUI with the parameters retrieved from the input Param |
---|
314 | hcheckgrid=findobj(handles.civ_input,'Tag','CheckGrid'); |
---|
315 | for ilist=1:numel(hcheckgrid) |
---|
316 | if get(hcheckgrid(ilist),'Value')% if a grid is used, do not show Dx and Dy for an automatic grid |
---|
317 | hparent=get(hcheckgrid(ilist),'parent');%handles of the parent panel |
---|
318 | hchildren=get(hparent,'children'); |
---|
319 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
320 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
321 | handle_title_dx=findobj(hchildren,'tag','title_Dx'); |
---|
322 | handle_title_dy=findobj(hchildren,'tag','title_Dy'); |
---|
323 | set(handle_dx,'Visible','off'); |
---|
324 | set(handle_dy,'Visible','off'); |
---|
325 | set(handle_title_dy,'Visible','off'); |
---|
326 | set(handle_title_dx,'Visible','off'); |
---|
327 | end |
---|
328 | end |
---|
329 | end |
---|
330 | |
---|
331 | %% set the reference indices from the input file indices |
---|
332 | if ~(isfield(Param,'ActionInput') && isfield(Param.ActionInput,'ConfigSource')) |
---|
333 | update_CivOptions(handles,ind_opening)% fill the menu of possible pairs |
---|
334 | end |
---|
335 | |
---|
336 | %% list the possible index pairs, depending on the option set in ListPairMode |
---|
337 | ListPairMode_Callback([], [], handles) |
---|
338 | ListPairCiv1_Callback(hObject, eventdata, handles) |
---|
339 | |
---|
340 | %% set the GUI to modal: wait for OK to close |
---|
341 | set(handles.civ_input,'WindowStyle','modal')% Make the GUI modal |
---|
342 | drawnow |
---|
343 | uiwait(handles.civ_input);% wait for OK action to end the function |
---|
344 | |
---|
345 | |
---|
346 | %------------------------------------------------------------------------ |
---|
347 | % --- Outputs from this function are returned to the command line. |
---|
348 | function varargout = civ_input_OutputFcn(hObject, eventdata, handles) |
---|
349 | %------------------------------------------------------------------------ |
---|
350 | % Get default command line output from handles structure |
---|
351 | varargout{1}=[];% default output when civ_input is canceled (no 'OK') |
---|
352 | if ~isempty(handles) |
---|
353 | varargout{1} = handles.output; |
---|
354 | delete(handles.civ_input) |
---|
355 | end |
---|
356 | |
---|
357 | % --- Executes when user attempts to close get_field. |
---|
358 | function civ_input_CloseRequestFcn(hObject, eventdata, handles) |
---|
359 | if isequal(get(handles.get_field, 'waitstatus'), 'waiting') |
---|
360 | % The GUI is still in UIWAIT, us UIRESUME |
---|
361 | uiresume(handles.civ_input); |
---|
362 | else |
---|
363 | % The GUI is no longer waiting, just close it |
---|
364 | delete(handles.civ_input); |
---|
365 | end |
---|
366 | |
---|
367 | %------------------------------------------------------------------------ |
---|
368 | % --- Executes on button press in SetDefaultParam. |
---|
369 | %------------------------------------------------------------------------ |
---|
370 | function SetDefaultParam_Callback(hObject, eventdata, handles) |
---|
371 | |
---|
372 | Param.ConfigSource='\default'; |
---|
373 | |
---|
374 | %% Civ1 parameters |
---|
375 | Param.Civ1.CorrBoxSize=[25 25]; |
---|
376 | Param.Civ1.SearchBoxSize=[55 55]; |
---|
377 | Param.Civ1.SearchBoxShift=[0 0]; |
---|
378 | Param.Civ1.CorrSmooth=1; |
---|
379 | Param.Civ1.Dx=20; |
---|
380 | Param.Civ1.Dy=20; |
---|
381 | Param.Civ1.CheckGrid=0; |
---|
382 | Param.Civ1.CheckMask=0; |
---|
383 | Param.Civ1.CheckThreshold=0; |
---|
384 | Param.Civ1.TestCiv1=0; |
---|
385 | |
---|
386 | %% Fix1 parameters |
---|
387 | Param.Fix1.CheckFmin2=1; |
---|
388 | Param.Fix1.CheckF3=1; |
---|
389 | Param.Fix1.MinCorr=0.2000; |
---|
390 | |
---|
391 | %% Patch1 parameters |
---|
392 | Param.Patch1.FieldSmooth=10; |
---|
393 | Param.Patch1.MaxDiff=1.5000; |
---|
394 | Param.Patch1.SubDomainSize=1000; |
---|
395 | Param.Patch1.TestPatch1=0; |
---|
396 | |
---|
397 | %% Civ2 parameters |
---|
398 | Param.Civ2.CorrBoxSize=[21 21]; |
---|
399 | Param.Civ2.SearchBoxSize=[31 31]; |
---|
400 | Param.Civ2.CorrSmooth=1; |
---|
401 | Param.Civ2.Dx=10; |
---|
402 | Param.Civ2.Dy=10; |
---|
403 | Param.Civ2.CheckGrid=0; |
---|
404 | Param.Civ2.CheckMask=0; |
---|
405 | Param.Civ2.CheckThreshold=0; |
---|
406 | Param.Civ2.TestCiv2=0; |
---|
407 | |
---|
408 | %% Fix2 parameters |
---|
409 | Param.Fix2.CheckFmin2=1; |
---|
410 | Param.Fix2.CheckF4=1; |
---|
411 | Param.Fix2.CheckF3=1; |
---|
412 | Param.Fix2.MinCorr=0.2000; |
---|
413 | |
---|
414 | %% Patch2 parameters |
---|
415 | Param.Patch2.FieldSmooth=2; |
---|
416 | Param.Patch2.MaxDiff=1.5000; |
---|
417 | Param.Patch2.SubDomainSize=1000; |
---|
418 | Param.Patch2.TestPatch2=0; |
---|
419 | |
---|
420 | fill_GUI(Param,handles.civ_input)% fill the elements of the GUI series with the input parameters |
---|
421 | |
---|
422 | % ----------------------------------------------------------------------- |
---|
423 | % ----------------------------------------------------------------------- |
---|
424 | % --- Open the help html file |
---|
425 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
426 | % ----------------------------------------------------------------------- |
---|
427 | web('http://servforge.legi.grenoble-inp.fr/projects/soft-uvmat/wiki/UvmatHelp#Civ') |
---|
428 | |
---|
429 | %------------------------------------------------------------------------ |
---|
430 | % --- Executes on carriage return on the subdir checkciv1 edit window |
---|
431 | function Civ1_ImageB_Callback(hObject, eventdata, handles) |
---|
432 | %------------------------------------------------------------------------ |
---|
433 | SubDir=get(handles.Civ1_ImageB,'String'); |
---|
434 | menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update |
---|
435 | ichoice=find(strcmp(SubDir,menu_str),1); |
---|
436 | if isempty(ichoice) |
---|
437 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
438 | else |
---|
439 | ilist=ichoice; |
---|
440 | end |
---|
441 | set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu |
---|
442 | if get(handles.CheckCiv1,'Value')% if Civ1 is performed |
---|
443 | set(handles.Civ2_ImageA,'String',SubDir);% set by default civ2 directory the same as civ1 |
---|
444 | % set(handles.ListSubdirCiv2,'Value',ilist) |
---|
445 | else % if Civ1 data already exist |
---|
446 | errormsg=find_netcpair_civ(handles,1); %update the list of available index pairs in the new directory |
---|
447 | if ~isempty(errormsg) |
---|
448 | msgbox_uvmat('ERROR',errormsg) |
---|
449 | end |
---|
450 | end |
---|
451 | |
---|
452 | %------------------------------------------------------------------------ |
---|
453 | % --- Executes on carriage return on the SubDir checkciv1 edit window |
---|
454 | function Civ2_ImageA_Callback(hObject, eventdata, handles) |
---|
455 | %------------------------------------------------------------------------ |
---|
456 | SubDir=get(handles.Civ1_ImageB,'String'); |
---|
457 | menu_str=get(handles.ListSubdirCiv2,'String');% read the list of subdirectories for update |
---|
458 | ichoice=find(strcmp(SubDir,menu_str),1); |
---|
459 | if isempty(ichoice) |
---|
460 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
461 | else |
---|
462 | ilist=ichoice; |
---|
463 | end |
---|
464 | set(handles.ListSubdirCiv2,'Value',ilist)% select the selected subdir in the menu |
---|
465 | %update the list of available pairs from netcdf files in the new directory |
---|
466 | if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') |
---|
467 | errormsg=find_netcpair_civ(handles,2); |
---|
468 | if ~isempty(errormsg) |
---|
469 | msgbox_uvmat('ERROR',errormsg) |
---|
470 | end |
---|
471 | end |
---|
472 | |
---|
473 | %------------------------------------------------------------------------ |
---|
474 | % --- Executes on button press in CheckCiv1. |
---|
475 | function CheckCiv1_Callback(hObject, eventdata, handles) |
---|
476 | %------------------------------------------------------------------------ |
---|
477 | update_CivOptions(handles,0) |
---|
478 | |
---|
479 | %------------------------------------------------------------------------ |
---|
480 | % --- Executes on button press in CheckFix1. |
---|
481 | function CheckFix1_Callback(hObject, eventdata, handles) |
---|
482 | %------------------------------------------------------------------------ |
---|
483 | update_CivOptions(handles,0) |
---|
484 | |
---|
485 | %------------------------------------------------------------------------ |
---|
486 | % --- Executes on button press in CheckPatch1. |
---|
487 | function CheckPatch1_Callback(hObject, eventdata, handles) |
---|
488 | %------------------------------------------------------------------------ |
---|
489 | update_CivOptions(handles,0) |
---|
490 | |
---|
491 | %------------------------------------------------------------------------ |
---|
492 | % --- Executes on button press in CheckCiv2. |
---|
493 | function CheckCiv2_Callback(hObject, eventdata, handles) |
---|
494 | %------------------------------------------------------------------------ |
---|
495 | update_CivOptions(handles,0) |
---|
496 | |
---|
497 | %------------------------------------------------------------------------ |
---|
498 | % --- Executes on button press in CheckFix2. |
---|
499 | function CheckFix2_Callback(hObject, eventdata, handles) |
---|
500 | %------------------------------------------------------------------------ |
---|
501 | update_CivOptions(handles,0) |
---|
502 | |
---|
503 | %------------------------------------------------------------------------ |
---|
504 | % --- Executes on button press in CheckPatch2. |
---|
505 | function CheckPatch2_Callback(hObject, eventdata, handles) |
---|
506 | %------------------------------------------------------------------------ |
---|
507 | update_CivOptions(handles,0) |
---|
508 | |
---|
509 | %------------------------------------------------------------------------ |
---|
510 | % --- activated by any checkbox controling the selection of Civ1,Fix1,Patch1,Civ2,Fix2,Patch2 |
---|
511 | function update_CivOptions(handles,opening) |
---|
512 | %------------------------------------------------------------------------ |
---|
513 | if opening>0 |
---|
514 | set(handles.CheckCiv2,'UserData',opening)% store the info on the current status of the civ processing |
---|
515 | end |
---|
516 | checkbox=zeros(1,6); |
---|
517 | checkbox(1)=get(handles.CheckCiv1,'Value'); |
---|
518 | checkbox(2)=get(handles.CheckFix1,'Value'); |
---|
519 | checkbox(3)=get(handles.CheckPatch1,'Value'); |
---|
520 | checkbox(4)=get(handles.CheckCiv2,'Value'); |
---|
521 | checkbox(5)=get(handles.CheckFix2,'Value'); |
---|
522 | checkbox(6)=get(handles.CheckPatch2,'Value'); |
---|
523 | if opening==0 |
---|
524 | errormsg=find_netcpair_civ(handles,1); % select the available netcdf files |
---|
525 | if ~isempty(errormsg) |
---|
526 | msgbox_uvmat('ERROR',errormsg) |
---|
527 | end |
---|
528 | end |
---|
529 | if max(checkbox(4:6))>0% case of civ2 pair choice needed |
---|
530 | set(handles.TitlePairCiv2,'Visible','on') |
---|
531 | set(handles.ListPairCiv2,'Visible','on') |
---|
532 | if ~opening |
---|
533 | errormsg=find_netcpair_civ(handles,2); % select the available netcdf files |
---|
534 | if ~isempty(errormsg) |
---|
535 | msgbox_uvmat('ERROR',errormsg) |
---|
536 | end |
---|
537 | end |
---|
538 | else |
---|
539 | set(handles.ListPairCiv2,'Visible','off') |
---|
540 | end |
---|
541 | if max(checkbox(1:3))==0 && get(handles.CheckCiv2,'UserData')==6,% no operation asked before Civ2 and input file ready for civ3 |
---|
542 | set(handles.CheckCiv3,'Visible','on') |
---|
543 | else |
---|
544 | set(handles.CheckCiv3,'Visible','off') |
---|
545 | end |
---|
546 | |
---|
547 | %% set the visibility of the different panels |
---|
548 | options={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; |
---|
549 | for ilist=1:length(options) |
---|
550 | if checkbox(ilist) |
---|
551 | set(handles.(options{ilist}),'Visible','on') |
---|
552 | else |
---|
553 | set(handles.(options{ilist}),'Visible','off') |
---|
554 | end |
---|
555 | end |
---|
556 | |
---|
557 | %------------------------------------------------------------------------ |
---|
558 | % --- Executes on button press in OK: processing on local computer |
---|
559 | function OK_Callback(hObject, eventdata, handles) |
---|
560 | %------------------------------------------------------------------------ |
---|
561 | |
---|
562 | ActionInput=read_GUI(handles.civ_input);% read the infos on the GUI civ_input |
---|
563 | |
---|
564 | %% correct input inconsistencies |
---|
565 | if isfield(ActionInput,'Civ1') |
---|
566 | checkeven=(mod(ActionInput.Civ1.CorrBoxSize,2)==0); |
---|
567 | ActionInput.Civ1.CorrBoxSize(checkeven)=ActionInput.Civ1.CorrBoxSize(checkeven)+1;% set correlation box sizes to odd values |
---|
568 | ActionInput.Civ1.SearchBoxSize=max(ActionInput.Civ1.SearchBoxSize,ActionInput.Civ1.CorrBoxSize+8);% insure that the search box size is large enough |
---|
569 | checkeven=(mod(ActionInput.Civ1.SearchBoxSize,2)==0); |
---|
570 | ActionInput.Civ1.SearchBoxSize(checkeven)=ActionInput.Civ1.SearchBoxSize(checkeven)+1;% set search box sizes to odd values |
---|
571 | end |
---|
572 | if isfield(ActionInput,'Civ2') |
---|
573 | checkeven=(mod(ActionInput.Civ2.CorrBoxSize,2)==0); |
---|
574 | ActionInput.Civ2.CorrBoxSize(checkeven)=ActionInput.Civ2.CorrBoxSize(checkeven)+1;% set correlation box sizes to odd values |
---|
575 | ActionInput.Civ2.SearchBoxSize=max(ActionInput.Civ2.SearchBoxSize,ActionInput.Civ2.CorrBoxSize+6); |
---|
576 | checkeven=(mod(ActionInput.Civ2.SearchBoxSize,2)==0); |
---|
577 | ActionInput.Civ2.SearchBoxSize(checkeven)=ActionInput.Civ2.SearchBoxSize(checkeven)+1;% set search box sizes to odd values |
---|
578 | end |
---|
579 | |
---|
580 | %% correct mask or grid name for Windows system (replace '\' by '/') |
---|
581 | if isfield(ActionInput,'Civ1') |
---|
582 | if isfield(ActionInput.Civ1,'Mask') |
---|
583 | ActionInput.Civ1.Mask=regexprep(ActionInput.Civ1.Mask,'\','/'); |
---|
584 | end |
---|
585 | if isfield(ActionInput.Civ1,'Grid') |
---|
586 | ActionInput.Civ1.Grid=regexprep(ActionInput.Civ1.Grid,'\','/'); |
---|
587 | end |
---|
588 | end |
---|
589 | if isfield(ActionInput,'Civ2') |
---|
590 | if isfield(ActionInput.Civ2,'Mask') |
---|
591 | ActionInput.Civ2.Mask=regexprep(ActionInput.Civ2.Mask,'\','/'); |
---|
592 | end |
---|
593 | if isfield(ActionInput.Civ2,'Grid') |
---|
594 | ActionInput.Civ2.Grid=regexprep(ActionInput.Civ2.Grid,'\','/'); |
---|
595 | end |
---|
596 | end |
---|
597 | |
---|
598 | %% exit the GUI and close it |
---|
599 | handles.output.ActionInput=ActionInput; |
---|
600 | guidata(hObject, handles);% Update handles structure |
---|
601 | uiresume(handles.civ_input); |
---|
602 | |
---|
603 | |
---|
604 | %------------------------------------------------------------------------ |
---|
605 | % --- Executes on button press in ListCompareMode. |
---|
606 | function ListCompareMode_Callback(hObject, eventdata, handles) |
---|
607 | %------------------------------------------------------------------------ |
---|
608 | ListCompareMode=get(handles.ListCompareMode,'String'); |
---|
609 | option=ListCompareMode{get(handles.ListCompareMode,'Value')}; |
---|
610 | hseries=findobj(allchild(0),'Tag','series'); |
---|
611 | SeriesData=get(hseries,'UserData'); |
---|
612 | check_nc=strcmp(SeriesData.FileType{1},'.nc'); |
---|
613 | ImageType=SeriesData.FileType(2:end); |
---|
614 | if check_nc |
---|
615 | ImageType=SeriesData.FileType(2:end); |
---|
616 | else |
---|
617 | ImageType=SeriesData.FileType; |
---|
618 | end |
---|
619 | hhseries=guidata(hseries); |
---|
620 | InputTable=get(hhseries.InputTable,'Data'); |
---|
621 | OriginIndex='off'; |
---|
622 | PairIndices='off'; |
---|
623 | DoubleInputSeries='off'; |
---|
624 | switch option |
---|
625 | case 'PIV' |
---|
626 | PairIndices='on';% needs to define index pairs for PIV |
---|
627 | |
---|
628 | case 'PIV volume' |
---|
629 | PairIndices='on';% needs to define index pairs for PIV |
---|
630 | set(handles.ListPairMode,'Value',1) |
---|
631 | set(handles.ListPairMode,'String',{'series(Di)'}) |
---|
632 | ListPairMode_Callback(hObject, eventdata, handles) |
---|
633 | case 'displacement' |
---|
634 | OriginIndex='on';%define a frame origin for displacement |
---|
635 | % case 'shift' |
---|
636 | % if numel(ImageType)==1 |
---|
637 | % fileinput=uigetfile_uvmat('pick a second file series for synchronous shift',InputTable{check_nc+1}); |
---|
638 | % if ~isempty(fileinput) |
---|
639 | % series( 'display_file_name',hhseries,fileinput,'append') |
---|
640 | % end |
---|
641 | % |
---|
642 | % |
---|
643 | % end |
---|
644 | end |
---|
645 | set(handles.num_OriginIndex,'Visible',OriginIndex) |
---|
646 | set(handles.OriginIndex_title,'Visible',OriginIndex) |
---|
647 | set(handles.PairIndices,'Visible',PairIndices) |
---|
648 | ListPairMode_Callback(hObject, eventdata, handles) |
---|
649 | |
---|
650 | |
---|
651 | |
---|
652 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
653 | % Callbacks in the uipanel Pair Indices |
---|
654 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
655 | %------------------------------------------------------------------------ |
---|
656 | % --- Executes on button press in ListPairMode. |
---|
657 | function ListPairMode_Callback(hObject, eventdata, handles) |
---|
658 | %------------------------------------------------------------------------ |
---|
659 | compare_list=get(handles.ListCompareMode,'String'); |
---|
660 | val=get(handles.ListCompareMode,'Value'); |
---|
661 | compare=compare_list{val}; |
---|
662 | if strcmp(compare,'displacement')||strcmp(compare,'shift') |
---|
663 | mode='displacement'; |
---|
664 | else |
---|
665 | mode_list=get(handles.ListPairMode,'String'); |
---|
666 | if ischar(mode_list) |
---|
667 | mode_list={mode_list}; |
---|
668 | end |
---|
669 | mode_value=get(handles.ListPairMode,'Value'); |
---|
670 | mode=mode_list{mode_value}; |
---|
671 | end |
---|
672 | % displ_num=[];%default |
---|
673 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
674 | % last_i=str2num(get(handles.last_i,'String')); |
---|
675 | CivInputData=get(handles.civ_input,'UserData'); |
---|
676 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
677 | checkframe=strcmp(TimeUnit,'frame'); |
---|
678 | time=CivInputData.Time; |
---|
679 | siztime=size(CivInputData.Time); |
---|
680 | nbfield=siztime(1)-1; |
---|
681 | nbfield2=siztime(2)-1; |
---|
682 | indchosen=1; %%first pair selected by default |
---|
683 | %displ_num used to define the indices of the civ_input pairs |
---|
684 | % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices |
---|
685 | % are relative to the reference indices ref_i and ref_j respectively. |
---|
686 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
687 | dt=1; |
---|
688 | displ=''; |
---|
689 | index=0; |
---|
690 | numlist_a=[]; |
---|
691 | numlist_B=[]; |
---|
692 | %get all the time intervals in bursts |
---|
693 | displ_dt=1;%default |
---|
694 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
695 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
696 | for numod_b=(numod_a+1):nbfield2 |
---|
697 | index=index+1; |
---|
698 | numlist_a(index)=numod_a; |
---|
699 | numlist_b(index)=numod_b; |
---|
700 | if size(time,2)>1 && ~checkframe |
---|
701 | dt(numod_a,numod_b)=CivInputData.Time(ref_i+1,numod_b+1)-CivInputData.Time(ref_i+1,numod_a+1);%first time interval dt |
---|
702 | displ_dt(index)=dt(numod_a,numod_b); |
---|
703 | else |
---|
704 | displ_dt(index)=1; |
---|
705 | end |
---|
706 | end |
---|
707 | end |
---|
708 | [dtsort,indsort]=sort(displ_dt); |
---|
709 | if ~isempty(numlist_a) |
---|
710 | displ_num(1,:)=numlist_a(indsort); |
---|
711 | displ_num(2,:)=numlist_b(indsort); |
---|
712 | end |
---|
713 | displ_num(3,:)=0; |
---|
714 | displ_num(4,:)=0; |
---|
715 | enable_j(handles, 'off') |
---|
716 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
717 | index=1:200; |
---|
718 | displ_num(1,index)=-floor(index/2); |
---|
719 | displ_num(2,index)=ceil(index/2); |
---|
720 | displ_num(3:4,index)=zeros(2,200); |
---|
721 | enable_j(handles, 'on') |
---|
722 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
723 | % index=1:200; |
---|
724 | % displ_num(1:2,index)=zeros(2,200); |
---|
725 | % displ_num(3,index)=-floor(index/2); |
---|
726 | % displ_num(4,index)=ceil(index/2); |
---|
727 | enable_i(handles, 'on') |
---|
728 | if nbfield2 > 1 |
---|
729 | enable_j(handles, 'on') |
---|
730 | else |
---|
731 | enable_j(handles, 'off') |
---|
732 | end |
---|
733 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
734 | displ_num(1,1)=0; |
---|
735 | displ_num(2,1)=0; |
---|
736 | displ_num(3,1)=0; |
---|
737 | displ_num(4,1)=0; |
---|
738 | if nbfield > 1 || nbfield==0 |
---|
739 | enable_i(handles, 'on') |
---|
740 | else |
---|
741 | enable_j(handles, 'off') |
---|
742 | end |
---|
743 | if nbfield2 > 1 |
---|
744 | enable_j(handles, 'on') |
---|
745 | else |
---|
746 | enable_j(handles, 'off') |
---|
747 | end |
---|
748 | end |
---|
749 | %set(handles.ListPairCiv1,'UserData',displ_num); |
---|
750 | errormsg=find_netcpair_civ( handles,1); |
---|
751 | if ~isempty(errormsg) |
---|
752 | msgbox_uvmat('ERROR',errormsg) |
---|
753 | end |
---|
754 | % find_netcpair_civ2(handles) |
---|
755 | |
---|
756 | function enable_i(handles, state) |
---|
757 | set(handles.itext,'Visible',state) |
---|
758 | % set(handles.MinIndex_i,'Visible',state) |
---|
759 | % set(handles.last_i,'Visible',state) |
---|
760 | % set(handles.incr_i,'Visible',state) |
---|
761 | set(handles.MaxIndex_i,'Visible',state) |
---|
762 | set(handles.ref_i,'Visible',state) |
---|
763 | |
---|
764 | function enable_j(handles, state) |
---|
765 | set(handles.jtext,'Visible',state) |
---|
766 | % set(handles.MinIndex_j,'Visible',state) |
---|
767 | % set(handles.last_j,'Visible',state) |
---|
768 | % set(handles.incr_j,'Visible',state) |
---|
769 | set(handles.MinIndex_j,'Visible',state) |
---|
770 | set(handles.MaxIndex_j,'Visible',state) |
---|
771 | set(handles.ref_j,'Visible',state) |
---|
772 | %hseries=findobj(allchild(0),'Tag','series'); |
---|
773 | %hhseries=guidata(hseries); |
---|
774 | %series('enable_j',hhseries,state); %file input with xml reading in uvmat, show the image in phys coordinates |
---|
775 | |
---|
776 | |
---|
777 | |
---|
778 | %------------------------------------------------------------------------ |
---|
779 | % --- Executes on selection change in ListPairCiv1. |
---|
780 | function ListPairCiv1_Callback(hObject, eventdata, handles) |
---|
781 | %------------------------------------------------------------------------ |
---|
782 | %reproduce by default the chosen pair in the checkciv2 menu |
---|
783 | list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs |
---|
784 | PairString=list_pair{get(handles.ListPairCiv1,'Value')}; |
---|
785 | |
---|
786 | [ind1,ind2]=... |
---|
787 | find_pair_indices(PairString); |
---|
788 | hseries=findobj(allchild(0),'Tag','series'); |
---|
789 | hhseries=guidata(hseries); |
---|
790 | set(hhseries.num_first_j,'String',num2str(ind1)); |
---|
791 | set(hhseries.num_last_j,'String',num2str(ind2)); |
---|
792 | set(hhseries.num_incr_j,'String',num2str(ind2-ind1)); |
---|
793 | set(handles.ListPairCiv2,'Value',get(handles.ListPairCiv1,'Value'))%civ2 selection the same as civ& by default |
---|
794 | |
---|
795 | |
---|
796 | %------------------------------------------------------------------------ |
---|
797 | % --- Executes on selection change in ListPairCiv2. |
---|
798 | function ListPairCiv2_Callback(hObject, eventdata, handles) |
---|
799 | %------------------------------------------------------------------------ |
---|
800 | |
---|
801 | |
---|
802 | %------------------------------------------------------------------------ |
---|
803 | function ref_i_Callback(hObject, eventdata, handles) |
---|
804 | %------------------------------------------------------------------------ |
---|
805 | mode_list=get(handles.ListPairMode,'String'); |
---|
806 | mode_value=get(handles.ListPairMode,'Value'); |
---|
807 | mode=mode_list{mode_value}; |
---|
808 | errormsg=find_netcpair_civ(handles,1);% update the menu of pairs depending on the available netcdf files |
---|
809 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
810 | (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) |
---|
811 | errormsg=find_netcpair_civ( handles,2); |
---|
812 | end |
---|
813 | if isempty(errormsg) |
---|
814 | set(handles.ref_i,'BackgroundColor',[1 1 1]) |
---|
815 | set(handles.ref_j,'BackgroundColor',[1 1 1]) |
---|
816 | else |
---|
817 | msgbox_uvmat('ERROR',errormsg) |
---|
818 | end |
---|
819 | |
---|
820 | function ref_i_KeyPressFcn(hObject, eventdata, handles) |
---|
821 | set(hObject,'BackgroundColor',[1 0 1]) |
---|
822 | |
---|
823 | % %------------------------------------------------------------------------ |
---|
824 | % function ref_j_Callback(hObject, eventdata, handles) |
---|
825 | % %------------------------------------------------------------------------ |
---|
826 | % mode_list=get(handles.ListPairMode,'String'); |
---|
827 | % mode_value=get(handles.ListPairMode,'Value'); |
---|
828 | % mode=mode_list{mode_value}; |
---|
829 | % errormsg=''; |
---|
830 | % if isequal(get(handles.CheckCiv1,'Value'),0)|| isequal(mode,'series(Dj)') |
---|
831 | % errormsg=find_netcpair_civ(handles,1);% update the menu of pairs depending on the available netcdf files |
---|
832 | % end |
---|
833 | % if isequal(mode,'series(Dj)') || ... |
---|
834 | % (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) |
---|
835 | % errormsg=find_netcpair_civ(handles,2); |
---|
836 | % end |
---|
837 | % if ~isempty(errormsg) |
---|
838 | % msgbox_uvmat('ERROR',errormsg) |
---|
839 | % end |
---|
840 | % |
---|
841 | % function ref_j_KeyPressFcn(hObject, eventdata, handles) |
---|
842 | % set(handles.ref_j,'BackgroundColor',[1 0 1]) |
---|
843 | %------------------------------------------------------------------------ |
---|
844 | % determine the menu for checkciv1 pairs depending on existing netcdf file at the middle of |
---|
845 | % the field series set by MinIndex_i, incr, last_i |
---|
846 | % index=1: look for pairs for civ1 |
---|
847 | % index=2: look for pairs for civ2 |
---|
848 | function errormsg=find_netcpair_civ(handles,index) |
---|
849 | %------------------------------------------------------------------------ |
---|
850 | set(gcf,'Pointer','watch')% set the mouse pointer to 'watch' (clock) |
---|
851 | |
---|
852 | %% initialisation |
---|
853 | errormsg=''; |
---|
854 | CivInputData=get(handles.civ_input,'UserData'); |
---|
855 | %browse=get(handles.RootPath,'UserData'); |
---|
856 | compare_list=get(handles.ListCompareMode,'String'); |
---|
857 | val=get(handles.ListCompareMode,'Value'); |
---|
858 | compare=compare_list{val}; |
---|
859 | if strcmp(compare,'displacement')||strcmp(compare,'shift') |
---|
860 | mode='displacement'; |
---|
861 | else |
---|
862 | mode_list=get(handles.ListPairMode,'String'); |
---|
863 | mode_value=get(handles.ListPairMode,'Value'); |
---|
864 | if isempty(mode_list) |
---|
865 | return |
---|
866 | end |
---|
867 | mode=mode_list{mode_value}; |
---|
868 | end |
---|
869 | nom_type_ima=CivInputData.NomTypeIma; |
---|
870 | |
---|
871 | %% determine nom_type_nc, nomenclature type of the .nc files: |
---|
872 | %[nom_type_nc]=nomtype2pair(nom_type_ima,mode); |
---|
873 | |
---|
874 | %% reads .nc subdirectoy and image numbers from the interface |
---|
875 | %SubDirImages=get(handles.Civ1_ImageA,'String'); |
---|
876 | %TODO: determine |
---|
877 | %subdir_civ1=[SubDirImages get(handles.Civ1_ImageB,'String')];%subdirectory subdir_civ1 for the netcdf data |
---|
878 | %subdir_civ2=[SubDirImages get(handles.Civ2_ImageA,'String')];%subdirectory subdir_civ2 for the netcdf data |
---|
879 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
880 | ref_j=[]; |
---|
881 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
882 | ref_j=0; |
---|
883 | elseif strcmp(get(handles.ref_j,'Visible'),'on') |
---|
884 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
885 | end |
---|
886 | if isempty(ref_j) |
---|
887 | ref_j=1; |
---|
888 | end |
---|
889 | CivInputData=get(handles.civ_input,'UserData'); |
---|
890 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
891 | Time=CivInputData.Time; |
---|
892 | checkframe=strcmp(TimeUnit,'frame'); |
---|
893 | |
---|
894 | %% case with no Civ1 operation, netcdf files need to exist for reading |
---|
895 | displ_pair={''}; |
---|
896 | nbpair=200;%default |
---|
897 | select=ones(size(1:nbpair));%flag for displayed pairs =1 for display |
---|
898 | nbpair=200; %default |
---|
899 | |
---|
900 | %% determine the menu display in .ListPairCiv1 |
---|
901 | switch mode |
---|
902 | case 'series(Di)' |
---|
903 | for ipair=1:nbpair |
---|
904 | if select(ipair) |
---|
905 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; |
---|
906 | if ~checkframe |
---|
907 | if size(Time,1)>=ref_i+1+ceil(ipair/2) && size(Time,2)>=ref_j+1&& ref_i-floor(ipair/2)>=0 && ref_j>=0 |
---|
908 | dt=Time(ref_i+1+ceil(ipair/2),ref_j+1)-Time(ref_i+1-floor(ipair/2),ref_j+1);%Time interval dtref_j+1 |
---|
909 | displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; |
---|
910 | end |
---|
911 | else |
---|
912 | dt=ipair/1000; |
---|
913 | displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(ipair)]; |
---|
914 | end |
---|
915 | else |
---|
916 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
917 | end |
---|
918 | end |
---|
919 | case 'series(Dj)' |
---|
920 | for ipair=1:nbpair |
---|
921 | if select(ipair) |
---|
922 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; |
---|
923 | if ~checkframe |
---|
924 | if size(Time,2)>=ref_j+1+ceil(ipair/2) && size(Time,1)>=ref_i+1 && ref_j-floor(ipair/2)>=0 && ref_i>=0 |
---|
925 | dt=Time(ref_i+1,ref_j+1+ceil(ipair/2))-Time(ref_i+1,ref_j+1-floor(ipair/2));%Time interval dtref_j+1 |
---|
926 | displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; |
---|
927 | end |
---|
928 | else |
---|
929 | dt=ipair/1000; |
---|
930 | displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; |
---|
931 | end |
---|
932 | else |
---|
933 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
934 | end |
---|
935 | end |
---|
936 | case 'pair j1-j2'%case of pairs |
---|
937 | % MinIndex_j=CivInputData.MinIndex_j; |
---|
938 | % MaxIndex_j=min(CivInputData.MaxIndex_j,10);%limitate the number of pairs to 10x10 |
---|
939 | MinIndex_j=str2num(get(handles.MinIndex_j,'String')); |
---|
940 | MaxIndex_j=str2num(get(handles.MaxIndex_j,'String')); |
---|
941 | index_pair=0; |
---|
942 | %get all the Time intervals in bursts |
---|
943 | for numod_a=MinIndex_j:MaxIndex_j-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
944 | for numod_b=(numod_a+1):MaxIndex_j |
---|
945 | index_pair=index_pair+1; |
---|
946 | displ_pair{index_pair}=['j= ' num2stra(numod_a,nom_type_ima) '-' num2stra(numod_b,nom_type_ima)]; |
---|
947 | dt(index_pair)=numod_b-numod_a;%default dt |
---|
948 | if size(Time,1)>ref_i && size(Time,2)>numod_b % && ~checkframe |
---|
949 | dt(index_pair)=Time(ref_i+1,numod_b+1)-Time(ref_i+1,numod_a+1);% Time interval dt |
---|
950 | displ_pair{index_pair}=[displ_pair{index_pair} ' :dt= ' num2str(dt(index_pair)*1000)]; |
---|
951 | end |
---|
952 | end |
---|
953 | |
---|
954 | end |
---|
955 | [tild,indsort]=sort(dt); |
---|
956 | displ_pair=displ_pair(indsort); |
---|
957 | case 'displacement' |
---|
958 | displ_pair={'Di=Dj=0'}; |
---|
959 | end |
---|
960 | if index==1 |
---|
961 | set(handles.ListPairCiv1,'String',displ_pair'); |
---|
962 | end |
---|
963 | |
---|
964 | %% determine the default selection in the pair menu for Civ1 |
---|
965 | ichoice=find(select,1);% index of first selected pair |
---|
966 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
967 | initial=get(handles.ListPairCiv1,'Value');%initial choice of pair |
---|
968 | if initial>nbpair || (numel(select)>=initial && ~isequal(select(initial),1)) |
---|
969 | set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
970 | end |
---|
971 | |
---|
972 | %% determine the default selection in the pair menu for Civ2 |
---|
973 | if strcmp(get(handles.ListPairCiv2,'Visible'),'on') |
---|
974 | initial=get(handles.ListPairCiv2,'Value'); |
---|
975 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
976 | if ichoice <= length(displ_pair') |
---|
977 | set(handles.ListPairCiv2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
978 | else |
---|
979 | set(handles.ListPairCiv2,'Value',1);% same pair proposed by default for civ2 |
---|
980 | end |
---|
981 | end |
---|
982 | else |
---|
983 | set(handles.ListPairCiv2,'Value',get(handles.ListPairCiv1,'Value'))% initiate the choice of Civ2 as a reproduction of if civ1 |
---|
984 | end |
---|
985 | set(handles.ListPairCiv2,'String',displ_pair'); |
---|
986 | set(gcf,'Pointer','arrow')% Indicate that the process is finished |
---|
987 | |
---|
988 | |
---|
989 | |
---|
990 | % %------------------------------------------------------------------------ |
---|
991 | % % call 'view_field.fig' to display the field selected in the list of 'status' |
---|
992 | % function open_view_field(hObject, eventdata) |
---|
993 | % %------------------------------------------------------------------------ |
---|
994 | % list=get(hObject,'String'); |
---|
995 | % index=get(hObject,'Value'); |
---|
996 | % rootroot=get(hObject,'UserData'); |
---|
997 | % filename=list{index}; |
---|
998 | % ind_dot=strfind(filename,'...'); |
---|
999 | % filename=filename(1:ind_dot-1); |
---|
1000 | % filename=fullfile(rootroot,filename); |
---|
1001 | % delete(get(hObject,'parent'))%delete the display figure to stop the check process |
---|
1002 | % if exist(filename,'file')%visualise the vel field if it exists |
---|
1003 | % uvmat(filename) |
---|
1004 | % set(gcbo,'Value',1) |
---|
1005 | % end |
---|
1006 | |
---|
1007 | |
---|
1008 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1009 | % Callbacks in the uipanel Reference Indices |
---|
1010 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1011 | %------------------------------------------------------------------------ |
---|
1012 | function MinIndex_i_Callback(hObject, eventdata, handles) |
---|
1013 | %------------------------------------------------------------------------ |
---|
1014 | first_i=str2double(get(handles.MinIndex_i,'String')); |
---|
1015 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
1016 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
1017 | |
---|
1018 | % %------------------------------------------------------------------------ |
---|
1019 | % function MinIndex_j_Callback(hObject, eventdata, handles) |
---|
1020 | % %------------------------------------------------------------------------ |
---|
1021 | % first_j=str2num(get(handles.MinIndex_j,'String')); |
---|
1022 | % set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
1023 | % ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
1024 | |
---|
1025 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1026 | % Callbacks in the uipanel Civ1 |
---|
1027 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1028 | %------------------------------------------------------------------------ |
---|
1029 | % --- Executes on button press in SearchRange: determine the search range num_SearchBoxSize_1,num_SearchBoxSize_2 |
---|
1030 | function SearchRange_Callback(hObject, eventdata, handles) |
---|
1031 | %------------------------------------------------------------------------ |
---|
1032 | %determine pair numbers |
---|
1033 | if strcmp(get(handles.num_UMin,'Visible'),'off') |
---|
1034 | set(handles.u_title,'Visible','on') |
---|
1035 | set(handles.v_title,'Visible','on') |
---|
1036 | set(handles.num_UMin,'Visible','on') |
---|
1037 | set(handles.num_UMax,'Visible','on') |
---|
1038 | set(handles.num_VMin,'Visible','on') |
---|
1039 | set(handles.num_VMax,'Visible','on') |
---|
1040 | %set(handles.CoordUnit,'Visible','on') |
---|
1041 | %set(handles.TimeUnit,'Visible','on') |
---|
1042 | %set(handles.slash_title,'Visible','on') |
---|
1043 | set(handles.min_title,'Visible','on') |
---|
1044 | set(handles.max_title,'Visible','on') |
---|
1045 | set(handles.unit_title,'Visible','on') |
---|
1046 | else |
---|
1047 | get_search_range(hObject, eventdata, handles) |
---|
1048 | end |
---|
1049 | |
---|
1050 | %------------------------------------------------------------------------ |
---|
1051 | % --- determine the search range num_SearchBoxSize_1,num_SearchBoxSize_2 and shift |
---|
1052 | function get_search_range(hObject, eventdata, handles) |
---|
1053 | %------------------------------------------------------------------------ |
---|
1054 | param_civ1=read_GUI(handles.Civ1); |
---|
1055 | umin=param_civ1.UMin; |
---|
1056 | umax=param_civ1.UMax; |
---|
1057 | vmin=param_civ1.VMin; |
---|
1058 | vmax=param_civ1.VMax; |
---|
1059 | %switch min_title and max_title in case of error |
---|
1060 | if umax<=umin |
---|
1061 | umin_old=umin; |
---|
1062 | umin=umax; |
---|
1063 | umax=umin_old; |
---|
1064 | set(handles.num_UMin,'String', num2str(umin)) |
---|
1065 | set(handles.num_UMax,'String', num2str(umax)) |
---|
1066 | end |
---|
1067 | if vmax<=vmin |
---|
1068 | vmin_old=vmin; |
---|
1069 | vmin=vmax; |
---|
1070 | vmax=vmin_old; |
---|
1071 | set(handles.num_VMin,'String', num2str(vmin)) |
---|
1072 | set(handles.num_VMax,'String', num2str(vmax)) |
---|
1073 | end |
---|
1074 | if ~(isempty(umin)||isempty(umax)||isempty(vmin)||isempty(vmax)) |
---|
1075 | % list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs |
---|
1076 | % index=get(handles.ListPairCiv1,'Value'); |
---|
1077 | % pair_string=list_pair{index}; |
---|
1078 | % time=get(handles.TimeSource,'UserData'); %get the set of times |
---|
1079 | % pxcm=get(handles.SearchRange,'UserData'); |
---|
1080 | % mode_list=get(handles.ListPairMode,'String'); |
---|
1081 | % mode_value=get(handles.ListPairMode,'Value'); |
---|
1082 | % mode=mode_list{mode_value}; |
---|
1083 | % if isequal (mode, 'series(Di)' ) |
---|
1084 | % ref_i=str2double(get(handles.ref_i,'String')); |
---|
1085 | % num1=ref_i-floor(index/2);% first image numbers |
---|
1086 | % num2=ref_i+ceil(index/2); |
---|
1087 | % num_a=1; |
---|
1088 | % num_b=1; |
---|
1089 | % elseif isequal (mode, 'series(Dj)') |
---|
1090 | % num1=1; |
---|
1091 | % num2=1; |
---|
1092 | % ref_j=str2double(get(handles.ref_j,'String')); |
---|
1093 | % num_a=ref_j-floor(index/2);% first image numbers |
---|
1094 | % num_b=ref_j+ceil(index/2); |
---|
1095 | % elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
1096 | % ref_i=str2double(get(handles.ref_i,'String')); |
---|
1097 | % num1=ref_i; |
---|
1098 | % num2=ref_i; |
---|
1099 | % r=regexp(pair_string,'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names'); |
---|
1100 | % if isempty(r) |
---|
1101 | % r=regexp(pair_string,'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names'); |
---|
1102 | % end |
---|
1103 | % num_a=str2num(r.num1); |
---|
1104 | % num_b=str2num(r.num2); |
---|
1105 | % end |
---|
1106 | % dt=time(num2+1,num_b+1)-time(num1+1,num_a+1); |
---|
1107 | % ibx=str2double(get(handles.num_CorrBoxSize_1,'String')); |
---|
1108 | % iby=str2double(get(handles.num_CorrBoxSize_2,'String')); |
---|
1109 | % umin=dt*pxcm*umin; |
---|
1110 | % umax=dt*pxcm*umax; |
---|
1111 | % vmin=dt*pxcm*vmin; |
---|
1112 | % vmax=dt*pxcm*vmax; |
---|
1113 | shiftx=round((umin+umax)/2); |
---|
1114 | shifty=round((vmin+vmax)/2); |
---|
1115 | isx=(umax+2-shiftx)*2+param_civ1.CorrBoxSize(1); |
---|
1116 | isx=2*ceil(isx/2)+1; |
---|
1117 | isy=(vmax+2-shifty)*2+param_civ1.CorrBoxSize(2); |
---|
1118 | isy=2*ceil(isy/2)+1; |
---|
1119 | set(handles.num_SearchBoxShift_1,'String',num2str(shiftx)); |
---|
1120 | set(handles.num_SearchBoxShift_2,'String',num2str(shifty)); |
---|
1121 | set(handles.num_SearchBoxSize_1,'String',num2str(isx)); |
---|
1122 | set(handles.num_SearchBoxSize_2,'String',num2str(isy)); |
---|
1123 | end |
---|
1124 | |
---|
1125 | %------------------------------------------------------------------------ |
---|
1126 | % --- Executes on selection in menu CorrSmooth. |
---|
1127 | function num_CorrSmooth_Callback(hObject, eventdata, handles) |
---|
1128 | set(handles.configSource,'String','NEW') |
---|
1129 | set(handles.OK,'BackgroundColor',[1 0 1]) |
---|
1130 | %------------------------------------------------------------------------ |
---|
1131 | |
---|
1132 | % --- Executes on button press in CheckDeformation. |
---|
1133 | function CheckDeformation_Callback(hObject, eventdata, handles) |
---|
1134 | set(handles.configSource,'String','NEW') |
---|
1135 | set(handles.OK,'BackgroundColor',[1 0 1]) |
---|
1136 | |
---|
1137 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1138 | % Callbacks in the uipanel Fix1 |
---|
1139 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1140 | %------------------------------------------------------------------------ |
---|
1141 | % % --- Executes on button press in CheckMask. |
---|
1142 | % function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
1143 | % %------------------------------------------------------------------------ |
---|
1144 | % maskval=get(handles.CheckMask,'Value'); |
---|
1145 | % if isequal(maskval,0) |
---|
1146 | % set(handles.Mask,'String','') |
---|
1147 | % else |
---|
1148 | % mask_displ='no mask'; %default |
---|
1149 | % filebase=get(handles.RootPath,'String'); |
---|
1150 | % [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
1151 | % if isequal(flag_mask,1) |
---|
1152 | % mask_displ=[num2str(nbslice) 'mask']; |
---|
1153 | % elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
1154 | % filebase_a=get(handles.RootFile_1,'String'); |
---|
1155 | % [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
1156 | % if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
1157 | % mask_displ='no mask'; |
---|
1158 | % end |
---|
1159 | % end |
---|
1160 | % if isequal(mask_displ,'no mask') |
---|
1161 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
1162 | % {'*.png', ' (*.png)'; |
---|
1163 | % '*.png', '.png files '; ... |
---|
1164 | % '*.*', 'All Files (*.*)'}, ... |
---|
1165 | % 'Pick a mask file *.png',filebase); |
---|
1166 | % mask_displ=fullfile(PathName,FileName); |
---|
1167 | % if ~exist(mask_displ,'file') |
---|
1168 | % mask_displ='no mask'; |
---|
1169 | % end |
---|
1170 | % end |
---|
1171 | % if isequal(mask_displ,'no mask') |
---|
1172 | % set(handles.CheckMask,'Value',0) |
---|
1173 | % set(handles.CheckMask,'Value',0) |
---|
1174 | % set(handles.CheckMask,'Value',0) |
---|
1175 | % else |
---|
1176 | % %set(handles.CheckMask,'Value',1) |
---|
1177 | % set(handles.CheckMask,'Value',1) |
---|
1178 | % end |
---|
1179 | % set(handles.Mask,'String',mask_displ) |
---|
1180 | % set(handles.Mask,'String',mask_displ) |
---|
1181 | % set(handles.Mask,'String',mask_displ) |
---|
1182 | % end |
---|
1183 | |
---|
1184 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1185 | % Callbacks in the uipanel Civ2 |
---|
1186 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1187 | %------------------------------------------------------------------------ |
---|
1188 | % --- Executes on button press in CheckMask: select box for mask option |
---|
1189 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
1190 | %------------------------------------------------------------------------ |
---|
1191 | maskval=get(handles.CheckMask,'Value'); |
---|
1192 | if isequal(maskval,0) |
---|
1193 | set(handles.Mask,'String','') |
---|
1194 | else |
---|
1195 | mask_displ='no mask'; %default |
---|
1196 | filebase=get(handles.RootPath,'String'); |
---|
1197 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
1198 | if isequal(flag_mask,1) |
---|
1199 | mask_displ=[num2str(nbslice) 'mask']; |
---|
1200 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
1201 | filebase_a=get(handles.RootFile_1,'String'); |
---|
1202 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
1203 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
1204 | mask_displ='no mask'; |
---|
1205 | end |
---|
1206 | end |
---|
1207 | if isequal(mask_displ,'no mask') |
---|
1208 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1209 | {'*.png', ' (*.png)'; |
---|
1210 | '*.png', '.png files '; ... |
---|
1211 | '*.*', 'All Files (*.*)'}, ... |
---|
1212 | 'Pick a mask file *.png',filebase); |
---|
1213 | mask_displ=fullfile(PathName,FileName); |
---|
1214 | if ~exist(mask_displ,'file') |
---|
1215 | mask_displ='no mask'; |
---|
1216 | end |
---|
1217 | end |
---|
1218 | if isequal(mask_displ,'no mask') |
---|
1219 | set(handles.CheckMask,'Value',0) |
---|
1220 | set(handles.CheckMask,'Value',0) |
---|
1221 | else |
---|
1222 | set(handles.CheckMask,'Value',1) |
---|
1223 | end |
---|
1224 | set(handles.Mask,'String',mask_displ) |
---|
1225 | end |
---|
1226 | |
---|
1227 | % %------------------------------------------------------------------------ |
---|
1228 | % % --- Executes on button press in CheckMask. |
---|
1229 | % function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
1230 | % %------------------------------------------------------------------------ |
---|
1231 | % maskval=get(handles.CheckMask,'Value'); |
---|
1232 | % if isequal(maskval,0) |
---|
1233 | % set(handles.Mask,'String','') |
---|
1234 | % else |
---|
1235 | % mask_displ='no mask'; %default |
---|
1236 | % filebase=get(handles.RootPath,'String'); |
---|
1237 | % [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
1238 | % if isequal(flag_mask,1) |
---|
1239 | % mask_displ=[num2str(nbslice) 'mask']; |
---|
1240 | % elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
1241 | % filebase_a=get(handles.RootFile_1,'String'); |
---|
1242 | % [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
1243 | % if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
1244 | % mask_displ='no mask'; |
---|
1245 | % end |
---|
1246 | % end |
---|
1247 | % if isequal(mask_displ,'no mask') |
---|
1248 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
1249 | % {'*.png', ' (*.png)'; |
---|
1250 | % '*.png', '.png files '; ... |
---|
1251 | % '*.*', 'All Files (*.*)'}, ... |
---|
1252 | % 'Pick a mask file *.png',filebase); |
---|
1253 | % mask_displ=fullfile(PathName,FileName); |
---|
1254 | % if ~exist(mask_displ,'file') |
---|
1255 | % mask_displ='no mask'; |
---|
1256 | % end |
---|
1257 | % end |
---|
1258 | % if isequal(mask_displ,'no mask') |
---|
1259 | % set(handles.CheckMask,'Value',0) |
---|
1260 | % end |
---|
1261 | % set(handles.Mask,'String',mask_displ) |
---|
1262 | % end |
---|
1263 | |
---|
1264 | %------------------------------------------------------------------------ |
---|
1265 | % --- function called to look for mask files |
---|
1266 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
1267 | %------------------------------------------------------------------------ |
---|
1268 | %detect mask files, images with appropriate file base |
---|
1269 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
1270 | %flag_mask=1 indicates detection |
---|
1271 | |
---|
1272 | flag_mask=0;%default |
---|
1273 | nbslice=1; |
---|
1274 | |
---|
1275 | % subdir=get(handles.Civ1_ImageB,'String'); |
---|
1276 | [Path,Name]=fileparts(filebase); |
---|
1277 | if ~isdir(Path) |
---|
1278 | msgbox_uvmat('ERROR','no path for input files') |
---|
1279 | return |
---|
1280 | end |
---|
1281 | % currentdir=pwd; |
---|
1282 | % cd(Path);%move in the dir of the root name filebase |
---|
1283 | maskfiles=dir(fullfile(Path,[Name '_*mask_*.png']));%look for mask files |
---|
1284 | % cd(currentdir);%come back to the current working directory |
---|
1285 | if ~isempty(maskfiles) |
---|
1286 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
1287 | % else |
---|
1288 | flag_mask=1; |
---|
1289 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
1290 | [Path2,Name,ext]=fileparts(maskname); |
---|
1291 | Namedouble=double(Name); |
---|
1292 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
1293 | ind_mask=findstr('mask',Name); |
---|
1294 | i=ind_mask-1; |
---|
1295 | while val(i)==0 && i>0 |
---|
1296 | i=i-1; |
---|
1297 | end |
---|
1298 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
1299 | if ~isnan(nbslice) && Name(i)=='_' |
---|
1300 | flag_mask=1; |
---|
1301 | else |
---|
1302 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
1303 | return |
---|
1304 | nbslice=1; |
---|
1305 | end |
---|
1306 | end |
---|
1307 | |
---|
1308 | %------------------------------------------------------------------------ |
---|
1309 | % --- function called to look for grid files |
---|
1310 | function [nbslice, flag_grid]=get_grid(filebase,handles) |
---|
1311 | %------------------------------------------------------------------------ |
---|
1312 | flag_grid=0;%default |
---|
1313 | nbslice=1; |
---|
1314 | [Path,Name]=fileparts(filebase); |
---|
1315 | currentdir=pwd; |
---|
1316 | cd(Path);%move in the dir of the root name filebase |
---|
1317 | gridfiles=dir([Name '_*grid_*.grid']);%look for grid files |
---|
1318 | cd(currentdir);%come back to the current working directory |
---|
1319 | if ~isempty(gridfiles) |
---|
1320 | flag_grid=1; |
---|
1321 | gridname=gridfiles(1).name;% take the first grid file in the list |
---|
1322 | [Path2,Name,ext]=fileparts(gridname); |
---|
1323 | Namedouble=double(Name); |
---|
1324 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
1325 | ind_grid=findstr('grid',Name); |
---|
1326 | i=ind_grid-1; |
---|
1327 | while val(i)==0 && i>0 |
---|
1328 | i=i-1; |
---|
1329 | end |
---|
1330 | nbslice=str2double(Name(i+1:ind_grid-1)); |
---|
1331 | if ~isnan(nbslice) && Name(i)=='_' |
---|
1332 | flag_grid=1; |
---|
1333 | else |
---|
1334 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
1335 | return |
---|
1336 | nbslice=1; |
---|
1337 | end |
---|
1338 | end |
---|
1339 | |
---|
1340 | %------------------------------------------------------------------------ |
---|
1341 | % --- transform numbers to letters |
---|
1342 | function str=num2stra(num,nom_type) |
---|
1343 | %------------------------------------------------------------------------ |
---|
1344 | if isempty(nom_type) |
---|
1345 | str=''; |
---|
1346 | elseif strcmp(nom_type(end),'a') |
---|
1347 | str=char(96+num); |
---|
1348 | elseif strcmp(nom_type(end),'A') |
---|
1349 | str=char(96+num); |
---|
1350 | elseif isempty(nom_type(2:end))%a single index |
---|
1351 | str=''; |
---|
1352 | else |
---|
1353 | str=num2str(num); |
---|
1354 | end |
---|
1355 | |
---|
1356 | % %------------------------------------------------------------------------ |
---|
1357 | % % --- Executes on button press in ListSubdirCiv1. |
---|
1358 | % function ListSubdirCiv1_Callback(hObject, eventdata, handles) |
---|
1359 | % %------------------------------------------------------------------------ |
---|
1360 | % list_subdir_civ1=get(handles.ListSubdirCiv1,'String'); |
---|
1361 | % val=get(handles.ListSubdirCiv1,'Value'); |
---|
1362 | % SubDir=list_subdir_civ1{val}; |
---|
1363 | % if strcmp(SubDir,'new...') |
---|
1364 | % if get(handles.CheckCiv1,'Value') |
---|
1365 | % SubDir='CIV_INPUT'; %default subdirectory |
---|
1366 | % else |
---|
1367 | % msgbox_uvmat('ERROR','select CheckCiv1 to perform a new civ_input operation') |
---|
1368 | % return |
---|
1369 | % end |
---|
1370 | % end |
---|
1371 | % set(handles.Civ1_ImageB,'String',SubDir); |
---|
1372 | % errormsg=find_netcpair_civ(handles,1); |
---|
1373 | % if ~isempty(errormsg) |
---|
1374 | % msgbox_uvmat('ERROR',errormsg) |
---|
1375 | % end |
---|
1376 | % |
---|
1377 | %------------------------------------------------------------------------ |
---|
1378 | % % --- Executes on button press in ListSubdirCiv2. |
---|
1379 | % function ListSubdirCiv2_Callback(hObject, eventdata, handles) |
---|
1380 | % %------------------------------------------------------------------------ |
---|
1381 | % list_subdir_civ2=get(handles.ListSubdirCiv2,'String'); |
---|
1382 | % val=get(handles.ListSubdirCiv2,'Value'); |
---|
1383 | % SubDir=list_subdir_civ2{val}; |
---|
1384 | % if strcmp(SubDir,'new...') |
---|
1385 | % if get(handles.CheckCiv2,'Value') |
---|
1386 | % SubDir='CIV_INPUT'; %default subdirectory |
---|
1387 | % else |
---|
1388 | % msgbox_uvmat('ERROR','select CheckCiv2 to perform a new civ_input operation') |
---|
1389 | % return |
---|
1390 | % end |
---|
1391 | % end |
---|
1392 | % set(handles.Civ2_ImageA,'String',SubDir); |
---|
1393 | |
---|
1394 | %------------------------------------------------------------------------ |
---|
1395 | % --- Executes on button press in CheckGrid. |
---|
1396 | function CheckGrid_Callback(hObject, eventdata, handles) |
---|
1397 | %------------------------------------------------------------------------ |
---|
1398 | value=get(hObject,'Value'); |
---|
1399 | hparent=get(hObject,'parent');%handles of the parent panel |
---|
1400 | hchildren=get(hparent,'children'); |
---|
1401 | handle_txtbox=findobj(hchildren,'tag','Grid');% look for the grid name box in the same panel |
---|
1402 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
1403 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
1404 | handle_title_dx=findobj(hchildren,'tag','title_Dx'); |
---|
1405 | handle_title_dy=findobj(hchildren,'tag','title_Dy'); |
---|
1406 | testgrid=0; |
---|
1407 | filegrid=''; |
---|
1408 | if value |
---|
1409 | hseries=findobj(allchild(0),'Tag','series'); |
---|
1410 | hhseries=guidata(hseries); |
---|
1411 | InputTable=get(hhseries.InputTable,'Data'); |
---|
1412 | ind_A=1;% line index of the (first) image series |
---|
1413 | if strcmp(InputTable{1,5},'.nc'); |
---|
1414 | ind_A=2; |
---|
1415 | end |
---|
1416 | filebase=InputTable{ind_A,1}; |
---|
1417 | [nbslice, flag_grid]=get_grid(filebase,handles);% look for a grid with appropriate name |
---|
1418 | if isequal(flag_grid,1) |
---|
1419 | filegrid=[num2str(nbslice) 'grid']; |
---|
1420 | testgrid=1; |
---|
1421 | else % browse for a grid |
---|
1422 | filegrid=get(hObject,'UserData');%look for previous grid name stored as UserData |
---|
1423 | if exist(filegrid,'file') |
---|
1424 | filebase=filegrid; |
---|
1425 | end |
---|
1426 | filegrid = uigetfile_uvmat('pick a grid file .grid:',filebase,'.grid'); |
---|
1427 | set(hObject,'UserData',filegrid);%store for future use |
---|
1428 | if ~isempty(filegrid) |
---|
1429 | testgrid=1; |
---|
1430 | end |
---|
1431 | set(hObject,'UserData',filegrid);%store for future use |
---|
1432 | end |
---|
1433 | end |
---|
1434 | if testgrid |
---|
1435 | set(handle_dx,'Visible','off'); |
---|
1436 | set(handle_dy,'Visible','off'); |
---|
1437 | set(handle_title_dy,'Visible','off'); |
---|
1438 | set(handle_title_dx,'Visible','off'); |
---|
1439 | set(handle_txtbox,'Visible','on') |
---|
1440 | set(handle_txtbox,'String',filegrid) |
---|
1441 | else |
---|
1442 | set(hObject,'Value',0); |
---|
1443 | set(handle_dx,'Visible','on'); |
---|
1444 | set(handle_dy,'Visible','on'); |
---|
1445 | set(handle_title_dy,'Visible','on'); |
---|
1446 | set(handle_title_dx,'Visible','on'); |
---|
1447 | set(handle_txtbox,'Visible','off') |
---|
1448 | end |
---|
1449 | |
---|
1450 | %% if hObject is on the checkciv1 frame, duplicate action for checkciv2 frame |
---|
1451 | PanelName=get(hparent,'tag'); |
---|
1452 | if strcmp(PanelName,'Civ1') |
---|
1453 | hchildren=get(handles.Civ2,'children'); |
---|
1454 | handle_checkbox=findobj(hchildren,'tag','CheckGrid'); |
---|
1455 | handle_txtbox=findobj(hchildren,'tag','Grid'); |
---|
1456 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
1457 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
1458 | handle_title_dx=findobj(hchildren,'tag','title_Dx'); |
---|
1459 | handle_title_dy=findobj(hchildren,'tag','title_Dy'); |
---|
1460 | set(handle_checkbox,'UserData',filegrid);%store for future use |
---|
1461 | if testgrid |
---|
1462 | set(handle_checkbox,'Value',1); |
---|
1463 | set(handle_dx,'Visible','off'); |
---|
1464 | set(handle_dy,'Visible','off'); |
---|
1465 | set(handle_title_dx,'Visible','off'); |
---|
1466 | set(handle_title_dy,'Visible','off'); |
---|
1467 | set(handle_txtbox,'Visible','on') |
---|
1468 | set(handle_txtbox,'String',filegrid) |
---|
1469 | end |
---|
1470 | end |
---|
1471 | set(hObject,'BackgroundColor',[1 0 1]) |
---|
1472 | set(handles.configSource,'String','NEW') |
---|
1473 | set(handles.OK,'BackgroundColor',[1 0 1]) |
---|
1474 | %------------------------------------------------------------------------ |
---|
1475 | % --- Executes on button press in CheckMask: common to all panels (civ1, Civ2..) |
---|
1476 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
1477 | %------------------------------------------------------------------------ |
---|
1478 | value=get(hObject,'Value'); |
---|
1479 | hparent=get(hObject,'parent'); |
---|
1480 | parent_tag=get(hparent,'Tag'); |
---|
1481 | hchildren=get(hparent,'children'); |
---|
1482 | handle_txtbox=findobj(hchildren,'tag','Mask');% look for the mask name box in the same panel |
---|
1483 | |
---|
1484 | testmask=0; |
---|
1485 | if value |
---|
1486 | hseries=findobj(allchild(0),'Tag','series'); |
---|
1487 | hhseries=guidata(hseries); |
---|
1488 | InputTable=get(hhseries.InputTable,'Data'); |
---|
1489 | ind_A=1;% line index of the (first) image series |
---|
1490 | if strcmp(InputTable{1,5},'.nc'); |
---|
1491 | ind_A=2; |
---|
1492 | end |
---|
1493 | [nbslice, flag_mask]=get_mask(InputTable{ind_A,1},handles);% look for a mask with appropriate name |
---|
1494 | if isequal(flag_mask,1) |
---|
1495 | filemask=[num2str(nbslice) 'mask']; |
---|
1496 | testmask=1; |
---|
1497 | else % browse for a mask |
---|
1498 | % filemask=get(hObject,'UserData');%look for previous mask name stored as UserData |
---|
1499 | % if exist(filemask,'file') |
---|
1500 | % filebase=filemask; |
---|
1501 | % end |
---|
1502 | filemask= uigetfile_uvmat('pick a mask image file:',InputTable{ind_A,1},'image'); |
---|
1503 | set(hObject,'UserData',filemask);%store for future use |
---|
1504 | if ~isempty(filemask) |
---|
1505 | testmask=1; |
---|
1506 | end |
---|
1507 | end |
---|
1508 | end |
---|
1509 | if testmask |
---|
1510 | set(handles.Mask,'Visible','on') |
---|
1511 | set(handles.Mask,'String',filemask) |
---|
1512 | set(handles.CheckMask,'Value',1) |
---|
1513 | else |
---|
1514 | set(hObject,'Value',0); |
---|
1515 | set(handle_txtbox,'Visible','off') |
---|
1516 | end |
---|
1517 | set(handles.configSource,'String','NEW') |
---|
1518 | set(handles.configSource,'BackgroundColor',[1 0 1]) |
---|
1519 | |
---|
1520 | % %------------------------------------------------------------------------ |
---|
1521 | % % --- Executes on button press in get_gridpatch1. |
---|
1522 | % function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
1523 | % %------------------------------------------------------------------------ |
---|
1524 | % filebase=get(handles.RootPath,'String'); |
---|
1525 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
1526 | % {'*.grid', ' (*.grid)'; |
---|
1527 | % '*.grid', '.grid files '; ... |
---|
1528 | % '*.*', 'All Files (*.*)'}, ... |
---|
1529 | % 'Pick a file',filebase); |
---|
1530 | % filegrid=fullfile(PathName,FileName); |
---|
1531 | % set(handles.grid_patch1,'string',filegrid); |
---|
1532 | % set(hObject,'BackgroundColor',[1 0 1]) |
---|
1533 | |
---|
1534 | %------------------------------------------------------------------------ |
---|
1535 | % --- STEREO Interp |
---|
1536 | function cmd=RUN_STINTERP(stinterpBin,filename_A_nc,filename_B_nc,filename_nc,nx_patch,ny_patch,rho_patch,subdomain_patch,thresh_value,xmlA,xmlB) |
---|
1537 | %------------------------------------------------------------------------ |
---|
1538 | namelog=[filename_nc(1:end-3) '_stinterp.log']; |
---|
1539 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
1540 | ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ' -c1 ' xmlA ' -c2 ' xmlB ' -xy x -Nfy 1024 > ' namelog ' 2>&1']; % redirect standard output to the log file |
---|
1541 | |
---|
1542 | % %------------------------------------------------------------------------ |
---|
1543 | % %--read images and convert them to the uint16 format used for PIV |
---|
1544 | % function A=read_image(filename,type_ima,num,movieobject) |
---|
1545 | % %------------------------------------------------------------------------ |
---|
1546 | % %num is the view number needed for an avi movie |
---|
1547 | % switch type_ima |
---|
1548 | % case 'movie' |
---|
1549 | % A=read(movieobject,num); |
---|
1550 | % case 'avi' |
---|
1551 | % mov=aviread(filename,num); |
---|
1552 | % A=frame2im(mov(1)); |
---|
1553 | % case 'multimage' |
---|
1554 | % A=imread(filename,num); |
---|
1555 | % case 'image' |
---|
1556 | % A=imread(filename); |
---|
1557 | % end |
---|
1558 | % siz=size(A); |
---|
1559 | % if length(siz)==3;%color images |
---|
1560 | % A=sum(double(A),3); |
---|
1561 | % A=uint16(A); |
---|
1562 | % end |
---|
1563 | |
---|
1564 | |
---|
1565 | %------------------------------------------------------------------------ |
---|
1566 | % --- Executes on button press in get_ref_fix1. |
---|
1567 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
1568 | %------------------------------------------------------------------------ |
---|
1569 | filebase=get(handles.RootPath,'String'); |
---|
1570 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1571 | {'*.nc', ' (*.nc)'; |
---|
1572 | '*.nc', 'netcdf files '; ... |
---|
1573 | '*.*', 'All Files (*.*)'}, ... |
---|
1574 | 'Pick a file',filebase); |
---|
1575 | |
---|
1576 | fileinput=[PathName FileName]; |
---|
1577 | sizf=size(fileinput); |
---|
1578 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
1579 | %[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
1580 | [Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput); |
---|
1581 | ref.filebase=fullfile(Path,File); |
---|
1582 | % ref.num_a=stra2num(str_a); |
---|
1583 | % ref.num_b=stra2num(str_b); |
---|
1584 | % ref.num1=str2double(field_count); |
---|
1585 | % ref.num2=str2double(str2); |
---|
1586 | browse=[];%initialisation |
---|
1587 | if ~isequal(ref.ext,'.nc') |
---|
1588 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
1589 | return |
---|
1590 | end |
---|
1591 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
1592 | set(handles.ref_fix1,'UserData',ref) |
---|
1593 | menu_field{1}='civ1'; |
---|
1594 | Data=nc2struct(fileinput,[]); |
---|
1595 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
1596 | menu_field{2}='filter1'; |
---|
1597 | end |
---|
1598 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
1599 | menu_field{3}='civ2'; |
---|
1600 | end |
---|
1601 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
1602 | menu_field{4}='filter2'; |
---|
1603 | end |
---|
1604 | set(handles.field_ref1,'String',menu_field); |
---|
1605 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
1606 | set(handles.num_MinVel,'Value',2); |
---|
1607 | set(handles.num_MinVel,'String','1');%default threshold |
---|
1608 | set(handles.ref_fix1,'Enable','on') |
---|
1609 | |
---|
1610 | %------------------------------------------------------------------------ |
---|
1611 | % --- Executes on button press in get_ref_fix2. |
---|
1612 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
1613 | %------------------------------------------------------------------------ |
---|
1614 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
1615 | filebase=get(handles.RootPath,'String'); |
---|
1616 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1617 | {'*.nc', ' (*.nc)'; |
---|
1618 | '*.nc', 'netcdf files '; ... |
---|
1619 | '*.*', 'All Files (*.*)'}, ... |
---|
1620 | 'Pick a file',filebase); |
---|
1621 | fileinput=[PathName FileName]; |
---|
1622 | sizf=size(fileinput); |
---|
1623 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
1624 | %[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
1625 | [Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput); |
---|
1626 | ref.filebase=fullfile(Path,File); |
---|
1627 | % ref.num_a=stra2num(str_a); |
---|
1628 | % ref.num_b=stra2num(str_b); |
---|
1629 | % ref.num1=str2num(field_count); |
---|
1630 | % ref.num2=str2num(str2); |
---|
1631 | browse=[];%initialisation |
---|
1632 | if ~isequal(ref.ext,'.nc') |
---|
1633 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
1634 | return |
---|
1635 | end |
---|
1636 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
1637 | set(handles.ref_fix2,'UserData',ref) |
---|
1638 | menu_field{1}='civ1'; |
---|
1639 | Data=nc2struct(fileinput,[]); |
---|
1640 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
1641 | menu_field{2}='filter1'; |
---|
1642 | end |
---|
1643 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
1644 | menu_field{3}='civ2'; |
---|
1645 | end |
---|
1646 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
1647 | menu_field{4}='filter2'; |
---|
1648 | end |
---|
1649 | set(handles.field_ref2,'String',menu_field); |
---|
1650 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
1651 | set(handles.num_MinVel,'Value',2); |
---|
1652 | set(handles.num_MinVel,'String','1');%default threshold |
---|
1653 | set(handles.ref_fix2,'Enable','on') |
---|
1654 | set(handles.ref_fix2,'Visible','on') |
---|
1655 | set(handles.field_ref2,'Visible','on') |
---|
1656 | else |
---|
1657 | set(handles.ref_fix2,'Visible','off') |
---|
1658 | set(handles.field_ref2,'Visible','off') |
---|
1659 | end |
---|
1660 | |
---|
1661 | %------------------------------------------------------------------------ |
---|
1662 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
1663 | %------------------------------------------------------------------------ |
---|
1664 | set(handles.num_MinVel,'Value',1); |
---|
1665 | set(handles.field_ref1,'Value',1) |
---|
1666 | set(handles.field_ref1,'String',{' '}) |
---|
1667 | set(handles.ref_fix1,'UserData',[]); |
---|
1668 | set(handles.ref_fix1,'String',''); |
---|
1669 | set(handles.thresh_vel1,'String','0'); |
---|
1670 | |
---|
1671 | %------------------------------------------------------------------------ |
---|
1672 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
1673 | %------------------------------------------------------------------------ |
---|
1674 | set(handles.num_MinVel,'Value',1); |
---|
1675 | set(handles.field_ref2,'Value',1) |
---|
1676 | set(handles.field_ref2,'String',{' '}) |
---|
1677 | set(handles.ref_fix2,'UserData',[]); |
---|
1678 | set(handles.ref_fix2,'String',''); |
---|
1679 | set(handles.num_MinVel,'String','0'); |
---|
1680 | |
---|
1681 | %------------------------------------------------------------------------ |
---|
1682 | % --- TO ABANDON Executes on button press in test_stereo1. |
---|
1683 | function CheckStereo_Callback(hObject, eventdata, handles) |
---|
1684 | %------------------------------------------------------------------------ |
---|
1685 | hparent=get(hObject,'parent'); |
---|
1686 | parent_tag=get(hparent,'Tag'); |
---|
1687 | hchildren=get(hparent,'children'); |
---|
1688 | handle_txtbox=findobj(hchildren,'tag','txt_Mask'); |
---|
1689 | if isequal(get(hObject,'Value'),0) |
---|
1690 | set(handles.num_SubDomainSize,'Visible','on') |
---|
1691 | set(handles.num_FieldSmooth,'Visible','on') |
---|
1692 | else |
---|
1693 | set(handles.num_SubDomainSize,'Visible','off') |
---|
1694 | set(handles.num_FieldSmooth,'Visible','off') |
---|
1695 | end |
---|
1696 | |
---|
1697 | % %------------------------------------------------------------------------ |
---|
1698 | % % --- Executes on button press in CheckStereo. |
---|
1699 | % function StereoCheck_Callback(hObject, eventdata, handles) |
---|
1700 | % %------------------------------------------------------------------------ |
---|
1701 | % if isequal(get(handles.CheckStereo,'Value'),0) |
---|
1702 | % set(handles.num_subdomainsize,'Visible','on') |
---|
1703 | % set(handles.num_FieldSmooth,'Visible','on') |
---|
1704 | % else |
---|
1705 | |
---|
1706 | % set(handles.num_subdomainsize,'Visible','off') |
---|
1707 | % set(handles.num_FieldSmooth,'Visible','off') |
---|
1708 | % end |
---|
1709 | |
---|
1710 | |
---|
1711 | |
---|
1712 | %------------------------------------------------------------------------ |
---|
1713 | %----function introduced for the correlation window figure, activated by deleting this window |
---|
1714 | function closeview_field(gcbo,eventdata) |
---|
1715 | %------------------------------------------------------------------------ |
---|
1716 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
1717 | if ~isempty(hview_field) |
---|
1718 | delete(hview_field) |
---|
1719 | end |
---|
1720 | |
---|
1721 | %------------------------------------------------------------------------ |
---|
1722 | % --- Executes on button press in CheckThreshold. |
---|
1723 | function CheckThreshold_Callback(hObject, eventdata, handles) |
---|
1724 | %------------------------------------------------------------------------ |
---|
1725 | huipanel=get(hObject,'parent'); |
---|
1726 | obj(1)=findobj(huipanel,'Tag','num_MinIma'); |
---|
1727 | obj(2)=findobj(huipanel,'Tag','num_MaxIma'); |
---|
1728 | obj(3)=findobj(huipanel,'Tag','title_Threshold'); |
---|
1729 | if get(hObject,'Value') |
---|
1730 | set(obj,'Visible','on') |
---|
1731 | else |
---|
1732 | set(obj,'Visible','off') |
---|
1733 | end |
---|
1734 | set(handles.configSource,'String','NEW') |
---|
1735 | set(handles.OK,'BackgroundColor',[1 0 1]) |
---|
1736 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1737 | %%%%%%%%%%%%%% TEST functions |
---|
1738 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1739 | %------------------------------------------------------------------------ |
---|
1740 | % --- Executes on button press in TestCiv1: prepare the image correlation function |
---|
1741 | % activated by mouse motion |
---|
1742 | function TestCiv1_Callback(hObject, eventdata, handles) |
---|
1743 | %------------------------------------------------------------------------ |
---|
1744 | drawnow |
---|
1745 | if get(handles.TestCiv1,'Value') |
---|
1746 | set(handles.TestCiv1,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch |
---|
1747 | %Param.Action.RUN=1; |
---|
1748 | |
---|
1749 | hseries=findobj(allchild(0),'Tag','series'); |
---|
1750 | Param=read_GUI(hseries); |
---|
1751 | Param.Action.RUN=1; |
---|
1752 | Param.ActionInput=read_GUI(handles.civ_input); |
---|
1753 | if isfield(Param,'OutputSubDir') |
---|
1754 | Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series |
---|
1755 | end |
---|
1756 | Param.ActionInput.Civ1.CorrSmooth=0;% launch Civ1 with no data point (to get the image names for A and B) |
---|
1757 | [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results |
---|
1758 | |
---|
1759 | %% create image data ImageData for display |
---|
1760 | ImageData.ListVarName={'ny','nx','A'}; |
---|
1761 | ImageData.VarDimName= {'ny','nx',{'ny','nx'}}; |
---|
1762 | ImageData.A=imread(Data.Civ1_ImageA); % read the first image |
---|
1763 | if ndims(ImageData.A)==3 %case of color image |
---|
1764 | ImageData.VarDimName= {'ny','nx',{'ny','nx','rgb'}}; |
---|
1765 | end |
---|
1766 | ImageData.ny=[size(ImageData.A,1) 1]; |
---|
1767 | ImageData.nx=[1 size(ImageData.A,2)]; |
---|
1768 | ImageData.CoordUnit='pixel';% used to set equal scaling for x and y in image dispa=ly |
---|
1769 | |
---|
1770 | %% create the figure view_field for image visualization |
---|
1771 | hview_field=view_field(ImageData); %view the image in the GUI view_field |
---|
1772 | set(0,'CurrentFigure',hview_field) |
---|
1773 | hhview_field=guihandles(hview_field); |
---|
1774 | set(hview_field,'CurrentAxes',hhview_field.PlotAxes) |
---|
1775 | ViewData=get(hview_field,'UserData'); |
---|
1776 | ViewData.CivHandle=handles.civ_input;% indicate the handle of the civ GUI in view_field |
---|
1777 | ViewData.PlotAxes.X=Data.Civ1_X'; |
---|
1778 | ViewData.PlotAxes.Y=Data.Civ1_Y'; |
---|
1779 | ViewData.PlotAxes.B=imread(Data.Civ1_ImageB);%store the second image in the UserData of the GUI view_field |
---|
1780 | set(hview_field,'UserData',ViewData)% store the info in the UserData of image view_field |
---|
1781 | |
---|
1782 | %% look for a current figure for image correlation display |
---|
1783 | corrfig=findobj(allchild(0),'tag','corrfig'); |
---|
1784 | if isempty(corrfig) |
---|
1785 | corrfig=figure; |
---|
1786 | set(corrfig,'tag','corrfig') |
---|
1787 | set(corrfig,'name','image correlation') |
---|
1788 | set(corrfig,'DeleteFcn',{@closeview_field})% |
---|
1789 | set(handles.TestCiv1,'BackgroundColor',[1 0 0]) |
---|
1790 | else |
---|
1791 | set(handles.TestCiv1,'BackgroundColor',[1 0 0])% paint button to red |
---|
1792 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
1793 | if ~isempty(corrfig) |
---|
1794 | delete(corrfig) |
---|
1795 | end |
---|
1796 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
1797 | if ~isempty(hview_field) |
---|
1798 | delete(hview_field) |
---|
1799 | end |
---|
1800 | end |
---|
1801 | else |
---|
1802 | hview_field=findobj(allchild(0),'Tag','view_field'); %view the image in the GUI view_field |
---|
1803 | if ~isempty(hview_field) |
---|
1804 | delete(hview_field) |
---|
1805 | end |
---|
1806 | end |
---|
1807 | |
---|
1808 | % -------------------------------------------------------------------- |
---|
1809 | % --- Executes on button press in TestPatch1. |
---|
1810 | % -------------------------------------------------------------------- |
---|
1811 | function TestPatch1_Callback(hObject, eventdata, handles) |
---|
1812 | |
---|
1813 | if get(handles.TestPatch1,'Value')% if TestPatch1 is activated |
---|
1814 | set(handles.TestPatch1,'BackgroundColor',[1 1 0])%paint TestPatch1 button in yellow to indicate activation |
---|
1815 | set(handles.Civ1,'BackgroundColor',[1 1 0])% indicate civ1 calculation is performed |
---|
1816 | hseries=findobj(allchild(0),'Tag','series'); |
---|
1817 | Param=read_GUI(hseries); |
---|
1818 | Param.Action.RUN=1; |
---|
1819 | Param.ActionInput=read_GUI(handles.civ_input); |
---|
1820 | if isfield(Param,'OutputSubDir') |
---|
1821 | Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series |
---|
1822 | end |
---|
1823 | ParamPatch1=Param.ActionInput.Patch1; %store the patch1 parameters |
---|
1824 | Param.ActionInput=rmfield(Param.ActionInput,'Patch1');% does not execute Patch |
---|
1825 | [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results |
---|
1826 | bckcolor=get(handles.civ_input,'Color'); |
---|
1827 | set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calculation is finished |
---|
1828 | |
---|
1829 | %% prepare Param for iterative Patch processing without input file reading |
---|
1830 | Param.Civ1_X=Data.Civ1_X; |
---|
1831 | Param.Civ1_Y=Data.Civ1_Y; |
---|
1832 | Param.Civ1_U=Data.Civ1_U; |
---|
1833 | Param.Civ1_V=Data.Civ1_V; |
---|
1834 | Param.Civ1_FF=Data.Civ1_FF; |
---|
1835 | Param=rmfield(Param,'InputTable');%desactivate input file reading |
---|
1836 | if isfield(Param.ActionInput,'Civ1') |
---|
1837 | Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant |
---|
1838 | end |
---|
1839 | if isfield(Param.ActionInput,'Fix1') |
---|
1840 | Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant |
---|
1841 | end |
---|
1842 | SmoothingParam=(ParamPatch1.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value |
---|
1843 | NbGood=numel(find(Data.Civ1_FF==0)); |
---|
1844 | NbExclude=zeros(1,7);% initialize the set of smoothing parameters |
---|
1845 | DiffVel=zeros(1,7);% initialize the rms difference between patch and civ |
---|
1846 | Param.ActionInput.Patch1=ParamPatch1;% retrieve Patch1 parameters |
---|
1847 | for irho=1:7 |
---|
1848 | Param.ActionInput.Patch1.FieldSmooth=SmoothingParam(irho); |
---|
1849 | [Data,errormsg]= civ_series(Param);%apply the processing fct |
---|
1850 | if ~isempty(errormsg) |
---|
1851 | msgbox_uvmat('ERROR',errormsg) |
---|
1852 | return |
---|
1853 | end |
---|
1854 | ind_good=find(Data.Civ1_FF==0); |
---|
1855 | Civ1_U_Diff=Data.Civ1_U(ind_good)-Data.Civ1_U_smooth(ind_good); |
---|
1856 | Civ1_V_Diff=Data.Civ1_V(ind_good)-Data.Civ1_V_smooth(ind_good); |
---|
1857 | DiffVel(irho)=sqrt(mean(Civ1_U_Diff.*Civ1_U_Diff+Civ1_V_Diff.*Civ1_V_Diff)); |
---|
1858 | NbExclude(irho)=(NbGood-numel(ind_good))/NbGood; |
---|
1859 | end |
---|
1860 | figure(1) |
---|
1861 | hold on |
---|
1862 | semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r') |
---|
1863 | grid on |
---|
1864 | legend('rms velocity diff. Patch1-Civ1 (pixels)','proportion of excluded vectors (between 0 to 1)') |
---|
1865 | xlabel('smoothing parameter') |
---|
1866 | ylabel('smoothing effect') |
---|
1867 | set(handles.TestPatch1,'BackgroundColor',[0 1 0]) |
---|
1868 | else |
---|
1869 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
1870 | if ~isempty(corrfig) |
---|
1871 | delete(corrfig) |
---|
1872 | end |
---|
1873 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
1874 | if ~isempty(hview_field) |
---|
1875 | delete(hview_field) |
---|
1876 | end |
---|
1877 | end |
---|
1878 | |
---|
1879 | %------------------------------------------------------------------------ |
---|
1880 | % --- Executes on button press in TestCiv2. |
---|
1881 | %------------------------------------------------------------------------ |
---|
1882 | function TestCiv2_Callback(hObject, eventdata, handles) |
---|
1883 | drawnow |
---|
1884 | if get(handles.TestCiv2,'Value') |
---|
1885 | set(handles.TestCiv2,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch |
---|
1886 | hseries=findobj(allchild(0),'Tag','series'); |
---|
1887 | Param=read_GUI(hseries); |
---|
1888 | Param.Action.RUN=1; |
---|
1889 | Param.ActionInput=read_GUI(handles.civ_input); |
---|
1890 | if isfield(Param,'OutputSubDir') |
---|
1891 | Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series |
---|
1892 | end |
---|
1893 | Param.ActionInput.Civ2.CorrSmooth=0;% launch Civ2 with no data point (to get the image names for A and B) |
---|
1894 | set(handles.Civ1,'BackgroundColor',[1 1 0]) |
---|
1895 | set(handles.Fix1,'BackgroundColor',[1 1 0]) |
---|
1896 | set(handles.Patch1,'BackgroundColor',[1 1 0]) |
---|
1897 | [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results |
---|
1898 | |
---|
1899 | %% create image data ImageData for display |
---|
1900 | ImageData.ListVarName={'ny','nx','A'}; |
---|
1901 | ImageData.VarDimName= {'ny','nx',{'ny','nx'}}; |
---|
1902 | ImageData.A=imread(Data.Civ2_ImageA); % read the first image |
---|
1903 | if ndims(ImageData.A)==3 %case of color image |
---|
1904 | ImageData.VarDimName= {'ny','nx',{'ny','nx','rgb'}}; |
---|
1905 | end |
---|
1906 | ImageData.ny=[size(ImageData.A,1) 1]; |
---|
1907 | ImageData.nx=[1 size(ImageData.A,2)]; |
---|
1908 | ImageData.CoordUnit='pixel';% used to set equal scaling for x and y in image dispa=ly |
---|
1909 | |
---|
1910 | %% create the figure view_field for image visualization |
---|
1911 | hview_field=view_field(ImageData); %view the image in the GUI view_field |
---|
1912 | set(0,'CurrentFigure',hview_field) |
---|
1913 | % plot the boundaries of the subdomains used for patch |
---|
1914 | for isub=1:size(Data.Civ1_SubRange,3); |
---|
1915 | pos_x=Data.Civ1_SubRange(1,1,isub); |
---|
1916 | pos_y=Data.Civ1_SubRange(2,1,isub); |
---|
1917 | width=Data.Civ1_SubRange(1,2,isub)-Data.Civ1_SubRange(1,1,isub); |
---|
1918 | height=Data.Civ1_SubRange(2,2,isub)-Data.Civ1_SubRange(2,1,isub); |
---|
1919 | rectangle('Position',[pos_x pos_y width height],'EdgeColor',[0 0 1]) |
---|
1920 | end |
---|
1921 | hhview_field=guihandles(hview_field);% |
---|
1922 | set(hview_field,'CurrentAxes',hhview_field.PlotAxes) |
---|
1923 | ViewData=get(hview_field,'UserData'); % get the currently plotted field (the image A) |
---|
1924 | % store info in the UserData of view-field |
---|
1925 | ViewData.CivHandle=handles.civ_input;% indicate the handle of the civ GUI in view_field |
---|
1926 | ViewData.PlotAxes.B=imread(Data.Civ2_ImageB);%store the second image in the UserData of the GUI view_field |
---|
1927 | ViewData.PlotAxes.X=Data.Civ2_X'; |
---|
1928 | ViewData.PlotAxes.Y=Data.Civ2_Y'; |
---|
1929 | ViewData.PlotAxes.ShiftX=Data.Civ2_U';% shift at each point (from patch1) estimated by running civ2 |
---|
1930 | ViewData.PlotAxes.ShiftY=Data.Civ2_V'; |
---|
1931 | ViewData.PlotAxes.Civ1_SubRange=Data.Civ1_SubRange; |
---|
1932 | ViewData.PlotAxes.Civ1_NbCentres=Data.Civ1_NbCentres; |
---|
1933 | ViewData.PlotAxes.Civ1_Coord_tps=Data.Civ1_Coord_tps; |
---|
1934 | ViewData.PlotAxes.Civ1_U_tps=Data.Civ1_U_tps; |
---|
1935 | ViewData.PlotAxes.Civ1_V_tps=Data.Civ1_V_tps; |
---|
1936 | ViewData.PlotAxes.Civ1_Dt=Data.Civ1_Dt; |
---|
1937 | ViewData.PlotAxes.Civ2_Dt=Data.Civ2_Dt; |
---|
1938 | set(hview_field,'UserData',ViewData)% store the info in the UserData of image view_field |
---|
1939 | bckcolor=get(handles.civ_input,'Color'); |
---|
1940 | set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calmculation is finished |
---|
1941 | set(handles.Fix1,'BackgroundColor',bckcolor) |
---|
1942 | set(handles.Patch1,'BackgroundColor',bckcolor) |
---|
1943 | drawnow |
---|
1944 | |
---|
1945 | %% look for a current figure for image correlation display |
---|
1946 | corrfig=findobj(allchild(0),'tag','corrfig'); |
---|
1947 | if isempty(corrfig) |
---|
1948 | corrfig=figure; |
---|
1949 | set(corrfig,'tag','corrfig') |
---|
1950 | set(corrfig,'name','image correlation') |
---|
1951 | set(corrfig,'DeleteFcn',{@closeview_field})% |
---|
1952 | set(handles.TestCiv1,'BackgroundColor',[1 0 0]) |
---|
1953 | else |
---|
1954 | set(handles.TestCiv1,'BackgroundColor',[1 0 0])% paint button to red |
---|
1955 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
1956 | if ~isempty(corrfig) |
---|
1957 | delete(corrfig) |
---|
1958 | end |
---|
1959 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
1960 | if ~isempty(hview_field) |
---|
1961 | delete(hview_field) |
---|
1962 | end |
---|
1963 | end |
---|
1964 | else |
---|
1965 | hview_field=findobj(allchild(0),'Tag','view_field'); %view the image in the GUI view_field |
---|
1966 | if ~isempty(hview_field) |
---|
1967 | delete(hview_field) |
---|
1968 | end |
---|
1969 | end |
---|
1970 | |
---|
1971 | |
---|
1972 | % --- Executes on button press in TestPatch2. |
---|
1973 | function TestPatch2_Callback(hObject, eventdata, handles) |
---|
1974 | if get(handles.TestPatch2,'Value')% if TestPatch2 is activated |
---|
1975 | set(handles.TestPatch2,'BackgroundColor',[1 1 0])%paint TestPatch2 button in yellow to indicate activation |
---|
1976 | set(handles.Civ1,'BackgroundColor',[1 1 0])% indicate civ1 calculation is activated |
---|
1977 | set(handles.Fix1,'BackgroundColor',[1 1 0])% indicate fix1 calculation is activated |
---|
1978 | set(handles.Patch1,'BackgroundColor',[1 1 0])% indicate Patch1 calculation is activated |
---|
1979 | set(handles.Civ2,'BackgroundColor',[1 1 0])% indicate civ2 calculation is activated |
---|
1980 | set(handles.Fix2,'BackgroundColor',[1 1 0])% indicate fix2 calculation is activated |
---|
1981 | hseries=findobj(allchild(0),'Tag','series'); |
---|
1982 | Param=read_GUI(hseries); |
---|
1983 | Param.Action.RUN=1; |
---|
1984 | Param.ActionInput=read_GUI(handles.civ_input); |
---|
1985 | if isfield(Param,'OutputSubDir') |
---|
1986 | Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series |
---|
1987 | end |
---|
1988 | ParamPatch2=Param.ActionInput.Patch2; %store the patch1 parameters |
---|
1989 | Param.ActionInput=rmfield(Param.ActionInput,'Patch2');% does not execute Patch |
---|
1990 | [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results |
---|
1991 | bckcolor=get(handles.civ_input,'Color'); |
---|
1992 | set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calculation is finished |
---|
1993 | set(handles.Fix1,'BackgroundColor',bckcolor)% indicate fix1 calculation is finished |
---|
1994 | set(handles.Patch1,'BackgroundColor',bckcolor)% indicate Patch1 calculation is finished |
---|
1995 | set(handles.Civ2,'BackgroundColor',bckcolor)% indicate civ2 calculation is finished |
---|
1996 | set(handles.Fix2,'BackgroundColor',bckcolor)% indicate fix2 calculation is finished |
---|
1997 | |
---|
1998 | %% prepare Param for iterative Patch processing without input file reading |
---|
1999 | Param.Civ2_X=Data.Civ2_X; |
---|
2000 | Param.Civ2_Y=Data.Civ2_Y; |
---|
2001 | Param.Civ2_U=Data.Civ2_U; |
---|
2002 | Param.Civ2_V=Data.Civ2_V; |
---|
2003 | Param.Civ2_FF=Data.Civ2_FF; |
---|
2004 | Param=rmfield(Param,'InputTable');%desactivate input file reading |
---|
2005 | if isfield(Param.ActionInput,'Civ1') |
---|
2006 | Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant |
---|
2007 | end |
---|
2008 | if isfield(Param.ActionInput,'Fix1') |
---|
2009 | Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant |
---|
2010 | end |
---|
2011 | if isfield(Param.ActionInput,'Patch1') |
---|
2012 | Param.ActionInput=rmfield(Param.ActionInput,'Patch1');%desactivate fix1:remove fix1 input param if relevant |
---|
2013 | end |
---|
2014 | if isfield(Param.ActionInput,'Civ2') |
---|
2015 | Param.ActionInput=rmfield(Param.ActionInput,'Civ2');%desactivate civ2: remove civ2 input param if relevant |
---|
2016 | end |
---|
2017 | if isfield(Param.ActionInput,'Fix2') |
---|
2018 | Param.ActionInput=rmfield(Param.ActionInput,'Fix2');%desactivate fix1:remove fix1 input param if relevant |
---|
2019 | end |
---|
2020 | SmoothingParam=(ParamPatch2.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value |
---|
2021 | NbGood=numel(find(Data.Civ2_FF==0)); |
---|
2022 | NbExclude=zeros(1,7);% initialize the set of smoothing parameters |
---|
2023 | DiffVel=zeros(1,7);% initialize the rms difference between patch and civ |
---|
2024 | Param.ActionInput.Patch2=ParamPatch2;% retrieve Patch2 parameters |
---|
2025 | for irho=1:7 |
---|
2026 | Param.ActionInput.Patch2.FieldSmooth=SmoothingParam(irho); |
---|
2027 | [Data,errormsg]= civ_series(Param);%apply the processing fct |
---|
2028 | if ~isempty(errormsg) |
---|
2029 | msgbox_uvmat('ERROR',errormsg) |
---|
2030 | return |
---|
2031 | end |
---|
2032 | ind_good=find(Data.Civ2_FF==0); |
---|
2033 | Civ2_U_Diff=Data.Civ2_U(ind_good)-Data.Civ2_U_smooth(ind_good); |
---|
2034 | Civ2_V_Diff=Data.Civ2_V(ind_good)-Data.Civ2_V_smooth(ind_good); |
---|
2035 | DiffVel(irho)=sqrt(mean(Civ2_U_Diff.*Civ2_U_Diff+Civ2_V_Diff.*Civ2_V_Diff)); |
---|
2036 | NbExclude(irho)=(NbGood-numel(ind_good))/NbGood; |
---|
2037 | end |
---|
2038 | figure(1) |
---|
2039 | hold on |
---|
2040 | semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r') |
---|
2041 | grid on |
---|
2042 | legend('rms velocity diff. Patch2-Civ2 (pixels)','proportion of excluded vectors (between 0 to 1)') |
---|
2043 | xlabel('smoothing parameter') |
---|
2044 | ylabel('smoothing effect') |
---|
2045 | set(handles.TestPatch2,'BackgroundColor',[0 1 0]) |
---|
2046 | else |
---|
2047 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
2048 | if ~isempty(corrfig) |
---|
2049 | delete(corrfig) |
---|
2050 | end |
---|
2051 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
2052 | if ~isempty(hview_field) |
---|
2053 | delete(hview_field) |
---|
2054 | end |
---|
2055 | end |
---|
2056 | |
---|
2057 | |
---|
2058 | %'nomtype2pair': creates nomencalture for index pairs knowing the image nomenclature |
---|
2059 | %--------------------------------------------------------------------- |
---|
2060 | function NomTypeNc=nomtype2pair(NomTypeIma,mode) |
---|
2061 | %--------------------------------------------------------------------- |
---|
2062 | % OUTPUT: |
---|
2063 | % NomTypeNc |
---|
2064 | %--------------------------------------------------------------------- |
---|
2065 | % INPUT: |
---|
2066 | % 'NomTypeIma': string defining the kind of nomenclature used for images |
---|
2067 | |
---|
2068 | NomTypeNc=NomTypeIma;%default |
---|
2069 | switch mode |
---|
2070 | case 'pair j1-j2' |
---|
2071 | if ~isempty(regexp(NomTypeIma,'a$')) |
---|
2072 | NomTypeNc=[NomTypeIma 'b']; |
---|
2073 | elseif ~isempty(regexp(NomTypeIma,'A$')) |
---|
2074 | NomTypeNc=[NomTypeIma 'B']; |
---|
2075 | else |
---|
2076 | r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
2077 | if ~isempty(r) |
---|
2078 | NomTypeNc='_1_1-2'; |
---|
2079 | end |
---|
2080 | end |
---|
2081 | case 'series(Dj)' |
---|
2082 | % r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
2083 | % if ~isempty(r) |
---|
2084 | NomTypeNc='_1_1-2'; |
---|
2085 | % end |
---|
2086 | case 'series(Di)' |
---|
2087 | r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
2088 | if ~isempty(r) |
---|
2089 | NomTypeNc='_1-2_1'; |
---|
2090 | else |
---|
2091 | NomTypeNc='_1-2'; |
---|
2092 | end |
---|
2093 | end |
---|
2094 | |
---|
2095 | |
---|
2096 | %------------------------------------------------------------------------ |
---|
2097 | % --- determine the list of index pairs of processing file |
---|
2098 | function [ind1,ind2,mode]=... |
---|
2099 | find_pair_indices(str_civ,i_series,j_series,MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j) |
---|
2100 | %------------------------------------------------------------------------ |
---|
2101 | ind1=''; |
---|
2102 | ind2=''; |
---|
2103 | r=regexp(str_civ,'^\D(?<ind>[i|j])=( -| )(?<num1>\d+)\|(?<num2>\d+)','names'); |
---|
2104 | if ~isempty(r) |
---|
2105 | mode=['D' r.ind]; |
---|
2106 | ind1=stra2num(r.num1); |
---|
2107 | ind2=stra2num(r.num2); |
---|
2108 | else |
---|
2109 | mode='burst'; |
---|
2110 | r=regexp(str_civ,'^j= (?<num1>[a-z])-(?<num2>[a-z])','names'); |
---|
2111 | if ~isempty(r) |
---|
2112 | NomTypeNc='_1ab'; |
---|
2113 | else |
---|
2114 | r=regexp(str_civ,'^j= (?<num1>[A-Z])-(?<num2>[A-Z])','names'); |
---|
2115 | if ~isempty(r) |
---|
2116 | NomTypeNc='_1AB'; |
---|
2117 | else |
---|
2118 | r=regexp(str_civ,'^j= (?<num1>\d+)-(?<num2>\d+)','names'); |
---|
2119 | if ~isempty(r) |
---|
2120 | NomTypeNc='_1_1-2'; |
---|
2121 | end |
---|
2122 | end |
---|
2123 | end |
---|
2124 | if isempty(r) |
---|
2125 | display('wrong pair mode input option') |
---|
2126 | else |
---|
2127 | ind1=stra2num(r.num1); |
---|
2128 | ind2=stra2num(r.num2); |
---|
2129 | end |
---|
2130 | end |
---|
2131 | |
---|
2132 | %------------------------------------------------------------------------ |
---|
2133 | % --- fill civ_input with the parameters retrieved from an input Civ file |
---|
2134 | %------------------------------------------------------------------------ |
---|
2135 | function fill_civ_input(Data,handles) |
---|
2136 | |
---|
2137 | %% Civ param |
---|
2138 | % lists of parameters to enter |
---|
2139 | ListParamNum={'CorrBoxSize','SearchBoxSize','SearchBoxShift','Dx','Dy','Dz','MinIma','MaxIma'};% list of numerical values (to transform in strings) |
---|
2140 | ListParamValue={'CorrSmooth','CheckGrid','CheckMask','CheckThreshold'}; |
---|
2141 | ListParamString={'Grid','Mask'}; |
---|
2142 | % CorrSmooth ?? |
---|
2143 | option={'Civ1','Civ2'}; |
---|
2144 | for ichoice=1:2 |
---|
2145 | if isfield(Data,[option{ichoice} '_CorrBoxSize']) |
---|
2146 | fill_panel(Data,handles,option{ichoice},ListParamNum,ListParamValue,ListParamString) |
---|
2147 | end |
---|
2148 | end |
---|
2149 | |
---|
2150 | %% Fix param |
---|
2151 | option={'Fix1','Fix2'}; |
---|
2152 | for ichoice=1:2 |
---|
2153 | if isfield(Data,[option{ichoice} '_CheckFmin2']) |
---|
2154 | ListParamNum={'MinVel','MaxVel','MinCorr'};% list of numerical values (to transform in strings) |
---|
2155 | ListParamValue={'CheckFmin2','CheckF3','CheckF4'}; |
---|
2156 | ListParamString={'ref_fix_1'}; |
---|
2157 | fill_panel(Data,handles,option{ichoice},ListParamNum,ListParamValue,ListParamString) |
---|
2158 | end |
---|
2159 | end |
---|
2160 | |
---|
2161 | %% Patch param |
---|
2162 | option={'Patch1','Patch2'}; |
---|
2163 | for ichoice=1:2 |
---|
2164 | if isfield(Data,[option{ichoice} '_FieldSmooth']) |
---|
2165 | ListParamNum={'FieldSmooth','MaxDiff','SubDomainSize'};% list of numerical values (to transform in strings) |
---|
2166 | ListParamValue={}; |
---|
2167 | ListParamString={}; |
---|
2168 | fill_panel(Data,handles,option{ichoice},ListParamNum,ListParamValue,ListParamString) |
---|
2169 | end |
---|
2170 | end |
---|
2171 | %------------------------------------------------------------------------ |
---|
2172 | % --- fill a panel of civ_input with the parameters retrieved from an input Civ file |
---|
2173 | %------------------------------------------------------------------------ |
---|
2174 | function fill_panel(Data,handles,panel,ListParamNum,ListParamValue,ListParamString) |
---|
2175 | children=get(handles.(panel),'children');%handles of the children of the input GUI with handle 'GUI_handle' |
---|
2176 | handles_panel=[]; |
---|
2177 | for ichild=1:numel(children) |
---|
2178 | if ~isempty(get(children(ichild),'tag')) |
---|
2179 | handles_panel.(get(children(ichild),'tag'))=children(ichild); |
---|
2180 | end |
---|
2181 | end |
---|
2182 | for ilist=1:numel(ListParamNum) |
---|
2183 | ParamName=ListParamNum{ilist}; |
---|
2184 | CivParamName=[panel '_' ParamName]; |
---|
2185 | if isfield(Data,CivParamName) |
---|
2186 | for icoord=1:numel(Data.(CivParamName)) |
---|
2187 | if numel(Data.(CivParamName))>1 |
---|
2188 | Tag=['num_' ParamName '_' num2str(icoord)]; |
---|
2189 | else |
---|
2190 | Tag=['num_' ParamName]; |
---|
2191 | end |
---|
2192 | if isfield(handles_panel,Tag) |
---|
2193 | set(handles_panel.(Tag),'String',num2str(Data.(CivParamName)(icoord))) |
---|
2194 | set(handles_panel.(Tag),'Visible','on') |
---|
2195 | end |
---|
2196 | end |
---|
2197 | end |
---|
2198 | end |
---|
2199 | for ilist=1:numel(ListParamValue) |
---|
2200 | ParamName=ListParamValue{ilist}; |
---|
2201 | CivParamName=[panel '_' ParamName]; |
---|
2202 | if strcmp(ParamName,'CorrSmooth') |
---|
2203 | ParamName=['num_' ParamName]; |
---|
2204 | end |
---|
2205 | if isfield(Data,CivParamName) |
---|
2206 | if isfield(handles_panel,ParamName) |
---|
2207 | set(handles_panel.(ParamName),'Value',Data.(CivParamName)) |
---|
2208 | end |
---|
2209 | end |
---|
2210 | end |
---|
2211 | for ilist=1:numel(ListParamString) |
---|
2212 | ParamName=ListParamString{ilist}; |
---|
2213 | CivParamName=[panel '_' ParamName]; |
---|
2214 | if isfield(Data,CivParamName) |
---|
2215 | if isfield(handles_panel,ParamName) |
---|
2216 | set(handles_panel.(ParamName),'String',Data.(CivParamName)) |
---|
2217 | end |
---|
2218 | end |
---|
2219 | end |
---|
2220 | |
---|
2221 | %------------------------------------------------------------------------ |
---|
2222 | % --- Executes on button press in ImportParam. |
---|
2223 | %------------------------------------------------------------------------ |
---|
2224 | function ImportParam_Callback(hObject, eventdata, handles) |
---|
2225 | hseries=findobj(allchild(0),'Tag','series'); |
---|
2226 | hhseries=guidata(hseries); |
---|
2227 | InputTable=get(hhseries.InputTable,'Data');% read the input file(s) table in the GUI series |
---|
2228 | oldfile=InputTable{1,1}; |
---|
2229 | if isempty(oldfile) |
---|
2230 | % use a file name stored in prefdir |
---|
2231 | dir_perso=prefdir; |
---|
2232 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
2233 | if exist(profil_perso,'file') |
---|
2234 | h=load (profil_perso); |
---|
2235 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
2236 | oldfile=h.RootPath; |
---|
2237 | end |
---|
2238 | end |
---|
2239 | end |
---|
2240 | filexml=uigetfile_uvmat('pick a xml parameter file for civ',oldfile,'.xml');% get the xml file containing processing parameters |
---|
2241 | %proceed only if a file has been introduced by the browser |
---|
2242 | if ~isempty(filexml) |
---|
2243 | Param=xml2struct(filexml);% read the input xml file as a Matlab structure |
---|
2244 | |
---|
2245 | % Param.Action.RUN=0; %desactivate the input RUN=1 |
---|
2246 | if ~isfield(Param,'InputTable')||~isfield(Param,'IndexRange') |
---|
2247 | msgbox_uvmat('ERROR','invalid config file: open a file in a folder ''/0_XML''') |
---|
2248 | return |
---|
2249 | end |
---|
2250 | check_input=0; |
---|
2251 | if isfield(Param,'ActionInput') |
---|
2252 | if isfield(Param.ActionInput,'Program')&& strcmp(Param.ActionInput.Program,'civ_series') |
---|
2253 | fill_GUI(Param.ActionInput,handles.civ_input)% fill the elements of the GUI series with the input parameters |
---|
2254 | set(handles.ConfigSource,'String',filexml) |
---|
2255 | check_input=1; |
---|
2256 | update_CivOptions(handles,0) |
---|
2257 | end |
---|
2258 | end |
---|
2259 | if ~check_input |
---|
2260 | msgbox_uvmat('ERROR','invalid config file (not for civ_series') |
---|
2261 | return |
---|
2262 | end |
---|
2263 | end |
---|
2264 | |
---|
2265 | % --- Executes on selection change in CheckCiv3. |
---|
2266 | function CheckCiv3_Callback(hObject, eventdata, handles) |
---|
2267 | |
---|
2268 | |
---|
2269 | %------------------------------------------------------------------------ |
---|
2270 | % --- Executes on key press with selection of a uicontrol |
---|
2271 | %------------------------------------------------------------------------ |
---|
2272 | function keyboard_callback(hObject,eventdata,handles) |
---|
2273 | |
---|
2274 | ListExclude={'CheckCiv1','CheckFix1','CheckPatch1','CheckCiv2','CheckFix2','CheckPatch2','ref_i'}; |
---|
2275 | if isempty(find(strcmp(get(gco,'Tag'),ListExclude),1))% if the selected uicontrol is not in the Exclude list |
---|
2276 | set(handles.ConfigSource,'String','NEW')% indicate that the configuration is new |
---|
2277 | set(handles.OK,'BackgroundColor',[1 0 1])% |
---|
2278 | drawnow |
---|
2279 | end |
---|
2280 | |
---|
2281 | |
---|
2282 | |
---|
2283 | |
---|
2284 | |
---|
2285 | |
---|