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 | %update_CivOptions(handles,0) |
---|
423 | %set(handles.ConfigSource,'String','\default') |
---|
424 | |
---|
425 | % %Param=read_GUI(handles.civ_input) |
---|
426 | % hseries=findobj(allchild(0),'Name','series');% look for the GUI series |
---|
427 | % hhseries=guidata(hseries);%handles of elements in the GUI series |
---|
428 | % SeriesData=get(hseries,'UserData');%read parameters on the GUI series |
---|
429 | % if isfield (SeriesData,'ActionInput') |
---|
430 | % SeriesData=rmfield(SeriesData,'ActionInput');% remove recorded civ parameters |
---|
431 | % end |
---|
432 | % set(hseries,'UserData',SeriesData) |
---|
433 | % %% exit the GUI and close it |
---|
434 | % %handles.output.ActionInput=rmfield(ActionInput; |
---|
435 | % guidata(hObject, handles);% Update handles structure |
---|
436 | % uiresume(handles.civ_input); |
---|
437 | % set(hhseries.ActionName,'BusyAction','cancel') |
---|
438 | % series('ActionName_Callback',hObject,eventdata,hhseries); % |
---|
439 | |
---|
440 | |
---|
441 | % ----------------------------------------------------------------------- |
---|
442 | % ----------------------------------------------------------------------- |
---|
443 | % --- Open the help html file |
---|
444 | function MenuHelp_Callback(hObject, eventdata, handles) |
---|
445 | % ----------------------------------------------------------------------- |
---|
446 | web('http://servforge.legi.grenoble-inp.fr/projects/soft-uvmat/wiki/UvmatHelp#Civ') |
---|
447 | |
---|
448 | %------------------------------------------------------------------------ |
---|
449 | % --- Executes on carriage return on the subdir checkciv1 edit window |
---|
450 | function Civ1_ImageB_Callback(hObject, eventdata, handles) |
---|
451 | %------------------------------------------------------------------------ |
---|
452 | SubDir=get(handles.Civ1_ImageB,'String'); |
---|
453 | menu_str=get(handles.ListSubdirCiv1,'String');% read the list of subdirectories for update |
---|
454 | ichoice=find(strcmp(SubDir,menu_str),1); |
---|
455 | if isempty(ichoice) |
---|
456 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
457 | else |
---|
458 | ilist=ichoice; |
---|
459 | end |
---|
460 | set(handles.ListSubdirCiv1,'Value',ilist)% select the selected subdir in the menu |
---|
461 | if get(handles.CheckCiv1,'Value')% if Civ1 is performed |
---|
462 | set(handles.Civ2_ImageA,'String',SubDir);% set by default civ2 directory the same as civ1 |
---|
463 | % set(handles.ListSubdirCiv2,'Value',ilist) |
---|
464 | else % if Civ1 data already exist |
---|
465 | errormsg=find_netcpair_civ(handles,1); %update the list of available index pairs in the new directory |
---|
466 | if ~isempty(errormsg) |
---|
467 | msgbox_uvmat('ERROR',errormsg) |
---|
468 | end |
---|
469 | end |
---|
470 | |
---|
471 | %------------------------------------------------------------------------ |
---|
472 | % --- Executes on carriage return on the SubDir checkciv1 edit window |
---|
473 | function Civ2_ImageA_Callback(hObject, eventdata, handles) |
---|
474 | %------------------------------------------------------------------------ |
---|
475 | SubDir=get(handles.Civ1_ImageB,'String'); |
---|
476 | menu_str=get(handles.ListSubdirCiv2,'String');% read the list of subdirectories for update |
---|
477 | ichoice=find(strcmp(SubDir,menu_str),1); |
---|
478 | if isempty(ichoice) |
---|
479 | ilist=numel(menu_str); %select 'new...' in the menu |
---|
480 | else |
---|
481 | ilist=ichoice; |
---|
482 | end |
---|
483 | set(handles.ListSubdirCiv2,'Value',ilist)% select the selected subdir in the menu |
---|
484 | %update the list of available pairs from netcdf files in the new directory |
---|
485 | if ~get(handles.CheckCiv2,'Value') && ~get(handles.CheckCiv1,'Value') && ~get(handles.CheckFix1,'Value') && ~get(handles.CheckPatch1,'Value') |
---|
486 | errormsg=find_netcpair_civ(handles,2); |
---|
487 | if ~isempty(errormsg) |
---|
488 | msgbox_uvmat('ERROR',errormsg) |
---|
489 | end |
---|
490 | end |
---|
491 | |
---|
492 | %------------------------------------------------------------------------ |
---|
493 | % --- Executes on button press in CheckCiv1. |
---|
494 | function CheckCiv1_Callback(hObject, eventdata, handles) |
---|
495 | %------------------------------------------------------------------------ |
---|
496 | update_CivOptions(handles,0) |
---|
497 | |
---|
498 | %------------------------------------------------------------------------ |
---|
499 | % --- Executes on button press in CheckFix1. |
---|
500 | function CheckFix1_Callback(hObject, eventdata, handles) |
---|
501 | %------------------------------------------------------------------------ |
---|
502 | update_CivOptions(handles,0) |
---|
503 | |
---|
504 | %------------------------------------------------------------------------ |
---|
505 | % --- Executes on button press in CheckPatch1. |
---|
506 | function CheckPatch1_Callback(hObject, eventdata, handles) |
---|
507 | %------------------------------------------------------------------------ |
---|
508 | update_CivOptions(handles,0) |
---|
509 | |
---|
510 | %------------------------------------------------------------------------ |
---|
511 | % --- Executes on button press in CheckCiv2. |
---|
512 | function CheckCiv2_Callback(hObject, eventdata, handles) |
---|
513 | %------------------------------------------------------------------------ |
---|
514 | update_CivOptions(handles,0) |
---|
515 | |
---|
516 | %------------------------------------------------------------------------ |
---|
517 | % --- Executes on button press in CheckFix2. |
---|
518 | function CheckFix2_Callback(hObject, eventdata, handles) |
---|
519 | %------------------------------------------------------------------------ |
---|
520 | update_CivOptions(handles,0) |
---|
521 | |
---|
522 | %------------------------------------------------------------------------ |
---|
523 | % --- Executes on button press in CheckPatch2. |
---|
524 | function CheckPatch2_Callback(hObject, eventdata, handles) |
---|
525 | %------------------------------------------------------------------------ |
---|
526 | update_CivOptions(handles,0) |
---|
527 | |
---|
528 | %------------------------------------------------------------------------ |
---|
529 | % --- activated by any checkbox controling the selection of Civ1,Fix1,Patch1,Civ2,Fix2,Patch2 |
---|
530 | function update_CivOptions(handles,opening) |
---|
531 | %------------------------------------------------------------------------ |
---|
532 | if opening>0 |
---|
533 | set(handles.CheckCiv2,'UserData',opening)% store the info on the current status of the civ processing |
---|
534 | end |
---|
535 | checkbox=zeros(1,6); |
---|
536 | checkbox(1)=get(handles.CheckCiv1,'Value'); |
---|
537 | checkbox(2)=get(handles.CheckFix1,'Value'); |
---|
538 | checkbox(3)=get(handles.CheckPatch1,'Value'); |
---|
539 | checkbox(4)=get(handles.CheckCiv2,'Value'); |
---|
540 | checkbox(5)=get(handles.CheckFix2,'Value'); |
---|
541 | checkbox(6)=get(handles.CheckPatch2,'Value'); |
---|
542 | if opening==0 |
---|
543 | errormsg=find_netcpair_civ(handles,1); % select the available netcdf files |
---|
544 | if ~isempty(errormsg) |
---|
545 | msgbox_uvmat('ERROR',errormsg) |
---|
546 | end |
---|
547 | end |
---|
548 | if max(checkbox(4:6))>0% case of civ2 pair choice needed |
---|
549 | set(handles.TitlePairCiv2,'Visible','on') |
---|
550 | set(handles.ListPairCiv2,'Visible','on') |
---|
551 | if ~opening |
---|
552 | errormsg=find_netcpair_civ(handles,2); % select the available netcdf files |
---|
553 | if ~isempty(errormsg) |
---|
554 | msgbox_uvmat('ERROR',errormsg) |
---|
555 | end |
---|
556 | end |
---|
557 | else |
---|
558 | set(handles.ListPairCiv2,'Visible','off') |
---|
559 | end |
---|
560 | if max(checkbox(1:3))==0 && get(handles.CheckCiv2,'UserData')==6,% no operation asked before Civ2 and input file ready for civ3 |
---|
561 | set(handles.CheckCiv3,'Visible','on') |
---|
562 | else |
---|
563 | set(handles.CheckCiv3,'Visible','off') |
---|
564 | end |
---|
565 | |
---|
566 | %% set the visibility of the different panels |
---|
567 | options={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; |
---|
568 | for ilist=1:length(options) |
---|
569 | if checkbox(ilist) |
---|
570 | set(handles.(options{ilist}),'Visible','on') |
---|
571 | else |
---|
572 | set(handles.(options{ilist}),'Visible','off') |
---|
573 | end |
---|
574 | end |
---|
575 | |
---|
576 | %------------------------------------------------------------------------ |
---|
577 | % --- Executes on button press in OK: processing on local computer |
---|
578 | function OK_Callback(hObject, eventdata, handles) |
---|
579 | %------------------------------------------------------------------------ |
---|
580 | |
---|
581 | ActionInput=read_GUI(handles.civ_input);% read the infos on the GUI civ_input |
---|
582 | |
---|
583 | %% correct input inconsistencies |
---|
584 | if isfield(ActionInput,'Civ1') |
---|
585 | checkeven=(mod(ActionInput.Civ1.CorrBoxSize,2)==0); |
---|
586 | ActionInput.Civ1.CorrBoxSize(checkeven)=ActionInput.Civ1.CorrBoxSize(checkeven)+1;% set correlation box sizes to odd values |
---|
587 | ActionInput.Civ1.SearchBoxSize=max(ActionInput.Civ1.SearchBoxSize,ActionInput.Civ1.CorrBoxSize+8);% insure that the search box size is large enough |
---|
588 | checkeven=(mod(ActionInput.Civ1.SearchBoxSize,2)==0); |
---|
589 | ActionInput.Civ1.SearchBoxSize(checkeven)=ActionInput.Civ1.SearchBoxSize(checkeven)+1;% set search box sizes to odd values |
---|
590 | end |
---|
591 | if isfield(ActionInput,'Civ2') |
---|
592 | checkeven=(mod(ActionInput.Civ2.CorrBoxSize,2)==0); |
---|
593 | ActionInput.Civ2.CorrBoxSize(checkeven)=ActionInput.Civ2.CorrBoxSize(checkeven)+1;% set correlation box sizes to odd values |
---|
594 | ActionInput.Civ2.SearchBoxSize=max(ActionInput.Civ2.SearchBoxSize,ActionInput.Civ2.CorrBoxSize+6); |
---|
595 | checkeven=(mod(ActionInput.Civ2.SearchBoxSize,2)==0); |
---|
596 | ActionInput.Civ2.SearchBoxSize(checkeven)=ActionInput.Civ2.SearchBoxSize(checkeven)+1;% set search box sizes to odd values |
---|
597 | end |
---|
598 | |
---|
599 | %% correct mask or grid name for Windows system (replace '\' by '/') |
---|
600 | if isfield(ActionInput,'Civ1') |
---|
601 | if isfield(ActionInput.Civ1,'Mask') |
---|
602 | ActionInput.Civ1.Mask=regexprep(ActionInput.Civ1.Mask,'\','/'); |
---|
603 | end |
---|
604 | if isfield(ActionInput.Civ1,'Grid') |
---|
605 | ActionInput.Civ1.Grid=regexprep(ActionInput.Civ1.Grid,'\','/'); |
---|
606 | end |
---|
607 | end |
---|
608 | if isfield(ActionInput,'Civ2') |
---|
609 | if isfield(ActionInput.Civ2,'Mask') |
---|
610 | ActionInput.Civ2.Mask=regexprep(ActionInput.Civ2.Mask,'\','/'); |
---|
611 | end |
---|
612 | if isfield(ActionInput.Civ2,'Grid') |
---|
613 | ActionInput.Civ2.Grid=regexprep(ActionInput.Civ2.Grid,'\','/'); |
---|
614 | end |
---|
615 | end |
---|
616 | |
---|
617 | %% exit the GUI and close it |
---|
618 | handles.output.ActionInput=ActionInput; |
---|
619 | guidata(hObject, handles);% Update handles structure |
---|
620 | uiresume(handles.civ_input); |
---|
621 | |
---|
622 | |
---|
623 | %------------------------------------------------------------------------ |
---|
624 | % --- Executes on button press in ListCompareMode. |
---|
625 | function ListCompareMode_Callback(hObject, eventdata, handles) |
---|
626 | %------------------------------------------------------------------------ |
---|
627 | ListCompareMode=get(handles.ListCompareMode,'String'); |
---|
628 | option=ListCompareMode{get(handles.ListCompareMode,'Value')}; |
---|
629 | hseries=findobj(allchild(0),'Tag','series'); |
---|
630 | SeriesData=get(hseries,'UserData'); |
---|
631 | check_nc=strcmp(SeriesData.FileType{1},'.nc'); |
---|
632 | ImageType=SeriesData.FileType(2:end); |
---|
633 | if check_nc |
---|
634 | ImageType=SeriesData.FileType(2:end); |
---|
635 | else |
---|
636 | ImageType=SeriesData.FileType; |
---|
637 | end |
---|
638 | hhseries=guidata(hseries); |
---|
639 | InputTable=get(hhseries.InputTable,'Data'); |
---|
640 | OriginIndex='off'; |
---|
641 | PairIndices='off'; |
---|
642 | DoubleInputSeries='off'; |
---|
643 | switch option |
---|
644 | case 'PIV' |
---|
645 | PairIndices='on';% needs to define index pairs for PIV |
---|
646 | |
---|
647 | case 'PIV volume' |
---|
648 | PairIndices='on';% needs to define index pairs for PIV |
---|
649 | set(handles.ListPairMode,'Value',1) |
---|
650 | set(handles.ListPairMode,'String',{'series(Di)'}) |
---|
651 | ListPairMode_Callback(hObject, eventdata, handles) |
---|
652 | case 'displacement' |
---|
653 | OriginIndex='on';%define a frame origin for displacement |
---|
654 | % case 'shift' |
---|
655 | % if numel(ImageType)==1 |
---|
656 | % fileinput=uigetfile_uvmat('pick a second file series for synchronous shift',InputTable{check_nc+1}); |
---|
657 | % if ~isempty(fileinput) |
---|
658 | % series( 'display_file_name',hhseries,fileinput,'append') |
---|
659 | % end |
---|
660 | % |
---|
661 | % |
---|
662 | % end |
---|
663 | end |
---|
664 | set(handles.num_OriginIndex,'Visible',OriginIndex) |
---|
665 | set(handles.OriginIndex_title,'Visible',OriginIndex) |
---|
666 | set(handles.PairIndices,'Visible',PairIndices) |
---|
667 | ListPairMode_Callback(hObject, eventdata, handles) |
---|
668 | |
---|
669 | |
---|
670 | |
---|
671 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
672 | % Callbacks in the uipanel Pair Indices |
---|
673 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
674 | %------------------------------------------------------------------------ |
---|
675 | % --- Executes on button press in ListPairMode. |
---|
676 | function ListPairMode_Callback(hObject, eventdata, handles) |
---|
677 | %------------------------------------------------------------------------ |
---|
678 | compare_list=get(handles.ListCompareMode,'String'); |
---|
679 | val=get(handles.ListCompareMode,'Value'); |
---|
680 | compare=compare_list{val}; |
---|
681 | if strcmp(compare,'displacement')||strcmp(compare,'shift') |
---|
682 | mode='displacement'; |
---|
683 | else |
---|
684 | mode_list=get(handles.ListPairMode,'String'); |
---|
685 | if ischar(mode_list) |
---|
686 | mode_list={mode_list}; |
---|
687 | end |
---|
688 | mode_value=get(handles.ListPairMode,'Value'); |
---|
689 | mode=mode_list{mode_value}; |
---|
690 | end |
---|
691 | % displ_num=[];%default |
---|
692 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
693 | % last_i=str2num(get(handles.last_i,'String')); |
---|
694 | CivInputData=get(handles.civ_input,'UserData'); |
---|
695 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
696 | checkframe=strcmp(TimeUnit,'frame'); |
---|
697 | time=CivInputData.Time; |
---|
698 | siztime=size(CivInputData.Time); |
---|
699 | nbfield=siztime(1)-1; |
---|
700 | nbfield2=siztime(2)-1; |
---|
701 | indchosen=1; %%first pair selected by default |
---|
702 | %displ_num used to define the indices of the civ_input pairs |
---|
703 | % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices |
---|
704 | % are relative to the reference indices ref_i and ref_j respectively. |
---|
705 | if isequal(mode,'pair j1-j2')%| isequal(mode,'st_pair j1-j2') |
---|
706 | dt=1; |
---|
707 | displ=''; |
---|
708 | index=0; |
---|
709 | numlist_a=[]; |
---|
710 | numlist_B=[]; |
---|
711 | %get all the time intervals in bursts |
---|
712 | displ_dt=1;%default |
---|
713 | nbfield2=min(nbfield2,10);%limitate the number of pairs to 10x10 |
---|
714 | for numod_a=1:nbfield2-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
715 | for numod_b=(numod_a+1):nbfield2 |
---|
716 | index=index+1; |
---|
717 | numlist_a(index)=numod_a; |
---|
718 | numlist_b(index)=numod_b; |
---|
719 | if size(time,2)>1 && ~checkframe |
---|
720 | 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 |
---|
721 | displ_dt(index)=dt(numod_a,numod_b); |
---|
722 | else |
---|
723 | displ_dt(index)=1; |
---|
724 | end |
---|
725 | end |
---|
726 | end |
---|
727 | [dtsort,indsort]=sort(displ_dt); |
---|
728 | if ~isempty(numlist_a) |
---|
729 | displ_num(1,:)=numlist_a(indsort); |
---|
730 | displ_num(2,:)=numlist_b(indsort); |
---|
731 | end |
---|
732 | displ_num(3,:)=0; |
---|
733 | displ_num(4,:)=0; |
---|
734 | enable_j(handles, 'off') |
---|
735 | elseif isequal(mode,'series(Dj)') %| isequal(mode,'st_series(Dj)') |
---|
736 | index=1:200; |
---|
737 | displ_num(1,index)=-floor(index/2); |
---|
738 | displ_num(2,index)=ceil(index/2); |
---|
739 | displ_num(3:4,index)=zeros(2,200); |
---|
740 | enable_j(handles, 'on') |
---|
741 | elseif isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)') |
---|
742 | % index=1:200; |
---|
743 | % displ_num(1:2,index)=zeros(2,200); |
---|
744 | % displ_num(3,index)=-floor(index/2); |
---|
745 | % displ_num(4,index)=ceil(index/2); |
---|
746 | enable_i(handles, 'on') |
---|
747 | if nbfield2 > 1 |
---|
748 | enable_j(handles, 'on') |
---|
749 | else |
---|
750 | enable_j(handles, 'off') |
---|
751 | end |
---|
752 | elseif isequal(mode,'displacement')%the pairs have the same indices |
---|
753 | displ_num(1,1)=0; |
---|
754 | displ_num(2,1)=0; |
---|
755 | displ_num(3,1)=0; |
---|
756 | displ_num(4,1)=0; |
---|
757 | if nbfield > 1 || nbfield==0 |
---|
758 | enable_i(handles, 'on') |
---|
759 | else |
---|
760 | enable_j(handles, 'off') |
---|
761 | end |
---|
762 | if nbfield2 > 1 |
---|
763 | enable_j(handles, 'on') |
---|
764 | else |
---|
765 | enable_j(handles, 'off') |
---|
766 | end |
---|
767 | end |
---|
768 | %set(handles.ListPairCiv1,'UserData',displ_num); |
---|
769 | errormsg=find_netcpair_civ( handles,1); |
---|
770 | if ~isempty(errormsg) |
---|
771 | msgbox_uvmat('ERROR',errormsg) |
---|
772 | end |
---|
773 | % find_netcpair_civ2(handles) |
---|
774 | |
---|
775 | function enable_i(handles, state) |
---|
776 | set(handles.itext,'Visible',state) |
---|
777 | % set(handles.MinIndex_i,'Visible',state) |
---|
778 | % set(handles.last_i,'Visible',state) |
---|
779 | % set(handles.incr_i,'Visible',state) |
---|
780 | set(handles.MaxIndex_i,'Visible',state) |
---|
781 | set(handles.ref_i,'Visible',state) |
---|
782 | |
---|
783 | function enable_j(handles, state) |
---|
784 | set(handles.jtext,'Visible',state) |
---|
785 | % set(handles.MinIndex_j,'Visible',state) |
---|
786 | % set(handles.last_j,'Visible',state) |
---|
787 | % set(handles.incr_j,'Visible',state) |
---|
788 | set(handles.MinIndex_j,'Visible',state) |
---|
789 | set(handles.MaxIndex_j,'Visible',state) |
---|
790 | set(handles.ref_j,'Visible',state) |
---|
791 | %hseries=findobj(allchild(0),'Tag','series'); |
---|
792 | %hhseries=guidata(hseries); |
---|
793 | %series('enable_j',hhseries,state); %file input with xml reading in uvmat, show the image in phys coordinates |
---|
794 | |
---|
795 | |
---|
796 | |
---|
797 | %------------------------------------------------------------------------ |
---|
798 | % --- Executes on selection change in ListPairCiv1. |
---|
799 | function ListPairCiv1_Callback(hObject, eventdata, handles) |
---|
800 | %------------------------------------------------------------------------ |
---|
801 | %reproduce by default the chosen pair in the checkciv2 menu |
---|
802 | list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs |
---|
803 | PairString=list_pair{get(handles.ListPairCiv1,'Value')}; |
---|
804 | |
---|
805 | [ind1,ind2]=... |
---|
806 | find_pair_indices(PairString); |
---|
807 | hseries=findobj(allchild(0),'Tag','series'); |
---|
808 | hhseries=guidata(hseries); |
---|
809 | set(hhseries.num_first_j,'String',num2str(ind1)); |
---|
810 | set(hhseries.num_last_j,'String',num2str(ind2)); |
---|
811 | set(hhseries.num_incr_j,'String',num2str(ind2-ind1)); |
---|
812 | set(handles.ListPairCiv2,'Value',get(handles.ListPairCiv1,'Value'))%civ2 selection the same as civ& by default |
---|
813 | |
---|
814 | |
---|
815 | %------------------------------------------------------------------------ |
---|
816 | % --- Executes on selection change in ListPairCiv2. |
---|
817 | function ListPairCiv2_Callback(hObject, eventdata, handles) |
---|
818 | %------------------------------------------------------------------------ |
---|
819 | |
---|
820 | |
---|
821 | %------------------------------------------------------------------------ |
---|
822 | function ref_i_Callback(hObject, eventdata, handles) |
---|
823 | %------------------------------------------------------------------------ |
---|
824 | mode_list=get(handles.ListPairMode,'String'); |
---|
825 | mode_value=get(handles.ListPairMode,'Value'); |
---|
826 | mode=mode_list{mode_value}; |
---|
827 | errormsg=find_netcpair_civ(handles,1);% update the menu of pairs depending on the available netcdf files |
---|
828 | if isequal(mode,'series(Di)') || ...% we do patch2 only |
---|
829 | (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) |
---|
830 | errormsg=find_netcpair_civ( handles,2); |
---|
831 | end |
---|
832 | if isempty(errormsg) |
---|
833 | set(handles.ref_i,'BackgroundColor',[1 1 1]) |
---|
834 | set(handles.ref_j,'BackgroundColor',[1 1 1]) |
---|
835 | else |
---|
836 | msgbox_uvmat('ERROR',errormsg) |
---|
837 | end |
---|
838 | |
---|
839 | function ref_i_KeyPressFcn(hObject, eventdata, handles) |
---|
840 | set(hObject,'BackgroundColor',[1 0 1]) |
---|
841 | |
---|
842 | % %------------------------------------------------------------------------ |
---|
843 | % function ref_j_Callback(hObject, eventdata, handles) |
---|
844 | % %------------------------------------------------------------------------ |
---|
845 | % mode_list=get(handles.ListPairMode,'String'); |
---|
846 | % mode_value=get(handles.ListPairMode,'Value'); |
---|
847 | % mode=mode_list{mode_value}; |
---|
848 | % errormsg=''; |
---|
849 | % if isequal(get(handles.CheckCiv1,'Value'),0)|| isequal(mode,'series(Dj)') |
---|
850 | % errormsg=find_netcpair_civ(handles,1);% update the menu of pairs depending on the available netcdf files |
---|
851 | % end |
---|
852 | % if isequal(mode,'series(Dj)') || ... |
---|
853 | % (get(handles.CheckCiv2,'Value')==0 && get(handles.CheckCiv1,'Value')==0 && get(handles.CheckFix1,'Value')==0 && get(handles.CheckPatch1,'Value')==0) |
---|
854 | % errormsg=find_netcpair_civ(handles,2); |
---|
855 | % end |
---|
856 | % if ~isempty(errormsg) |
---|
857 | % msgbox_uvmat('ERROR',errormsg) |
---|
858 | % end |
---|
859 | % |
---|
860 | % function ref_j_KeyPressFcn(hObject, eventdata, handles) |
---|
861 | % set(handles.ref_j,'BackgroundColor',[1 0 1]) |
---|
862 | %------------------------------------------------------------------------ |
---|
863 | % determine the menu for checkciv1 pairs depending on existing netcdf file at the middle of |
---|
864 | % the field series set by MinIndex_i, incr, last_i |
---|
865 | % index=1: look for pairs for civ1 |
---|
866 | % index=2: look for pairs for civ2 |
---|
867 | function errormsg=find_netcpair_civ(handles,index) |
---|
868 | %------------------------------------------------------------------------ |
---|
869 | set(gcf,'Pointer','watch')% set the mouse pointer to 'watch' (clock) |
---|
870 | |
---|
871 | %% initialisation |
---|
872 | errormsg=''; |
---|
873 | CivInputData=get(handles.civ_input,'UserData'); |
---|
874 | %browse=get(handles.RootPath,'UserData'); |
---|
875 | compare_list=get(handles.ListCompareMode,'String'); |
---|
876 | val=get(handles.ListCompareMode,'Value'); |
---|
877 | compare=compare_list{val}; |
---|
878 | if strcmp(compare,'displacement')||strcmp(compare,'shift') |
---|
879 | mode='displacement'; |
---|
880 | else |
---|
881 | mode_list=get(handles.ListPairMode,'String'); |
---|
882 | mode_value=get(handles.ListPairMode,'Value'); |
---|
883 | if isempty(mode_list) |
---|
884 | return |
---|
885 | end |
---|
886 | mode=mode_list{mode_value}; |
---|
887 | end |
---|
888 | nom_type_ima=CivInputData.NomTypeIma; |
---|
889 | |
---|
890 | %% determine nom_type_nc, nomenclature type of the .nc files: |
---|
891 | %[nom_type_nc]=nomtype2pair(nom_type_ima,mode); |
---|
892 | |
---|
893 | %% reads .nc subdirectoy and image numbers from the interface |
---|
894 | %SubDirImages=get(handles.Civ1_ImageA,'String'); |
---|
895 | %TODO: determine |
---|
896 | %subdir_civ1=[SubDirImages get(handles.Civ1_ImageB,'String')];%subdirectory subdir_civ1 for the netcdf data |
---|
897 | %subdir_civ2=[SubDirImages get(handles.Civ2_ImageA,'String')];%subdirectory subdir_civ2 for the netcdf data |
---|
898 | ref_i=str2double(get(handles.ref_i,'String')); |
---|
899 | ref_j=[]; |
---|
900 | if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') |
---|
901 | ref_j=0; |
---|
902 | elseif strcmp(get(handles.ref_j,'Visible'),'on') |
---|
903 | ref_j=str2double(get(handles.ref_j,'String')); |
---|
904 | end |
---|
905 | if isempty(ref_j) |
---|
906 | ref_j=1; |
---|
907 | end |
---|
908 | CivInputData=get(handles.civ_input,'UserData'); |
---|
909 | TimeUnit=get(handles.TimeUnit,'String'); |
---|
910 | Time=CivInputData.Time; |
---|
911 | checkframe=strcmp(TimeUnit,'frame'); |
---|
912 | |
---|
913 | %% case with no Civ1 operation, netcdf files need to exist for reading |
---|
914 | displ_pair={''}; |
---|
915 | nbpair=200;%default |
---|
916 | select=ones(size(1:nbpair));%flag for displayed pairs =1 for display |
---|
917 | nbpair=200; %default |
---|
918 | |
---|
919 | %% determine the menu display in .ListPairCiv1 |
---|
920 | switch mode |
---|
921 | case 'series(Di)' |
---|
922 | for ipair=1:nbpair |
---|
923 | if select(ipair) |
---|
924 | displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; |
---|
925 | if ~checkframe |
---|
926 | 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 |
---|
927 | 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 |
---|
928 | displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; |
---|
929 | end |
---|
930 | else |
---|
931 | dt=ipair/1000; |
---|
932 | displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(ipair)]; |
---|
933 | end |
---|
934 | else |
---|
935 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
936 | end |
---|
937 | end |
---|
938 | case 'series(Dj)' |
---|
939 | for ipair=1:nbpair |
---|
940 | if select(ipair) |
---|
941 | displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; |
---|
942 | if ~checkframe |
---|
943 | 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 |
---|
944 | 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 |
---|
945 | displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; |
---|
946 | end |
---|
947 | else |
---|
948 | dt=ipair/1000; |
---|
949 | displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; |
---|
950 | end |
---|
951 | else |
---|
952 | displ_pair{ipair}='...'; %pair not displayed in the menu |
---|
953 | end |
---|
954 | end |
---|
955 | case 'pair j1-j2'%case of pairs |
---|
956 | % MinIndex_j=CivInputData.MinIndex_j; |
---|
957 | % MaxIndex_j=min(CivInputData.MaxIndex_j,10);%limitate the number of pairs to 10x10 |
---|
958 | MinIndex_j=str2num(get(handles.MinIndex_j,'String')); |
---|
959 | MaxIndex_j=str2num(get(handles.MaxIndex_j,'String')); |
---|
960 | index_pair=0; |
---|
961 | %get all the Time intervals in bursts |
---|
962 | for numod_a=MinIndex_j:MaxIndex_j-1 %nbfield2 always >=2 for 'pair j1-j2' mode |
---|
963 | for numod_b=(numod_a+1):MaxIndex_j |
---|
964 | index_pair=index_pair+1; |
---|
965 | displ_pair{index_pair}=['j= ' num2stra(numod_a,nom_type_ima) '-' num2stra(numod_b,nom_type_ima)]; |
---|
966 | dt(index_pair)=numod_b-numod_a;%default dt |
---|
967 | if size(Time,1)>ref_i && size(Time,2)>numod_b % && ~checkframe |
---|
968 | dt(index_pair)=Time(ref_i+1,numod_b+1)-Time(ref_i+1,numod_a+1);% Time interval dt |
---|
969 | displ_pair{index_pair}=[displ_pair{index_pair} ' :dt= ' num2str(dt(index_pair)*1000)]; |
---|
970 | end |
---|
971 | end |
---|
972 | |
---|
973 | end |
---|
974 | [tild,indsort]=sort(dt); |
---|
975 | displ_pair=displ_pair(indsort); |
---|
976 | case 'displacement' |
---|
977 | displ_pair={'Di=Dj=0'}; |
---|
978 | end |
---|
979 | if index==1 |
---|
980 | set(handles.ListPairCiv1,'String',displ_pair'); |
---|
981 | end |
---|
982 | |
---|
983 | %% determine the default selection in the pair menu for Civ1 |
---|
984 | ichoice=find(select,1);% index of first selected pair |
---|
985 | if (isempty(ichoice) || ichoice < 1); ichoice=1; end; |
---|
986 | initial=get(handles.ListPairCiv1,'Value');%initial choice of pair |
---|
987 | if initial>nbpair || (numel(select)>=initial && ~isequal(select(initial),1)) |
---|
988 | set(handles.ListPairCiv1,'Value',ichoice);% first valid pair proposed by default in the menu |
---|
989 | end |
---|
990 | |
---|
991 | %% determine the default selection in the pair menu for Civ2 |
---|
992 | if strcmp(get(handles.ListPairCiv2,'Visible'),'on') |
---|
993 | initial=get(handles.ListPairCiv2,'Value'); |
---|
994 | if initial>length(displ_pair')%|~isequal(select(initial),1) |
---|
995 | if ichoice <= length(displ_pair') |
---|
996 | set(handles.ListPairCiv2,'Value',ichoice);% same pair proposed by default for civ2 |
---|
997 | else |
---|
998 | set(handles.ListPairCiv2,'Value',1);% same pair proposed by default for civ2 |
---|
999 | end |
---|
1000 | end |
---|
1001 | else |
---|
1002 | set(handles.ListPairCiv2,'Value',get(handles.ListPairCiv1,'Value'))% initiate the choice of Civ2 as a reproduction of if civ1 |
---|
1003 | end |
---|
1004 | set(handles.ListPairCiv2,'String',displ_pair'); |
---|
1005 | set(gcf,'Pointer','arrow')% Indicate that the process is finished |
---|
1006 | |
---|
1007 | |
---|
1008 | |
---|
1009 | % %------------------------------------------------------------------------ |
---|
1010 | % % call 'view_field.fig' to display the field selected in the list of 'status' |
---|
1011 | % function open_view_field(hObject, eventdata) |
---|
1012 | % %------------------------------------------------------------------------ |
---|
1013 | % list=get(hObject,'String'); |
---|
1014 | % index=get(hObject,'Value'); |
---|
1015 | % rootroot=get(hObject,'UserData'); |
---|
1016 | % filename=list{index}; |
---|
1017 | % ind_dot=strfind(filename,'...'); |
---|
1018 | % filename=filename(1:ind_dot-1); |
---|
1019 | % filename=fullfile(rootroot,filename); |
---|
1020 | % delete(get(hObject,'parent'))%delete the display figure to stop the check process |
---|
1021 | % if exist(filename,'file')%visualise the vel field if it exists |
---|
1022 | % uvmat(filename) |
---|
1023 | % set(gcbo,'Value',1) |
---|
1024 | % end |
---|
1025 | |
---|
1026 | |
---|
1027 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1028 | % Callbacks in the uipanel Reference Indices |
---|
1029 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1030 | %------------------------------------------------------------------------ |
---|
1031 | function MinIndex_i_Callback(hObject, eventdata, handles) |
---|
1032 | %------------------------------------------------------------------------ |
---|
1033 | first_i=str2double(get(handles.MinIndex_i,'String')); |
---|
1034 | set(handles.ref_i,'String', num2str(first_i))% reference index for pair dt = first index |
---|
1035 | ref_i_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
1036 | |
---|
1037 | % %------------------------------------------------------------------------ |
---|
1038 | % function MinIndex_j_Callback(hObject, eventdata, handles) |
---|
1039 | % %------------------------------------------------------------------------ |
---|
1040 | % first_j=str2num(get(handles.MinIndex_j,'String')); |
---|
1041 | % set(handles.ref_j,'String', num2str(first_j))% reference index for pair dt = first index |
---|
1042 | % ref_j_Callback(hObject, eventdata, handles)%refresh dispaly of dt for pairs (in case of non constant dt) |
---|
1043 | |
---|
1044 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1045 | % Callbacks in the uipanel Civ1 |
---|
1046 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1047 | %------------------------------------------------------------------------ |
---|
1048 | % --- Executes on button press in SearchRange: determine the search range num_SearchBoxSize_1,num_SearchBoxSize_2 |
---|
1049 | function SearchRange_Callback(hObject, eventdata, handles) |
---|
1050 | %------------------------------------------------------------------------ |
---|
1051 | %determine pair numbers |
---|
1052 | if strcmp(get(handles.num_UMin,'Visible'),'off') |
---|
1053 | set(handles.u_title,'Visible','on') |
---|
1054 | set(handles.v_title,'Visible','on') |
---|
1055 | set(handles.num_UMin,'Visible','on') |
---|
1056 | set(handles.num_UMax,'Visible','on') |
---|
1057 | set(handles.num_VMin,'Visible','on') |
---|
1058 | set(handles.num_VMax,'Visible','on') |
---|
1059 | %set(handles.CoordUnit,'Visible','on') |
---|
1060 | %set(handles.TimeUnit,'Visible','on') |
---|
1061 | %set(handles.slash_title,'Visible','on') |
---|
1062 | set(handles.min_title,'Visible','on') |
---|
1063 | set(handles.max_title,'Visible','on') |
---|
1064 | set(handles.unit_title,'Visible','on') |
---|
1065 | else |
---|
1066 | get_search_range(hObject, eventdata, handles) |
---|
1067 | end |
---|
1068 | |
---|
1069 | %------------------------------------------------------------------------ |
---|
1070 | % --- determine the search range num_SearchBoxSize_1,num_SearchBoxSize_2 and shift |
---|
1071 | function get_search_range(hObject, eventdata, handles) |
---|
1072 | %------------------------------------------------------------------------ |
---|
1073 | param_civ1=read_GUI(handles.Civ1); |
---|
1074 | umin=param_civ1.UMin; |
---|
1075 | umax=param_civ1.UMax; |
---|
1076 | vmin=param_civ1.VMin; |
---|
1077 | vmax=param_civ1.VMax; |
---|
1078 | %switch min_title and max_title in case of error |
---|
1079 | if umax<=umin |
---|
1080 | umin_old=umin; |
---|
1081 | umin=umax; |
---|
1082 | umax=umin_old; |
---|
1083 | set(handles.num_UMin,'String', num2str(umin)) |
---|
1084 | set(handles.num_UMax,'String', num2str(umax)) |
---|
1085 | end |
---|
1086 | if vmax<=vmin |
---|
1087 | vmin_old=vmin; |
---|
1088 | vmin=vmax; |
---|
1089 | vmax=vmin_old; |
---|
1090 | set(handles.num_VMin,'String', num2str(vmin)) |
---|
1091 | set(handles.num_VMax,'String', num2str(vmax)) |
---|
1092 | end |
---|
1093 | if ~(isempty(umin)||isempty(umax)||isempty(vmin)||isempty(vmax)) |
---|
1094 | % list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs |
---|
1095 | % index=get(handles.ListPairCiv1,'Value'); |
---|
1096 | % pair_string=list_pair{index}; |
---|
1097 | % time=get(handles.TimeSource,'UserData'); %get the set of times |
---|
1098 | % pxcm=get(handles.SearchRange,'UserData'); |
---|
1099 | % mode_list=get(handles.ListPairMode,'String'); |
---|
1100 | % mode_value=get(handles.ListPairMode,'Value'); |
---|
1101 | % mode=mode_list{mode_value}; |
---|
1102 | % if isequal (mode, 'series(Di)' ) |
---|
1103 | % ref_i=str2double(get(handles.ref_i,'String')); |
---|
1104 | % num1=ref_i-floor(index/2);% first image numbers |
---|
1105 | % num2=ref_i+ceil(index/2); |
---|
1106 | % num_a=1; |
---|
1107 | % num_b=1; |
---|
1108 | % elseif isequal (mode, 'series(Dj)') |
---|
1109 | % num1=1; |
---|
1110 | % num2=1; |
---|
1111 | % ref_j=str2double(get(handles.ref_j,'String')); |
---|
1112 | % num_a=ref_j-floor(index/2);% first image numbers |
---|
1113 | % num_b=ref_j+ceil(index/2); |
---|
1114 | % elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) |
---|
1115 | % ref_i=str2double(get(handles.ref_i,'String')); |
---|
1116 | % num1=ref_i; |
---|
1117 | % num2=ref_i; |
---|
1118 | % r=regexp(pair_string,'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names'); |
---|
1119 | % if isempty(r) |
---|
1120 | % r=regexp(pair_string,'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names'); |
---|
1121 | % end |
---|
1122 | % num_a=str2num(r.num1); |
---|
1123 | % num_b=str2num(r.num2); |
---|
1124 | % end |
---|
1125 | % dt=time(num2+1,num_b+1)-time(num1+1,num_a+1); |
---|
1126 | % ibx=str2double(get(handles.num_CorrBoxSize_1,'String')); |
---|
1127 | % iby=str2double(get(handles.num_CorrBoxSize_2,'String')); |
---|
1128 | % umin=dt*pxcm*umin; |
---|
1129 | % umax=dt*pxcm*umax; |
---|
1130 | % vmin=dt*pxcm*vmin; |
---|
1131 | % vmax=dt*pxcm*vmax; |
---|
1132 | shiftx=round((umin+umax)/2); |
---|
1133 | shifty=round((vmin+vmax)/2); |
---|
1134 | isx=(umax+2-shiftx)*2+param_civ1.CorrBoxSize(1); |
---|
1135 | isx=2*ceil(isx/2)+1; |
---|
1136 | isy=(vmax+2-shifty)*2+param_civ1.CorrBoxSize(2); |
---|
1137 | isy=2*ceil(isy/2)+1; |
---|
1138 | set(handles.num_SearchBoxShift_1,'String',num2str(shiftx)); |
---|
1139 | set(handles.num_SearchBoxShift_2,'String',num2str(shifty)); |
---|
1140 | set(handles.num_SearchBoxSize_1,'String',num2str(isx)); |
---|
1141 | set(handles.num_SearchBoxSize_2,'String',num2str(isy)); |
---|
1142 | end |
---|
1143 | |
---|
1144 | %------------------------------------------------------------------------ |
---|
1145 | % --- Executes on selection in menu CorrSmooth. |
---|
1146 | function num_CorrSmooth_Callback(hObject, eventdata, handles) |
---|
1147 | set(handles.configSource,'String','NEW') |
---|
1148 | set(handles.OK,'BackgroundColor',[1 0 1]) |
---|
1149 | %------------------------------------------------------------------------ |
---|
1150 | |
---|
1151 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1152 | % Callbacks in the uipanel Fix1 |
---|
1153 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1154 | %------------------------------------------------------------------------ |
---|
1155 | % % --- Executes on button press in CheckMask. |
---|
1156 | % function get_mask_fix1_Callback(hObject, eventdata, handles) |
---|
1157 | % %------------------------------------------------------------------------ |
---|
1158 | % maskval=get(handles.CheckMask,'Value'); |
---|
1159 | % if isequal(maskval,0) |
---|
1160 | % set(handles.Mask,'String','') |
---|
1161 | % else |
---|
1162 | % mask_displ='no mask'; %default |
---|
1163 | % filebase=get(handles.RootPath,'String'); |
---|
1164 | % [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
1165 | % if isequal(flag_mask,1) |
---|
1166 | % mask_displ=[num2str(nbslice) 'mask']; |
---|
1167 | % elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
1168 | % filebase_a=get(handles.RootFile_1,'String'); |
---|
1169 | % [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
1170 | % if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
1171 | % mask_displ='no mask'; |
---|
1172 | % end |
---|
1173 | % end |
---|
1174 | % if isequal(mask_displ,'no mask') |
---|
1175 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
1176 | % {'*.png', ' (*.png)'; |
---|
1177 | % '*.png', '.png files '; ... |
---|
1178 | % '*.*', 'All Files (*.*)'}, ... |
---|
1179 | % 'Pick a mask file *.png',filebase); |
---|
1180 | % mask_displ=fullfile(PathName,FileName); |
---|
1181 | % if ~exist(mask_displ,'file') |
---|
1182 | % mask_displ='no mask'; |
---|
1183 | % end |
---|
1184 | % end |
---|
1185 | % if isequal(mask_displ,'no mask') |
---|
1186 | % set(handles.CheckMask,'Value',0) |
---|
1187 | % set(handles.CheckMask,'Value',0) |
---|
1188 | % set(handles.CheckMask,'Value',0) |
---|
1189 | % else |
---|
1190 | % %set(handles.CheckMask,'Value',1) |
---|
1191 | % set(handles.CheckMask,'Value',1) |
---|
1192 | % end |
---|
1193 | % set(handles.Mask,'String',mask_displ) |
---|
1194 | % set(handles.Mask,'String',mask_displ) |
---|
1195 | % set(handles.Mask,'String',mask_displ) |
---|
1196 | % end |
---|
1197 | |
---|
1198 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1199 | % Callbacks in the uipanel Civ2 |
---|
1200 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1201 | %------------------------------------------------------------------------ |
---|
1202 | % --- Executes on button press in CheckMask: select box for mask option |
---|
1203 | function get_mask_civ2_Callback(hObject, eventdata, handles) |
---|
1204 | %------------------------------------------------------------------------ |
---|
1205 | maskval=get(handles.CheckMask,'Value'); |
---|
1206 | if isequal(maskval,0) |
---|
1207 | set(handles.Mask,'String','') |
---|
1208 | else |
---|
1209 | mask_displ='no mask'; %default |
---|
1210 | filebase=get(handles.RootPath,'String'); |
---|
1211 | [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
1212 | if isequal(flag_mask,1) |
---|
1213 | mask_displ=[num2str(nbslice) 'mask']; |
---|
1214 | elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
1215 | filebase_a=get(handles.RootFile_1,'String'); |
---|
1216 | [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
1217 | if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
1218 | mask_displ='no mask'; |
---|
1219 | end |
---|
1220 | end |
---|
1221 | if isequal(mask_displ,'no mask') |
---|
1222 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1223 | {'*.png', ' (*.png)'; |
---|
1224 | '*.png', '.png files '; ... |
---|
1225 | '*.*', 'All Files (*.*)'}, ... |
---|
1226 | 'Pick a mask file *.png',filebase); |
---|
1227 | mask_displ=fullfile(PathName,FileName); |
---|
1228 | if ~exist(mask_displ,'file') |
---|
1229 | mask_displ='no mask'; |
---|
1230 | end |
---|
1231 | end |
---|
1232 | if isequal(mask_displ,'no mask') |
---|
1233 | set(handles.CheckMask,'Value',0) |
---|
1234 | set(handles.CheckMask,'Value',0) |
---|
1235 | else |
---|
1236 | set(handles.CheckMask,'Value',1) |
---|
1237 | end |
---|
1238 | set(handles.Mask,'String',mask_displ) |
---|
1239 | end |
---|
1240 | |
---|
1241 | % %------------------------------------------------------------------------ |
---|
1242 | % % --- Executes on button press in CheckMask. |
---|
1243 | % function get_mask_fix2_Callback(hObject, eventdata, handles) |
---|
1244 | % %------------------------------------------------------------------------ |
---|
1245 | % maskval=get(handles.CheckMask,'Value'); |
---|
1246 | % if isequal(maskval,0) |
---|
1247 | % set(handles.Mask,'String','') |
---|
1248 | % else |
---|
1249 | % mask_displ='no mask'; %default |
---|
1250 | % filebase=get(handles.RootPath,'String'); |
---|
1251 | % [nbslice, flag_mask]=get_mask(filebase,handles); |
---|
1252 | % if isequal(flag_mask,1) |
---|
1253 | % mask_displ=[num2str(nbslice) 'mask']; |
---|
1254 | % elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series |
---|
1255 | % filebase_a=get(handles.RootFile_1,'String'); |
---|
1256 | % [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles); |
---|
1257 | % if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice) |
---|
1258 | % mask_displ='no mask'; |
---|
1259 | % end |
---|
1260 | % end |
---|
1261 | % if isequal(mask_displ,'no mask') |
---|
1262 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
1263 | % {'*.png', ' (*.png)'; |
---|
1264 | % '*.png', '.png files '; ... |
---|
1265 | % '*.*', 'All Files (*.*)'}, ... |
---|
1266 | % 'Pick a mask file *.png',filebase); |
---|
1267 | % mask_displ=fullfile(PathName,FileName); |
---|
1268 | % if ~exist(mask_displ,'file') |
---|
1269 | % mask_displ='no mask'; |
---|
1270 | % end |
---|
1271 | % end |
---|
1272 | % if isequal(mask_displ,'no mask') |
---|
1273 | % set(handles.CheckMask,'Value',0) |
---|
1274 | % end |
---|
1275 | % set(handles.Mask,'String',mask_displ) |
---|
1276 | % end |
---|
1277 | |
---|
1278 | %------------------------------------------------------------------------ |
---|
1279 | % --- function called to look for mask files |
---|
1280 | function [nbslice, flag_mask]=get_mask(filebase,handles) |
---|
1281 | %------------------------------------------------------------------------ |
---|
1282 | %detect mask files, images with appropriate file base |
---|
1283 | %[filebase '_' xx 'mask'], xx=nbslice |
---|
1284 | %flag_mask=1 indicates detection |
---|
1285 | |
---|
1286 | flag_mask=0;%default |
---|
1287 | nbslice=1; |
---|
1288 | |
---|
1289 | % subdir=get(handles.Civ1_ImageB,'String'); |
---|
1290 | [Path,Name]=fileparts(filebase); |
---|
1291 | if ~isdir(Path) |
---|
1292 | msgbox_uvmat('ERROR','no path for input files') |
---|
1293 | return |
---|
1294 | end |
---|
1295 | % currentdir=pwd; |
---|
1296 | % cd(Path);%move in the dir of the root name filebase |
---|
1297 | maskfiles=dir(fullfile(Path,[Name '_*mask_*.png']));%look for mask files |
---|
1298 | % cd(currentdir);%come back to the current working directory |
---|
1299 | if ~isempty(maskfiles) |
---|
1300 | % msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat') |
---|
1301 | % else |
---|
1302 | flag_mask=1; |
---|
1303 | maskname=maskfiles(1).name;% take the first mask file in the list |
---|
1304 | [Path2,Name,ext]=fileparts(maskname); |
---|
1305 | Namedouble=double(Name); |
---|
1306 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
1307 | ind_mask=findstr('mask',Name); |
---|
1308 | i=ind_mask-1; |
---|
1309 | while val(i)==0 && i>0 |
---|
1310 | i=i-1; |
---|
1311 | end |
---|
1312 | nbslice=str2double(Name(i+1:ind_mask-1)); |
---|
1313 | if ~isnan(nbslice) && Name(i)=='_' |
---|
1314 | flag_mask=1; |
---|
1315 | else |
---|
1316 | msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2]) |
---|
1317 | return |
---|
1318 | nbslice=1; |
---|
1319 | end |
---|
1320 | end |
---|
1321 | |
---|
1322 | %------------------------------------------------------------------------ |
---|
1323 | % --- function called to look for grid files |
---|
1324 | function [nbslice, flag_grid]=get_grid(filebase,handles) |
---|
1325 | %------------------------------------------------------------------------ |
---|
1326 | flag_grid=0;%default |
---|
1327 | nbslice=1; |
---|
1328 | [Path,Name]=fileparts(filebase); |
---|
1329 | currentdir=pwd; |
---|
1330 | cd(Path);%move in the dir of the root name filebase |
---|
1331 | gridfiles=dir([Name '_*grid_*.grid']);%look for grid files |
---|
1332 | cd(currentdir);%come back to the current working directory |
---|
1333 | if ~isempty(gridfiles) |
---|
1334 | flag_grid=1; |
---|
1335 | gridname=gridfiles(1).name;% take the first grid file in the list |
---|
1336 | [Path2,Name,ext]=fileparts(gridname); |
---|
1337 | Namedouble=double(Name); |
---|
1338 | val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters |
---|
1339 | ind_grid=findstr('grid',Name); |
---|
1340 | i=ind_grid-1; |
---|
1341 | while val(i)==0 && i>0 |
---|
1342 | i=i-1; |
---|
1343 | end |
---|
1344 | nbslice=str2double(Name(i+1:ind_grid-1)); |
---|
1345 | if ~isnan(nbslice) && Name(i)=='_' |
---|
1346 | flag_grid=1; |
---|
1347 | else |
---|
1348 | msgbox_uvmat('ERROR',['bad grid file ' Name ext ' found in ' Path2]) |
---|
1349 | return |
---|
1350 | nbslice=1; |
---|
1351 | end |
---|
1352 | end |
---|
1353 | |
---|
1354 | %------------------------------------------------------------------------ |
---|
1355 | % --- transform numbers to letters |
---|
1356 | function str=num2stra(num,nom_type) |
---|
1357 | %------------------------------------------------------------------------ |
---|
1358 | if isempty(nom_type) |
---|
1359 | str=''; |
---|
1360 | elseif strcmp(nom_type(end),'a') |
---|
1361 | str=char(96+num); |
---|
1362 | elseif strcmp(nom_type(end),'A') |
---|
1363 | str=char(96+num); |
---|
1364 | elseif isempty(nom_type(2:end))%a single index |
---|
1365 | str=''; |
---|
1366 | else |
---|
1367 | str=num2str(num); |
---|
1368 | end |
---|
1369 | |
---|
1370 | % %------------------------------------------------------------------------ |
---|
1371 | % % --- Executes on button press in ListSubdirCiv1. |
---|
1372 | % function ListSubdirCiv1_Callback(hObject, eventdata, handles) |
---|
1373 | % %------------------------------------------------------------------------ |
---|
1374 | % list_subdir_civ1=get(handles.ListSubdirCiv1,'String'); |
---|
1375 | % val=get(handles.ListSubdirCiv1,'Value'); |
---|
1376 | % SubDir=list_subdir_civ1{val}; |
---|
1377 | % if strcmp(SubDir,'new...') |
---|
1378 | % if get(handles.CheckCiv1,'Value') |
---|
1379 | % SubDir='CIV_INPUT'; %default subdirectory |
---|
1380 | % else |
---|
1381 | % msgbox_uvmat('ERROR','select CheckCiv1 to perform a new civ_input operation') |
---|
1382 | % return |
---|
1383 | % end |
---|
1384 | % end |
---|
1385 | % set(handles.Civ1_ImageB,'String',SubDir); |
---|
1386 | % errormsg=find_netcpair_civ(handles,1); |
---|
1387 | % if ~isempty(errormsg) |
---|
1388 | % msgbox_uvmat('ERROR',errormsg) |
---|
1389 | % end |
---|
1390 | % |
---|
1391 | %------------------------------------------------------------------------ |
---|
1392 | % % --- Executes on button press in ListSubdirCiv2. |
---|
1393 | % function ListSubdirCiv2_Callback(hObject, eventdata, handles) |
---|
1394 | % %------------------------------------------------------------------------ |
---|
1395 | % list_subdir_civ2=get(handles.ListSubdirCiv2,'String'); |
---|
1396 | % val=get(handles.ListSubdirCiv2,'Value'); |
---|
1397 | % SubDir=list_subdir_civ2{val}; |
---|
1398 | % if strcmp(SubDir,'new...') |
---|
1399 | % if get(handles.CheckCiv2,'Value') |
---|
1400 | % SubDir='CIV_INPUT'; %default subdirectory |
---|
1401 | % else |
---|
1402 | % msgbox_uvmat('ERROR','select CheckCiv2 to perform a new civ_input operation') |
---|
1403 | % return |
---|
1404 | % end |
---|
1405 | % end |
---|
1406 | % set(handles.Civ2_ImageA,'String',SubDir); |
---|
1407 | |
---|
1408 | %------------------------------------------------------------------------ |
---|
1409 | % --- Executes on button press in CheckGrid. |
---|
1410 | function CheckGrid_Callback(hObject, eventdata, handles) |
---|
1411 | %------------------------------------------------------------------------ |
---|
1412 | value=get(hObject,'Value'); |
---|
1413 | hparent=get(hObject,'parent');%handles of the parent panel |
---|
1414 | hchildren=get(hparent,'children'); |
---|
1415 | handle_txtbox=findobj(hchildren,'tag','Grid');% look for the grid name box in the same panel |
---|
1416 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
1417 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
1418 | handle_title_dx=findobj(hchildren,'tag','title_Dx'); |
---|
1419 | handle_title_dy=findobj(hchildren,'tag','title_Dy'); |
---|
1420 | testgrid=0; |
---|
1421 | filegrid=''; |
---|
1422 | if value |
---|
1423 | hseries=findobj(allchild(0),'Tag','series'); |
---|
1424 | hhseries=guidata(hseries); |
---|
1425 | InputTable=get(hhseries.InputTable,'Data'); |
---|
1426 | ind_A=1;% line index of the (first) image series |
---|
1427 | if strcmp(InputTable{1,5},'.nc'); |
---|
1428 | ind_A=2; |
---|
1429 | end |
---|
1430 | filebase=InputTable{ind_A,1}; |
---|
1431 | [nbslice, flag_grid]=get_grid(filebase,handles);% look for a grid with appropriate name |
---|
1432 | if isequal(flag_grid,1) |
---|
1433 | filegrid=[num2str(nbslice) 'grid']; |
---|
1434 | testgrid=1; |
---|
1435 | else % browse for a grid |
---|
1436 | filegrid=get(hObject,'UserData');%look for previous grid name stored as UserData |
---|
1437 | if exist(filegrid,'file') |
---|
1438 | filebase=filegrid; |
---|
1439 | end |
---|
1440 | filegrid = uigetfile_uvmat('pick a grid file .grid:',filebase,'.grid'); |
---|
1441 | set(hObject,'UserData',filegrid);%store for future use |
---|
1442 | if ~isempty(filegrid) |
---|
1443 | testgrid=1; |
---|
1444 | end |
---|
1445 | set(hObject,'UserData',filegrid);%store for future use |
---|
1446 | end |
---|
1447 | end |
---|
1448 | if testgrid |
---|
1449 | set(handle_dx,'Visible','off'); |
---|
1450 | set(handle_dy,'Visible','off'); |
---|
1451 | set(handle_title_dy,'Visible','off'); |
---|
1452 | set(handle_title_dx,'Visible','off'); |
---|
1453 | set(handle_txtbox,'Visible','on') |
---|
1454 | set(handle_txtbox,'String',filegrid) |
---|
1455 | else |
---|
1456 | set(hObject,'Value',0); |
---|
1457 | set(handle_dx,'Visible','on'); |
---|
1458 | set(handle_dy,'Visible','on'); |
---|
1459 | set(handle_title_dy,'Visible','on'); |
---|
1460 | set(handle_title_dx,'Visible','on'); |
---|
1461 | set(handle_txtbox,'Visible','off') |
---|
1462 | end |
---|
1463 | |
---|
1464 | %% if hObject is on the checkciv1 frame, duplicate action for checkciv2 frame |
---|
1465 | PanelName=get(hparent,'tag'); |
---|
1466 | if strcmp(PanelName,'Civ1') |
---|
1467 | hchildren=get(handles.Civ2,'children'); |
---|
1468 | handle_checkbox=findobj(hchildren,'tag','CheckGrid'); |
---|
1469 | handle_txtbox=findobj(hchildren,'tag','Grid'); |
---|
1470 | handle_dx=findobj(hchildren,'tag','num_Dx'); |
---|
1471 | handle_dy=findobj(hchildren,'tag','num_Dy'); |
---|
1472 | handle_title_dx=findobj(hchildren,'tag','title_Dx'); |
---|
1473 | handle_title_dy=findobj(hchildren,'tag','title_Dy'); |
---|
1474 | set(handle_checkbox,'UserData',filegrid);%store for future use |
---|
1475 | if testgrid |
---|
1476 | set(handle_checkbox,'Value',1); |
---|
1477 | set(handle_dx,'Visible','off'); |
---|
1478 | set(handle_dy,'Visible','off'); |
---|
1479 | set(handle_title_dx,'Visible','off'); |
---|
1480 | set(handle_title_dy,'Visible','off'); |
---|
1481 | set(handle_txtbox,'Visible','on') |
---|
1482 | set(handle_txtbox,'String',filegrid) |
---|
1483 | end |
---|
1484 | end |
---|
1485 | set(hObject,'BackgroundColor',[1 0 1]) |
---|
1486 | set(handles.configSource,'String','NEW') |
---|
1487 | set(handles.OK,'BackgroundColor',[1 0 1]) |
---|
1488 | %------------------------------------------------------------------------ |
---|
1489 | % --- Executes on button press in CheckMask: common to all panels (civ1, Civ2..) |
---|
1490 | function CheckMask_Callback(hObject, eventdata, handles) |
---|
1491 | %------------------------------------------------------------------------ |
---|
1492 | value=get(hObject,'Value'); |
---|
1493 | hparent=get(hObject,'parent'); |
---|
1494 | parent_tag=get(hparent,'Tag'); |
---|
1495 | hchildren=get(hparent,'children'); |
---|
1496 | handle_txtbox=findobj(hchildren,'tag','Mask');% look for the mask name box in the same panel |
---|
1497 | |
---|
1498 | testmask=0; |
---|
1499 | if value |
---|
1500 | hseries=findobj(allchild(0),'Tag','series'); |
---|
1501 | hhseries=guidata(hseries); |
---|
1502 | InputTable=get(hhseries.InputTable,'Data'); |
---|
1503 | ind_A=1;% line index of the (first) image series |
---|
1504 | if strcmp(InputTable{1,5},'.nc'); |
---|
1505 | ind_A=2; |
---|
1506 | end |
---|
1507 | [nbslice, flag_mask]=get_mask(InputTable{ind_A,1},handles);% look for a mask with appropriate name |
---|
1508 | if isequal(flag_mask,1) |
---|
1509 | filemask=[num2str(nbslice) 'mask']; |
---|
1510 | testmask=1; |
---|
1511 | else % browse for a mask |
---|
1512 | % filemask=get(hObject,'UserData');%look for previous mask name stored as UserData |
---|
1513 | % if exist(filemask,'file') |
---|
1514 | % filebase=filemask; |
---|
1515 | % end |
---|
1516 | filemask= uigetfile_uvmat('pick a mask image file:',InputTable{ind_A,1},'image'); |
---|
1517 | set(hObject,'UserData',filemask);%store for future use |
---|
1518 | if ~isempty(filemask) |
---|
1519 | testmask=1; |
---|
1520 | end |
---|
1521 | end |
---|
1522 | end |
---|
1523 | if testmask |
---|
1524 | set(handles.Mask,'Visible','on') |
---|
1525 | set(handles.Mask,'String',filemask) |
---|
1526 | set(handles.CheckMask,'Value',1) |
---|
1527 | else |
---|
1528 | set(hObject,'Value',0); |
---|
1529 | set(handle_txtbox,'Visible','off') |
---|
1530 | end |
---|
1531 | set(handles.configSource,'String','NEW') |
---|
1532 | set(handles.configSource,'BackgroundColor',[1 0 1]) |
---|
1533 | |
---|
1534 | % %------------------------------------------------------------------------ |
---|
1535 | % % --- Executes on button press in get_gridpatch1. |
---|
1536 | % function get_gridpatch1_Callback(hObject, eventdata, handles) |
---|
1537 | % %------------------------------------------------------------------------ |
---|
1538 | % filebase=get(handles.RootPath,'String'); |
---|
1539 | % [FileName, PathName, filterindex] = uigetfile( ... |
---|
1540 | % {'*.grid', ' (*.grid)'; |
---|
1541 | % '*.grid', '.grid files '; ... |
---|
1542 | % '*.*', 'All Files (*.*)'}, ... |
---|
1543 | % 'Pick a file',filebase); |
---|
1544 | % filegrid=fullfile(PathName,FileName); |
---|
1545 | % set(handles.grid_patch1,'string',filegrid); |
---|
1546 | % set(hObject,'BackgroundColor',[1 0 1]) |
---|
1547 | |
---|
1548 | %------------------------------------------------------------------------ |
---|
1549 | % --- STEREO Interp |
---|
1550 | 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) |
---|
1551 | %------------------------------------------------------------------------ |
---|
1552 | namelog=[filename_nc(1:end-3) '_stinterp.log']; |
---|
1553 | cmd=[stinterpBin ' -f1 ' filename_A_nc ' -f2 ' filename_B_nc ' -f ' filename_nc ... |
---|
1554 | ' -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 |
---|
1555 | |
---|
1556 | % %------------------------------------------------------------------------ |
---|
1557 | % %--read images and convert them to the uint16 format used for PIV |
---|
1558 | % function A=read_image(filename,type_ima,num,movieobject) |
---|
1559 | % %------------------------------------------------------------------------ |
---|
1560 | % %num is the view number needed for an avi movie |
---|
1561 | % switch type_ima |
---|
1562 | % case 'movie' |
---|
1563 | % A=read(movieobject,num); |
---|
1564 | % case 'avi' |
---|
1565 | % mov=aviread(filename,num); |
---|
1566 | % A=frame2im(mov(1)); |
---|
1567 | % case 'multimage' |
---|
1568 | % A=imread(filename,num); |
---|
1569 | % case 'image' |
---|
1570 | % A=imread(filename); |
---|
1571 | % end |
---|
1572 | % siz=size(A); |
---|
1573 | % if length(siz)==3;%color images |
---|
1574 | % A=sum(double(A),3); |
---|
1575 | % A=uint16(A); |
---|
1576 | % end |
---|
1577 | |
---|
1578 | |
---|
1579 | %------------------------------------------------------------------------ |
---|
1580 | % --- Executes on button press in get_ref_fix1. |
---|
1581 | function get_ref_fix1_Callback(hObject, eventdata, handles) |
---|
1582 | %------------------------------------------------------------------------ |
---|
1583 | filebase=get(handles.RootPath,'String'); |
---|
1584 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1585 | {'*.nc', ' (*.nc)'; |
---|
1586 | '*.nc', 'netcdf files '; ... |
---|
1587 | '*.*', 'All Files (*.*)'}, ... |
---|
1588 | 'Pick a file',filebase); |
---|
1589 | |
---|
1590 | fileinput=[PathName FileName]; |
---|
1591 | sizf=size(fileinput); |
---|
1592 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
1593 | %[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
1594 | [Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput); |
---|
1595 | ref.filebase=fullfile(Path,File); |
---|
1596 | % ref.num_a=stra2num(str_a); |
---|
1597 | % ref.num_b=stra2num(str_b); |
---|
1598 | % ref.num1=str2double(field_count); |
---|
1599 | % ref.num2=str2double(str2); |
---|
1600 | browse=[];%initialisation |
---|
1601 | if ~isequal(ref.ext,'.nc') |
---|
1602 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
1603 | return |
---|
1604 | end |
---|
1605 | set(handles.ref_fix1,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
1606 | set(handles.ref_fix1,'UserData',ref) |
---|
1607 | menu_field{1}='civ1'; |
---|
1608 | Data=nc2struct(fileinput,[]); |
---|
1609 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
1610 | menu_field{2}='filter1'; |
---|
1611 | end |
---|
1612 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
1613 | menu_field{3}='civ2'; |
---|
1614 | end |
---|
1615 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
1616 | menu_field{4}='filter2'; |
---|
1617 | end |
---|
1618 | set(handles.field_ref1,'String',menu_field); |
---|
1619 | set(handles.field_ref1,'Value',length(menu_field)); |
---|
1620 | set(handles.num_MinVel,'Value',2); |
---|
1621 | set(handles.num_MinVel,'String','1');%default threshold |
---|
1622 | set(handles.ref_fix1,'Enable','on') |
---|
1623 | |
---|
1624 | %------------------------------------------------------------------------ |
---|
1625 | % --- Executes on button press in get_ref_fix2. |
---|
1626 | function get_ref_fix2_Callback(hObject, eventdata, handles) |
---|
1627 | %------------------------------------------------------------------------ |
---|
1628 | if isequal(get(handles.get_ref_fix2,'Value'),1) |
---|
1629 | filebase=get(handles.RootPath,'String'); |
---|
1630 | [FileName, PathName, filterindex] = uigetfile( ... |
---|
1631 | {'*.nc', ' (*.nc)'; |
---|
1632 | '*.nc', 'netcdf files '; ... |
---|
1633 | '*.*', 'All Files (*.*)'}, ... |
---|
1634 | 'Pick a file',filebase); |
---|
1635 | fileinput=[PathName FileName]; |
---|
1636 | sizf=size(fileinput); |
---|
1637 | if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string |
---|
1638 | %[Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput); |
---|
1639 | [Path,ref.subdir,File,ref.num1,ref.num2,ref.num_a,ref.num_b,ref.ext,ref.nom_type]=fileparts_uvmat(fileinput); |
---|
1640 | ref.filebase=fullfile(Path,File); |
---|
1641 | % ref.num_a=stra2num(str_a); |
---|
1642 | % ref.num_b=stra2num(str_b); |
---|
1643 | % ref.num1=str2num(field_count); |
---|
1644 | % ref.num2=str2num(str2); |
---|
1645 | browse=[];%initialisation |
---|
1646 | if ~isequal(ref.ext,'.nc') |
---|
1647 | msgbox_uvmat('ERROR','the reference file must be in netcdf format (*.nc)') |
---|
1648 | return |
---|
1649 | end |
---|
1650 | set(handles.ref_fix2,'String',[fullfile(ref.subdir,File) '....nc']); |
---|
1651 | set(handles.ref_fix2,'UserData',ref) |
---|
1652 | menu_field{1}='civ1'; |
---|
1653 | Data=nc2struct(fileinput,[]); |
---|
1654 | if isfield(Data,'patch') && isequal(Data.patch,1) |
---|
1655 | menu_field{2}='filter1'; |
---|
1656 | end |
---|
1657 | if isfield(Data,'civ2') && isequal(Data.civ2,1) |
---|
1658 | menu_field{3}='civ2'; |
---|
1659 | end |
---|
1660 | if isfield(Data,'patch2') && isequal(Data.patch2,1) |
---|
1661 | menu_field{4}='filter2'; |
---|
1662 | end |
---|
1663 | set(handles.field_ref2,'String',menu_field); |
---|
1664 | set(handles.field_ref2,'Value',length(menu_field)); |
---|
1665 | set(handles.num_MinVel,'Value',2); |
---|
1666 | set(handles.num_MinVel,'String','1');%default threshold |
---|
1667 | set(handles.ref_fix2,'Enable','on') |
---|
1668 | set(handles.ref_fix2,'Visible','on') |
---|
1669 | set(handles.field_ref2,'Visible','on') |
---|
1670 | else |
---|
1671 | set(handles.ref_fix2,'Visible','off') |
---|
1672 | set(handles.field_ref2,'Visible','off') |
---|
1673 | end |
---|
1674 | |
---|
1675 | %------------------------------------------------------------------------ |
---|
1676 | function ref_fix1_Callback(hObject, eventdata, handles) |
---|
1677 | %------------------------------------------------------------------------ |
---|
1678 | set(handles.num_MinVel,'Value',1); |
---|
1679 | set(handles.field_ref1,'Value',1) |
---|
1680 | set(handles.field_ref1,'String',{' '}) |
---|
1681 | set(handles.ref_fix1,'UserData',[]); |
---|
1682 | set(handles.ref_fix1,'String',''); |
---|
1683 | set(handles.thresh_vel1,'String','0'); |
---|
1684 | |
---|
1685 | %------------------------------------------------------------------------ |
---|
1686 | function ref_fix2_Callback(hObject, eventdata, handles) |
---|
1687 | %------------------------------------------------------------------------ |
---|
1688 | set(handles.num_MinVel,'Value',1); |
---|
1689 | set(handles.field_ref2,'Value',1) |
---|
1690 | set(handles.field_ref2,'String',{' '}) |
---|
1691 | set(handles.ref_fix2,'UserData',[]); |
---|
1692 | set(handles.ref_fix2,'String',''); |
---|
1693 | set(handles.num_MinVel,'String','0'); |
---|
1694 | |
---|
1695 | %------------------------------------------------------------------------ |
---|
1696 | % --- TO ABANDON Executes on button press in test_stereo1. |
---|
1697 | function CheckStereo_Callback(hObject, eventdata, handles) |
---|
1698 | %------------------------------------------------------------------------ |
---|
1699 | hparent=get(hObject,'parent'); |
---|
1700 | parent_tag=get(hparent,'Tag'); |
---|
1701 | hchildren=get(hparent,'children'); |
---|
1702 | handle_txtbox=findobj(hchildren,'tag','txt_Mask'); |
---|
1703 | if isequal(get(hObject,'Value'),0) |
---|
1704 | set(handles.num_SubDomainSize,'Visible','on') |
---|
1705 | set(handles.num_FieldSmooth,'Visible','on') |
---|
1706 | else |
---|
1707 | set(handles.num_SubDomainSize,'Visible','off') |
---|
1708 | set(handles.num_FieldSmooth,'Visible','off') |
---|
1709 | end |
---|
1710 | |
---|
1711 | % %------------------------------------------------------------------------ |
---|
1712 | % % --- Executes on button press in CheckStereo. |
---|
1713 | % function StereoCheck_Callback(hObject, eventdata, handles) |
---|
1714 | % %------------------------------------------------------------------------ |
---|
1715 | % if isequal(get(handles.CheckStereo,'Value'),0) |
---|
1716 | % set(handles.num_subdomainsize,'Visible','on') |
---|
1717 | % set(handles.num_FieldSmooth,'Visible','on') |
---|
1718 | % else |
---|
1719 | |
---|
1720 | % set(handles.num_subdomainsize,'Visible','off') |
---|
1721 | % set(handles.num_FieldSmooth,'Visible','off') |
---|
1722 | % end |
---|
1723 | |
---|
1724 | |
---|
1725 | |
---|
1726 | %------------------------------------------------------------------------ |
---|
1727 | %----function introduced for the correlation window figure, activated by deleting this window |
---|
1728 | function closeview_field(gcbo,eventdata) |
---|
1729 | %------------------------------------------------------------------------ |
---|
1730 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
1731 | if ~isempty(hview_field) |
---|
1732 | delete(hview_field) |
---|
1733 | end |
---|
1734 | |
---|
1735 | %------------------------------------------------------------------------ |
---|
1736 | % --- Executes on button press in CheckThreshold. |
---|
1737 | function CheckThreshold_Callback(hObject, eventdata, handles) |
---|
1738 | %------------------------------------------------------------------------ |
---|
1739 | huipanel=get(hObject,'parent'); |
---|
1740 | obj(1)=findobj(huipanel,'Tag','num_MinIma'); |
---|
1741 | obj(2)=findobj(huipanel,'Tag','num_MaxIma'); |
---|
1742 | obj(3)=findobj(huipanel,'Tag','title_Threshold'); |
---|
1743 | if get(hObject,'Value') |
---|
1744 | set(obj,'Visible','on') |
---|
1745 | else |
---|
1746 | set(obj,'Visible','off') |
---|
1747 | end |
---|
1748 | set(handles.configSource,'String','NEW') |
---|
1749 | set(handles.OK,'BackgroundColor',[1 0 1]) |
---|
1750 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1751 | %%%%%%%%%%%%%% TEST functions |
---|
1752 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
1753 | %------------------------------------------------------------------------ |
---|
1754 | % --- Executes on button press in TestCiv1: prepare the image correlation function |
---|
1755 | % activated by mouse motion |
---|
1756 | function TestCiv1_Callback(hObject, eventdata, handles) |
---|
1757 | %------------------------------------------------------------------------ |
---|
1758 | drawnow |
---|
1759 | if get(handles.TestCiv1,'Value') |
---|
1760 | set(handles.TestCiv1,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch |
---|
1761 | %Param.Action.RUN=1; |
---|
1762 | Param.ActionInput=read_GUI(handles.civ_input); |
---|
1763 | par_civ=Param.ActionInput.Civ1; |
---|
1764 | [Data,ImageName_B]=get_param_civ1(handles); |
---|
1765 | |
---|
1766 | %% create the figure view_field for image visualization |
---|
1767 | hview_field=view_field(Data); %view the image in the GUI view_field |
---|
1768 | set(0,'CurrentFigure',hview_field) |
---|
1769 | hhview_field=guihandles(hview_field); |
---|
1770 | set(hview_field,'CurrentAxes',hhview_field.PlotAxes) |
---|
1771 | ViewData=get(hview_field,'UserData'); |
---|
1772 | ViewData.CivHandle=handles.civ_input;% indicate the handle of the civ GUI in view_field |
---|
1773 | ViewData.PlotAxes.B=imread(ImageName_B);%store the second image in the UserData of the GUI view_field |
---|
1774 | |
---|
1775 | %% prepare measurement grid |
---|
1776 | if isfield(par_civ,'Grid')% grid points set as input |
---|
1777 | par_civ.Grid=dlmread(par_civ.Grid); |
---|
1778 | par_civ.Grid(1,:)=[];%the first line must be removed (heading in the grid file) |
---|
1779 | else% automatic grid |
---|
1780 | minix=floor(par_civ.Dx/2)-0.5; |
---|
1781 | maxix=minix+par_civ.Dx*floor((size(Data.A,2)-1)/par_civ.Dx); |
---|
1782 | miniy=floor(par_civ.Dy/2)-0.5; |
---|
1783 | maxiy=minix+par_civ.Dy*floor((size(Data.A,1)-1)/par_civ.Dy); |
---|
1784 | [GridX,GridY]=meshgrid(minix:par_civ.Dx:maxix,miniy:par_civ.Dy:maxiy); |
---|
1785 | ViewData.PlotAxes.X=reshape(GridX,[],1); |
---|
1786 | ViewData.PlotAxes.Y=reshape(GridY,[],1); |
---|
1787 | end |
---|
1788 | |
---|
1789 | set(hview_field,'UserData',ViewData)% store the info in the UserData of image view_field |
---|
1790 | |
---|
1791 | %% look for a current figure for image correlation display |
---|
1792 | corrfig=findobj(allchild(0),'tag','corrfig'); |
---|
1793 | if isempty(corrfig) |
---|
1794 | corrfig=figure; |
---|
1795 | set(corrfig,'tag','corrfig') |
---|
1796 | set(corrfig,'name','image correlation') |
---|
1797 | set(corrfig,'DeleteFcn',{@closeview_field})% |
---|
1798 | set(handles.TestCiv1,'BackgroundColor',[1 0 0]) |
---|
1799 | else |
---|
1800 | set(handles.TestCiv1,'BackgroundColor',[1 0 0])% paint button to red |
---|
1801 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
1802 | if ~isempty(corrfig) |
---|
1803 | delete(corrfig) |
---|
1804 | end |
---|
1805 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
1806 | if ~isempty(hview_field) |
---|
1807 | delete(hview_field) |
---|
1808 | end |
---|
1809 | end |
---|
1810 | else |
---|
1811 | hview_field=findobj(allchild(0),'Tag','view_field'); %view the image in the GUI view_field |
---|
1812 | if ~isempty(hview_field) |
---|
1813 | delete(hview_field) |
---|
1814 | end |
---|
1815 | end |
---|
1816 | |
---|
1817 | % -------------------------------------------------------------------- |
---|
1818 | % --- Executes on button press in TestPatch1. |
---|
1819 | % -------------------------------------------------------------------- |
---|
1820 | function TestPatch1_Callback(hObject, eventdata, handles) |
---|
1821 | |
---|
1822 | if get(handles.TestPatch1,'Value')% if TestPatch1 is activated |
---|
1823 | set(handles.TestPatch1,'BackgroundColor',[1 1 0])%paint TestPatch1 button in yellow to induicate activation |
---|
1824 | hseries=findobj(allchild(0),'Tag','series'); |
---|
1825 | Param=read_GUI(hseries); |
---|
1826 | Param.Action.RUN=1; |
---|
1827 | Param.ActionInput=read_GUI(handles.civ_input); |
---|
1828 | Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series |
---|
1829 | [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results |
---|
1830 | |
---|
1831 | %% prepare Param for iterative Patch processing without input file reading |
---|
1832 | Param.Civ1_X=Data.Civ1_X; |
---|
1833 | Param.Civ1_Y=Data.Civ1_Y; |
---|
1834 | Param.Civ1_U=Data.Civ1_U; |
---|
1835 | Param.Civ1_V=Data.Civ1_V; |
---|
1836 | Param.Civ1_FF=Data.Civ1_FF; |
---|
1837 | Param=rmfield(Param,'InputTable');%desactivate input file reading |
---|
1838 | if isfield(Param.ActionInput,'Civ1') |
---|
1839 | Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant |
---|
1840 | end |
---|
1841 | if isfield(Param.ActionInput,'Fix1') |
---|
1842 | Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant |
---|
1843 | end |
---|
1844 | SmoothingParam=(Param.ActionInput.Patch1.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value |
---|
1845 | NbGood=numel(find(Data.Civ1_FF==0)); |
---|
1846 | for irho=1:7 |
---|
1847 | Param.ActionInput.Patch1.FieldSmooth=SmoothingParam(irho); |
---|
1848 | [Data,errormsg]= civ_series(Param);%apply the processing fct |
---|
1849 | if ~isempty(errormsg) |
---|
1850 | msgbox_uvmat('ERROR',errormsg) |
---|
1851 | return |
---|
1852 | end |
---|
1853 | ind_good=find(Data.Civ1_FF==0); |
---|
1854 | Civ1_U_Diff=Data.Civ1_U(ind_good)-Data.Civ1_U_smooth(ind_good); |
---|
1855 | Civ1_V_Diff=Data.Civ1_V(ind_good)-Data.Civ1_V_smooth(ind_good); |
---|
1856 | DiffVel(irho)=sqrt(mean(Civ1_U_Diff.*Civ1_U_Diff+Civ1_V_Diff.*Civ1_V_Diff)); |
---|
1857 | NbExclude(irho)=(NbGood-numel(ind_good))/NbGood; |
---|
1858 | end |
---|
1859 | figure |
---|
1860 | semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r') |
---|
1861 | grid on |
---|
1862 | legend('rms velocity diff. Patch1-Civ1 (pixels)','proportion of excluded vectors (between 0 to 1)') |
---|
1863 | xlabel('smoothing parameter') |
---|
1864 | ylabel('smoothing effect') |
---|
1865 | set(handles.TestPatch1,'BackgroundColor',[1 0 0]) |
---|
1866 | else |
---|
1867 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
1868 | if ~isempty(corrfig) |
---|
1869 | delete(corrfig) |
---|
1870 | end |
---|
1871 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
1872 | if ~isempty(hview_field) |
---|
1873 | delete(hview_field) |
---|
1874 | end |
---|
1875 | end |
---|
1876 | |
---|
1877 | %------------------------------------------------------------------------ |
---|
1878 | % --- Executes on button press in TestCiv2. |
---|
1879 | %------------------------------------------------------------------------ |
---|
1880 | function TestCiv2_Callback(hObject, eventdata, handles) |
---|
1881 | drawnow |
---|
1882 | if get(handles.TestCiv2,'Value') |
---|
1883 | set(handles.TestCiv2,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch |
---|
1884 | hseries=findobj(allchild(0),'Tag','series'); |
---|
1885 | Param=read_GUI(hseries); |
---|
1886 | Param.Action.RUN=1; |
---|
1887 | Param.ActionInput=read_GUI(handles.civ_input); |
---|
1888 | Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series |
---|
1889 | Param.ActionInput.Civ2.SmoothParam=0;% launch Civ2 with no data point (to get the image names for A and B) |
---|
1890 | [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results |
---|
1891 | |
---|
1892 | %% create image data ImageData for display |
---|
1893 | ImageData.ListVarName={'ny','nx','A'}; |
---|
1894 | ImageData.VarDimName= {'ny','nx',{'ny','nx'}}; |
---|
1895 | ImageData.A=imread(Data.Civ2_ImageA); % read the first image |
---|
1896 | if ndims(ImageData.A)==3 %case of color image |
---|
1897 | ImageData.VarDimName= {'ny','nx',{'ny','nx','rgb'}}; |
---|
1898 | end |
---|
1899 | ImageData.ny=[size(ImageData.A,1) 1]; |
---|
1900 | ImageData.nx=[1 size(ImageData.A,2)]; |
---|
1901 | ImageData.CoordUnit='pixel';% used to set equal scaling for x and y in image dispa=ly |
---|
1902 | |
---|
1903 | %% create the figure view_field for image visualization |
---|
1904 | hview_field=view_field(ImageData); %view the image in the GUI view_field |
---|
1905 | set(0,'CurrentFigure',hview_field) |
---|
1906 | RectCentre=squeeze(mean(Data.Civ1_SubRange,2)); |
---|
1907 | for isub=1:size(Data.Civ1_SubRange,3); |
---|
1908 | pos_x=Data.Civ1_SubRange(1,1,isub); |
---|
1909 | pos_y=Data.Civ1_SubRange(2,1,isub); |
---|
1910 | width=Data.Civ1_SubRange(1,2,isub)-Data.Civ1_SubRange(1,1,isub); |
---|
1911 | height=Data.Civ1_SubRange(2,2,isub)-Data.Civ1_SubRange(2,1,isub); |
---|
1912 | rectangle('Position',[pos_x pos_y width height],'EdgeColor',[0 0 1]) |
---|
1913 | end |
---|
1914 | hhview_field=guihandles(hview_field); |
---|
1915 | set(hview_field,'CurrentAxes',hhview_field.PlotAxes) |
---|
1916 | ViewData=get(hview_field,'UserData'); |
---|
1917 | ViewData.CivHandle=handles.civ_input;% indicate the handle of the civ GUI in view_field |
---|
1918 | ViewData.PlotAxes.B=imread(Data.Civ2_ImageB);%store the second image in the UserData of the GUI view_field |
---|
1919 | ViewData.PlotAxes.X=Data.Civ2_X'; |
---|
1920 | ViewData.PlotAxes.Y=Data.Civ2_Y'; |
---|
1921 | ViewData.PlotAxes.ShiftX=Data.Civ2_U'; |
---|
1922 | ViewData.PlotAxes.ShiftY=Data.Civ2_V'; |
---|
1923 | ViewData.PlotAxes.Civ1_SubRange=Data.Civ1_SubRange; |
---|
1924 | ViewData.PlotAxes.Civ1_NbCentres=Data.Civ1_NbCentres; |
---|
1925 | ViewData.PlotAxes.Civ1_Coord_tps=Data.Civ1_Coord_tps; |
---|
1926 | ViewData.PlotAxes.Civ1_U_tps=Data.Civ1_U_tps; |
---|
1927 | ViewData.PlotAxes.Civ1_V_tps=Data.Civ1_V_tps; |
---|
1928 | ViewData.PlotAxes.Civ1_Dt=Data.Civ1_Dt; |
---|
1929 | set(hview_field,'UserData',ViewData)% store the info in the UserData of image view_field |
---|
1930 | |
---|
1931 | %% look for a current figure for image correlation display |
---|
1932 | corrfig=findobj(allchild(0),'tag','corrfig'); |
---|
1933 | if isempty(corrfig) |
---|
1934 | corrfig=figure; |
---|
1935 | set(corrfig,'tag','corrfig') |
---|
1936 | set(corrfig,'name','image correlation') |
---|
1937 | set(corrfig,'DeleteFcn',{@closeview_field})% |
---|
1938 | set(handles.TestCiv1,'BackgroundColor',[1 0 0]) |
---|
1939 | else |
---|
1940 | set(handles.TestCiv1,'BackgroundColor',[1 0 0])% paint button to red |
---|
1941 | corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display |
---|
1942 | if ~isempty(corrfig) |
---|
1943 | delete(corrfig) |
---|
1944 | end |
---|
1945 | hview_field=findobj(allchild(0),'tag','view_field');% look for view_field |
---|
1946 | if ~isempty(hview_field) |
---|
1947 | delete(hview_field) |
---|
1948 | end |
---|
1949 | end |
---|
1950 | else |
---|
1951 | hview_field=findobj(allchild(0),'Tag','view_field'); %view the image in the GUI view_field |
---|
1952 | if ~isempty(hview_field) |
---|
1953 | delete(hview_field) |
---|
1954 | end |
---|
1955 | end |
---|
1956 | |
---|
1957 | |
---|
1958 | %'nomtype2pair': creates nomencalture for index pairs knowing the image nomenclature |
---|
1959 | %--------------------------------------------------------------------- |
---|
1960 | function NomTypeNc=nomtype2pair(NomTypeIma,mode) |
---|
1961 | %--------------------------------------------------------------------- |
---|
1962 | % OUTPUT: |
---|
1963 | % NomTypeNc |
---|
1964 | %--------------------------------------------------------------------- |
---|
1965 | % INPUT: |
---|
1966 | % 'NomTypeIma': string defining the kind of nomenclature used for images |
---|
1967 | |
---|
1968 | NomTypeNc=NomTypeIma;%default |
---|
1969 | switch mode |
---|
1970 | case 'pair j1-j2' |
---|
1971 | if ~isempty(regexp(NomTypeIma,'a$')) |
---|
1972 | NomTypeNc=[NomTypeIma 'b']; |
---|
1973 | elseif ~isempty(regexp(NomTypeIma,'A$')) |
---|
1974 | NomTypeNc=[NomTypeIma 'B']; |
---|
1975 | else |
---|
1976 | r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
1977 | if ~isempty(r) |
---|
1978 | NomTypeNc='_1_1-2'; |
---|
1979 | end |
---|
1980 | end |
---|
1981 | case 'series(Dj)' |
---|
1982 | % r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
1983 | % if ~isempty(r) |
---|
1984 | NomTypeNc='_1_1-2'; |
---|
1985 | % end |
---|
1986 | case 'series(Di)' |
---|
1987 | r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); |
---|
1988 | if ~isempty(r) |
---|
1989 | NomTypeNc='_1-2_1'; |
---|
1990 | else |
---|
1991 | NomTypeNc='_1-2'; |
---|
1992 | end |
---|
1993 | end |
---|
1994 | |
---|
1995 | |
---|
1996 | %------------------------------------------------------------------------ |
---|
1997 | % --- determine the list of index pairs of processing file |
---|
1998 | function [ind1,ind2,mode]=... |
---|
1999 | find_pair_indices(str_civ,i_series,j_series,MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j) |
---|
2000 | %------------------------------------------------------------------------ |
---|
2001 | ind1=''; |
---|
2002 | ind2=''; |
---|
2003 | r=regexp(str_civ,'^\D(?<ind>[i|j])=( -| )(?<num1>\d+)\|(?<num2>\d+)','names'); |
---|
2004 | if ~isempty(r) |
---|
2005 | mode=['D' r.ind]; |
---|
2006 | ind1=stra2num(r.num1); |
---|
2007 | ind2=stra2num(r.num2); |
---|
2008 | else |
---|
2009 | mode='burst'; |
---|
2010 | r=regexp(str_civ,'^j= (?<num1>[a-z])-(?<num2>[a-z])','names'); |
---|
2011 | if ~isempty(r) |
---|
2012 | NomTypeNc='_1ab'; |
---|
2013 | else |
---|
2014 | r=regexp(str_civ,'^j= (?<num1>[A-Z])-(?<num2>[A-Z])','names'); |
---|
2015 | if ~isempty(r) |
---|
2016 | NomTypeNc='_1AB'; |
---|
2017 | else |
---|
2018 | r=regexp(str_civ,'^j= (?<num1>\d+)-(?<num2>\d+)','names'); |
---|
2019 | if ~isempty(r) |
---|
2020 | NomTypeNc='_1_1-2'; |
---|
2021 | end |
---|
2022 | end |
---|
2023 | end |
---|
2024 | if isempty(r) |
---|
2025 | display('wrong pair mode input option') |
---|
2026 | else |
---|
2027 | ind1=stra2num(r.num1); |
---|
2028 | ind2=stra2num(r.num2); |
---|
2029 | end |
---|
2030 | end |
---|
2031 | |
---|
2032 | %------------------------------------------------------------------------ |
---|
2033 | % --- fill civ_input with the parameters retrieved from an input Civ file |
---|
2034 | %------------------------------------------------------------------------ |
---|
2035 | function fill_civ_input(Data,handles) |
---|
2036 | |
---|
2037 | %% Civ param |
---|
2038 | % lists of parameters to enter |
---|
2039 | ListParamNum={'CorrBoxSize','SearchBoxSize','SearchBoxShift','Dx','Dy','Dz','MinIma','MaxIma'};% list of numerical values (to transform in strings) |
---|
2040 | ListParamValue={'CorrSmooth','CheckGrid','CheckMask','CheckThreshold'}; |
---|
2041 | ListParamString={'Grid','Mask'}; |
---|
2042 | % CorrSmooth ?? |
---|
2043 | option={'Civ1','Civ2'}; |
---|
2044 | for ichoice=1:2 |
---|
2045 | if isfield(Data,[option{ichoice} '_CorrBoxSize']) |
---|
2046 | fill_panel(Data,handles,option{ichoice},ListParamNum,ListParamValue,ListParamString) |
---|
2047 | end |
---|
2048 | end |
---|
2049 | |
---|
2050 | %% Fix param |
---|
2051 | option={'Fix1','Fix2'}; |
---|
2052 | for ichoice=1:2 |
---|
2053 | if isfield(Data,[option{ichoice} '_CheckFmin2']) |
---|
2054 | ListParamNum={'MinVel','MaxVel','MinCorr'};% list of numerical values (to transform in strings) |
---|
2055 | ListParamValue={'CheckFmin2','CheckF3','CheckF4'}; |
---|
2056 | ListParamString={'ref_fix_1'}; |
---|
2057 | fill_panel(Data,handles,option{ichoice},ListParamNum,ListParamValue,ListParamString) |
---|
2058 | end |
---|
2059 | end |
---|
2060 | |
---|
2061 | %% Patch param |
---|
2062 | option={'Patch1','Patch2'}; |
---|
2063 | for ichoice=1:2 |
---|
2064 | if isfield(Data,[option{ichoice} '_FieldSmooth']) |
---|
2065 | ListParamNum={'FieldSmooth','MaxDiff','SubDomainSize'};% list of numerical values (to transform in strings) |
---|
2066 | ListParamValue={}; |
---|
2067 | ListParamString={}; |
---|
2068 | fill_panel(Data,handles,option{ichoice},ListParamNum,ListParamValue,ListParamString) |
---|
2069 | end |
---|
2070 | end |
---|
2071 | %------------------------------------------------------------------------ |
---|
2072 | % --- fill a panel of civ_input with the parameters retrieved from an input Civ file |
---|
2073 | %------------------------------------------------------------------------ |
---|
2074 | function fill_panel(Data,handles,panel,ListParamNum,ListParamValue,ListParamString) |
---|
2075 | children=get(handles.(panel),'children');%handles of the children of the input GUI with handle 'GUI_handle' |
---|
2076 | handles_panel=[]; |
---|
2077 | for ichild=1:numel(children) |
---|
2078 | if ~isempty(get(children(ichild),'tag')) |
---|
2079 | handles_panel.(get(children(ichild),'tag'))=children(ichild); |
---|
2080 | end |
---|
2081 | end |
---|
2082 | for ilist=1:numel(ListParamNum) |
---|
2083 | ParamName=ListParamNum{ilist}; |
---|
2084 | CivParamName=[panel '_' ParamName]; |
---|
2085 | if isfield(Data,CivParamName) |
---|
2086 | for icoord=1:numel(Data.(CivParamName)) |
---|
2087 | if numel(Data.(CivParamName))>1 |
---|
2088 | Tag=['num_' ParamName '_' num2str(icoord)]; |
---|
2089 | else |
---|
2090 | Tag=['num_' ParamName]; |
---|
2091 | end |
---|
2092 | if isfield(handles_panel,Tag) |
---|
2093 | set(handles_panel.(Tag),'String',num2str(Data.(CivParamName)(icoord))) |
---|
2094 | set(handles_panel.(Tag),'Visible','on') |
---|
2095 | end |
---|
2096 | end |
---|
2097 | end |
---|
2098 | end |
---|
2099 | for ilist=1:numel(ListParamValue) |
---|
2100 | ParamName=ListParamValue{ilist}; |
---|
2101 | CivParamName=[panel '_' ParamName]; |
---|
2102 | if strcmp(ParamName,'CorrSmooth') |
---|
2103 | ParamName=['num_' ParamName]; |
---|
2104 | end |
---|
2105 | if isfield(Data,CivParamName) |
---|
2106 | if isfield(handles_panel,ParamName) |
---|
2107 | set(handles_panel.(ParamName),'Value',Data.(CivParamName)) |
---|
2108 | end |
---|
2109 | end |
---|
2110 | end |
---|
2111 | for ilist=1:numel(ListParamString) |
---|
2112 | ParamName=ListParamString{ilist}; |
---|
2113 | CivParamName=[panel '_' ParamName]; |
---|
2114 | if isfield(Data,CivParamName) |
---|
2115 | if isfield(handles_panel,ParamName) |
---|
2116 | set(handles_panel.(ParamName),'String',Data.(CivParamName)) |
---|
2117 | end |
---|
2118 | end |
---|
2119 | end |
---|
2120 | |
---|
2121 | |
---|
2122 | %------------------------------------------------------------------------ |
---|
2123 | function [Data,ImageName_B]=get_param_civ1(handles) |
---|
2124 | |
---|
2125 | ref_i=str2double(get(handles.ref_i,'String'));% read reference i index |
---|
2126 | if strcmp(get(handles.ref_j,'Visible'),'on') |
---|
2127 | ref_j=str2double(get(handles.ref_j,'String'));% read reference j index if relevant |
---|
2128 | else |
---|
2129 | ref_j=1;%default j index |
---|
2130 | end |
---|
2131 | Data.ListVarName={'ny','nx','A'}; |
---|
2132 | Data.VarDimName= {'ny','nx',{'ny','nx'}}; |
---|
2133 | hseries=findobj(allchild(0),'Tag','series'); |
---|
2134 | hhseries=guidata(hseries); |
---|
2135 | InputTable=get(hhseries.InputTable,'Data'); |
---|
2136 | ind_A=1; |
---|
2137 | if strcmp(InputTable{1,5},'.nc'); |
---|
2138 | ind_A=2; |
---|
2139 | end |
---|
2140 | list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs |
---|
2141 | PairString=list_pair{get(handles.ListPairCiv1,'Value')}; |
---|
2142 | [ind1,ind2,mode]=find_pair_indices(PairString,ref_i,ref_j);%,MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j) |
---|
2143 | switch mode |
---|
2144 | case 'Di' |
---|
2145 | i1=ref_i-ind1; |
---|
2146 | i2=ref_i+ind2; |
---|
2147 | j1=ref_j; |
---|
2148 | j2=ref_j; |
---|
2149 | case 'Dj' |
---|
2150 | i1=ref_i; |
---|
2151 | i2=ref_i; |
---|
2152 | j1=ref_j-ind1; |
---|
2153 | j2=ref_j+ind2; |
---|
2154 | case 'burst' |
---|
2155 | i1=ref_i; |
---|
2156 | i2=ref_i; |
---|
2157 | j1=ind1; |
---|
2158 | j2=ind2; |
---|
2159 | end |
---|
2160 | ImageName_A=fullfile_uvmat(InputTable{ind_A,1},InputTable{ind_A,2},InputTable{ind_A,3},InputTable{ind_A,5},InputTable{ind_A,4},... |
---|
2161 | i1,[],j1); |
---|
2162 | ImageName_B=fullfile_uvmat(InputTable{ind_A,1},InputTable{ind_A,2},InputTable{ind_A,3},InputTable{ind_A,5},InputTable{ind_A,4},... |
---|
2163 | i2,[],j2); |
---|
2164 | Data.A=imread(ImageName_A); % read the first image |
---|
2165 | if ndims(Data.A)==3 %case of color image |
---|
2166 | Data.VarDimName= {'ny','nx',{'ny','nx','rgb'}}; |
---|
2167 | end |
---|
2168 | Data.ny=[size(Data.A,1) 1]; |
---|
2169 | Data.nx=[1 size(Data.A,2)]; |
---|
2170 | Data.CoordUnit='pixel';% used to set equal scaling for x and y in image dispa=ly |
---|
2171 | % par_civ1=read_GUI(handles.Civ1); |
---|
2172 | % FileInfo=get_file_info(ImageName_A); |
---|
2173 | % par_civ1.FileTypeA=FileInfo.FileType; |
---|
2174 | % par_civ1.ImageWidth=size(Data.A,2); |
---|
2175 | % par_civ1.ImageHeight=size(Data.A,1); |
---|
2176 | % par_civ1.Mask='all';% will provide only the grid set for PIV, no image correlation |
---|
2177 | % par_civ1.FrameIndexA=num2str(i1); |
---|
2178 | % par_civ1.FrameIndexB=num2str(i2); |
---|
2179 | % par_civ1.ImageName_B=ImageName_B; |
---|
2180 | |
---|
2181 | %------------------------------------------------------------------------ |
---|
2182 | % --- Executes on button press in ImportParam. |
---|
2183 | %------------------------------------------------------------------------ |
---|
2184 | function ImportParam_Callback(hObject, eventdata, handles) |
---|
2185 | hseries=findobj(allchild(0),'Tag','series'); |
---|
2186 | hhseries=guidata(hseries); |
---|
2187 | InputTable=get(hhseries.InputTable,'Data');% read the input file(s) table in the GUI series |
---|
2188 | oldfile=InputTable{1,1}; |
---|
2189 | if isempty(oldfile) |
---|
2190 | % use a file name stored in prefdir |
---|
2191 | dir_perso=prefdir; |
---|
2192 | profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); |
---|
2193 | if exist(profil_perso,'file') |
---|
2194 | h=load (profil_perso); |
---|
2195 | if isfield(h,'RootPath') && ischar(h.RootPath) |
---|
2196 | oldfile=h.RootPath; |
---|
2197 | end |
---|
2198 | end |
---|
2199 | end |
---|
2200 | filexml=uigetfile_uvmat('pick a xml parameter file for civ',oldfile,'.xml');% get the xml file containing processing parameters |
---|
2201 | %proceed only if a file has been introduced by the browser |
---|
2202 | if ~isempty(filexml) |
---|
2203 | Param=xml2struct(filexml);% read the input xml file as a Matlab structure |
---|
2204 | |
---|
2205 | % Param.Action.RUN=0; %desactivate the input RUN=1 |
---|
2206 | if ~isfield(Param,'InputTable')||~isfield(Param,'IndexRange') |
---|
2207 | msgbox_uvmat('ERROR','invalid config file: open a file in a folder ''/0_XML''') |
---|
2208 | return |
---|
2209 | end |
---|
2210 | check_input=0; |
---|
2211 | if isfield(Param,'ActionInput') |
---|
2212 | if isfield(Param.ActionInput,'Program')&& strcmp(Param.ActionInput.Program,'civ_series') |
---|
2213 | fill_GUI(Param.ActionInput,handles.civ_input)% fill the elements of the GUI series with the input parameters |
---|
2214 | set(handles.ConfigSource,'String',filexml) |
---|
2215 | check_input=1; |
---|
2216 | update_CivOptions(handles,0) |
---|
2217 | end |
---|
2218 | end |
---|
2219 | if ~check_input |
---|
2220 | msgbox_uvmat('ERROR','invalid config file (not for civ_series') |
---|
2221 | return |
---|
2222 | end |
---|
2223 | end |
---|
2224 | |
---|
2225 | % --- Executes on selection change in CheckCiv3. |
---|
2226 | function CheckCiv3_Callback(hObject, eventdata, handles) |
---|
2227 | |
---|
2228 | %------------------------------------------------------------------------ |
---|
2229 | % --- Executes on key press with selection of a uicontrol |
---|
2230 | %------------------------------------------------------------------------ |
---|
2231 | function keyboard_callback(hObject,eventdata,handles) |
---|
2232 | |
---|
2233 | ListExclude={'CheckCiv1','CheckFix1','CheckPatch1','CheckCiv2','CheckFix2','CheckPatch2','ref_i'}; |
---|
2234 | if isempty(find(strcmp(get(gco,'Tag'),ListExclude),1))% if the selected uicontrol is not in the Exclude list |
---|
2235 | set(handles.ConfigSource,'String','NEW')% indicate that the configuration is new |
---|
2236 | set(handles.OK,'BackgroundColor',[1 0 1])% |
---|
2237 | drawnow |
---|
2238 | end |
---|
2239 | |
---|
2240 | |
---|
2241 | % --- Executes on button press in TestPatch2. |
---|
2242 | function TestPatch2_Callback(hObject, eventdata, handles) |
---|