Changeset 856
- Timestamp:
- Jan 26, 2015, 12:37:56 AM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/browse_data.m
r837 r856 24 24 function varargout = browse_data(varargin) 25 25 26 % Last Modified by GUIDE v2.5 11-Mar-2014 22:09:3726 % Last Modified by GUIDE v2.5 24-Jan-2015 16:55:04 27 27 28 28 % Begin initialization code - DO NOT EDIT … … 47 47 %------------------------------------------------------------------------ 48 48 % --- Executes just before browse_data is made visible. 49 function browse_data_OpeningFcn(hObject, eventdata, handles, Campaign,EnableMirror)49 function browse_data_OpeningFcn(hObject, eventdata, handles, DataSeries,EnableMirror) 50 50 %------------------------------------------------------------------------ 51 51 … … 80 80 set(handles.mirror_txt,'Visible','off') 81 81 end 82 if exist('Campaign','var') 83 [tild,CampaignName]=fileparts(Campaign); 84 RootXml=fullfile(Campaign,[CampaignName '.xml']); 85 s=[]; 86 if exist(RootXml,'file') 87 [s,Heading]=xml2struct(RootXml);%read the xml file 88 if isfield(s,'SourceDir') 89 set(handles.SourceDir,'String',s.SourceDir);%display the source dir if a mirror has been opened 90 set(handles.MirrorDir,'Visible','on');% mirror dir display 91 set(handles.MirrorDir,'String',Campaign);%display the opened mirror dir 92 set(handles.CreateMirror,'String','update_mirror') 93 end 94 end 95 if isempty(s) %a source dir has been opened 96 set(handles.SourceDir,'String',Campaign); 97 set(handles.MirrorDir,'Visible','off');% no mirror dir display 98 set(handles.CreateMirror,'String','create_mirror') 99 end 100 errormsg=scan_campaign(handles,Campaign); 101 if ~isempty(errormsg) 102 msgbox_uvmat('ERROR',errormsg) 103 return 104 end 105 set(handles.OK,'Visible','on') 106 set(handles.Cancel,'Visible','on') 107 set(handles.browse_data,'WindowStyle','modal')% Make the GUI modal 108 set(hObject,'Visible','on') 109 drawnow 110 % UIWAIT makes GUI wait for user response (see UIRESUME) 111 uiwait(handles.browse_data); 112 end 82 83 %% initialize the GUI 84 if ~(exist('DataSeries','var') && exist(DataSeries,'dir')) 85 DataSeries=pwd;% current dir is the starting data series by default 86 end 87 [Experiment,DataSeries,Ext]=fileparts(DataSeries); 88 DataSeries=[DataSeries Ext]; 89 [Campaign,Experiment,Ext]=fileparts(Experiment); 90 Experiment=[Experiment Ext]; 91 [tild,CampaignName]=fileparts(Campaign); 92 RootXml=fullfile(Campaign,[CampaignName '.xml']); 93 s=[]; 94 if exist(RootXml,'file') 95 [s,Heading]=xml2struct(RootXml);%read the xml file 96 if isfield(s,'SourceDir') 97 set(handles.SourceDir,'String',s.SourceDir);%display the source dir if a mirror has been opened 98 set(handles.MirrorDir,'Visible','on');% mirror dir display 99 set(handles.MirrorDir,'String',Campaign);%display the opened mirror dir 100 set(handles.CreateMirror,'String','update_mirror') 101 end 102 end 103 if isempty(s) %a source dir has been opened 104 set(handles.SourceDir,'String',Campaign); 105 set(handles.MirrorDir,'Visible','off');% no mirror dir display 106 set(handles.CreateMirror,'String','create_mirror') 107 end 108 errormsg=scan_campaign(handles,Campaign,Experiment,DataSeries); 109 if ~isempty(errormsg) 110 msgbox_uvmat('ERROR',errormsg) 111 return 112 end 113 set(handles.OK,'Visible','on') 114 set(handles.Cancel,'Visible','on') 115 116 set(handles.browse_data,'WindowStyle','modal')% Make the GUI modal 117 set(hObject,'Visible','on') 118 drawnow 119 % UIWAIT makes GUI wait for user response (see UIRESUME) 120 uiwait(handles.browse_data); 121 113 122 114 123 … … 190 199 set(handles.SourceDir,'BackgroundColor',[1 1 1]) 191 200 192 193 %------------------------------------------------------------------------ 194 function errormsg=scan_campaign(handles,Campaign) 195 %------------------------------------------------------------------------ 196 %set(handles.SourceDir,'BackgroundColor',[1 1 0]) 197 %drawnow 198 %SourceDir=get(handles.SourceDir,'String'); 199 %MirrorDir=get(handles.MirrorDir,'String'); 200 % ExpName={''}; 201 %------------------------------------------------------------------------ 202 % List the experiments in a campaign, filling the menu ListExperiments 203 %------------------------------------------------------------------------ 204 function errormsg=scan_campaign(handles,Campaign,Experiment,DataSeries) 205 %------------------------------------------------------------------------ 201 206 errormsg=''; 202 207 if exist(Campaign,'dir') … … 213 218 check_keep=cellfun('isempty', cell_remove); 214 219 ListFiles=sort((ListFiles(check_keep))'); 220 index=find(strcmp(['+/' Experiment],ListFiles)); 221 if isempty(index), index=0; end 215 222 set(handles.ListExperiments,'String',[{'*'};ListFiles]) 216 set(handles.ListExperiments,'Value', 1)223 set(handles.ListExperiments,'Value',index+1)% initialise the menu selection with the folder defined by the input 217 224 ListExperiments_Callback([],[], handles) 225 ListDevices=get(handles.ListDevices,'String'); 226 index=find(strcmp(['+/' DataSeries],ListDevices)); 227 if isempty(index) 228 index=find(strcmp(['~/' DataSeries],ListDevices)); 229 end 230 if ~isempty(index) 231 set(handles.ListDevices,'Value',index) 232 end 218 233 else 219 234 msgbox_uvmat('ERROR',['The input ' Campaign ' is not a directory']) 220 235 end 221 %set(handles.SourceDir,'BackgroundColor',[1 1 1])222 223 236 224 237 %------------------------------------------------------------------------ … … 668 681 669 682 670 % --- Executes during object deletion, before destroying properties. 671 function browse_data_DeleteFcn(hObject, eventdata, handles) 683 % --- Executes on button press in Browse. 684 function Browse_Callback(hObject, eventdata, handles) 685 ListDevices=get(handles.ListDevices,'String'); 686 Device=ListDevices{get(handles.ListDevices,'Value')}; 687 DataSeries=uigetfile_uvmat('open a data folder',Device,'uigetdir'); 688 uiresume(handles.browse_data); 689 browse_data(DataSeries) -
trunk/src/check_files.m
r828 r856 45 45 'civ_3D';... % function associated with the interface 'civ_3D.fig' for PIV in volume (TODO: combine with civ.m) 46 46 'civ_3D.fig';... 47 'civ_matlab';...% civ programs, Matlab version (called by civ.m, option Civprogram/Matlab in the upper menu bar)48 47 'compile';...% compile a Matlab function, create a binary in a subdirectory /bin 49 48 'copyfields';...% copy fields between two matlab structures -
trunk/src/geometry_calib.m
r851 r856 239 239 InputDir=fileparts(fileparts(CalibData.XmlInputFile)); 240 240 end 241 SubProject=uigetfile_uvmat('open folder of subproject to calibrate',InputDir,'uigetdir'); 242 % answer=msgbox_uvmat('INPUT_TXT','Campaign to calibrate?',InputDir); 243 % if strcmp(answer,'Cancel') 244 % return 245 % end 246 OutPut=browse_data(SubProject); 241 DataSeries=uigetfile_uvmat('open a folder of images to calibrate',InputDir,'uigetdir'); 242 %SubProject=uigetfile_uvmat('open folder of subproject to calibrate',InputDir,'uigetdir'); 243 OutPut=browse_data(DataSeries); 247 244 nbcalib=0; 248 245 for ilist=1:numel(OutPut.Experiment) -
trunk/src/mouse_motion.m
r855 r856 64 64 end 65 65 test_piv=0; 66 if isfield(FigData,'CivHandle') 66 if isfield(FigData,'CivHandle')% look for handle of the civ_input GUI 67 67 if ~ishandle(FigData.CivHandle) 68 68 delete(hObject) … … 70 70 return 71 71 end 72 hhciv=guidata(FigData.CivHandle); 72 hhciv=guidata(FigData.CivHandle);% list of handles in the GUI civ_input 73 73 test_piv=1; 74 74 end … … 236 236 % case of PIV correlation display 237 237 if test_piv 238 par=read_GUI(hhciv.Civ1); 239 [dd,ind_pt]=min(abs(Field.X-xy(1,1))+abs(Field.Y-xy(1,2))); 238 [dd,ind_pt]=min(abs(Field.X-xy(1,1))+abs(Field.Y-xy(1,2))); 239 if (isfield(hhciv,'TestCiv2')&& get(hhciv.TestCiv2,'Value'))% if TestCiv2 is activated 240 CivOption='Civ2'; 241 Param.CheckCiv1=0; 242 par_civ=read_GUI(hhciv.Civ2);%read the Civ2 panel in civ_input 243 par_civ.Civ1_SubRange=Field.Civ1_SubRange; 244 par_civ.Civ1_NbCentres=Field.Civ1_NbCentres; 245 par_civ.Civ1_Coord_tps=Field.Civ1_Coord_tps; 246 par_civ.Civ1_U_tps=Field.Civ1_U_tps; 247 par_civ.Civ1_V_tps=Field.Civ1_V_tps; 248 par_civ.Civ1_Dt=Field.Civ1_Dt; 249 shiftx=Field.ShiftX(ind_pt); 250 shifty=Field.ShiftY(ind_pt); 251 else 252 CivOption='Civ1'; 253 Param.CheckCiv2=0; 254 par_civ=read_GUI(hhciv.Civ1);%read the Civ1 panel in civ_input 255 shiftx=par_civ.SearchBoxShift(1); 256 shifty=par_civ.SearchBoxShift(2); 257 end 240 258 xround=Field.X(ind_pt); 241 259 yround=Field.Y(ind_pt); 242 par.Grid=[xround yround];260 243 261 % mark the correlation box with a rectangle 244 par.ImageA=Field.A; 245 par.ImageB=Field.B; 246 par.ImageHeight=size(par.ImageA,1); 247 par.ImageWidth=size(par.ImageA,2); 248 Param.ActionInput.Civ1=par; 249 ibx2=floor((par.CorrBoxSize(1)-1)/2); 250 iby2=floor((par.CorrBoxSize(2)-1)/2); 251 isx2=floor((par.SearchBoxSize(1)-1)/2); 252 isy2=floor((par.SearchBoxSize(2)-1)/2); 253 shiftx=par.SearchBoxShift(1); 254 shifty=par.SearchBoxShift(2); 262 ibx2=floor((par_civ.CorrBoxSize(1)-1)/2); 263 iby2=floor((par_civ.CorrBoxSize(2)-1)/2); 264 isx2=floor((par_civ.SearchBoxSize(1)-1)/2); 265 isy2=floor((par_civ.SearchBoxSize(2)-1)/2); 255 266 hhh=findobj(CurrentAxes,'Tag','PIV_box_marker'); 256 267 hhhh=findobj(CurrentAxes,'Tag','PIV_search_marker'); … … 268 279 set(hhhh,'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2]) 269 280 end 281 282 % perform the PIV calculation as the single point xround yround 283 Param.CheckFix1=0; 284 Param.CheckPatch1=0;%desactivate all calculations except Civ2 or Civ1 270 285 Param.Action.RUN=1; 271 286 Param.ActionInput.ListCompareMode='PIV'; 287 par_civ.ImageA=Field.A; 288 par_civ.ImageB=Field.B; 289 par_civ.ImageHeight=size(par_civ.ImageA,1); 290 par_civ.ImageWidth=size(par_civ.ImageA,2); 291 par_civ.Grid=[xround yround];% PIV calculation with a single point 292 Param.ActionInput.(CivOption)=par_civ; 293 294 % .ImageA: first image for correlation (matrix) 295 % .ImageB: second image for correlation(matrix) 296 % .CorrBoxSize: 1,2 vector giving the size of the correlation box in x and y 297 % .SearchBoxSize: 1,2 vector giving the size of the search box in x and y 298 % .SearchBoxShift: 1,2 vector or 2 column matrix (for civ2) giving the shift of the search box in x and y 299 % .CorrSmooth: =1 or 2 determines the choice of the sub-pixel determination of the correlation max 300 % .ImageWidth: nb of pixels of the image in x 301 % .Dx, Dy: mesh for the PIV calculation 302 % .Grid: grid giving the PIV calculation points (alternative to .Dx .Dy) 303 % .Mask: name of a mask file or mask image matrix itself 304 % .MinIma: thresholds for image luminosity 305 % .MaxIma 306 % .CheckDeformation=1 for subpixel interpolation and image deformation (linear transform) 307 % .DUDX: matrix of deformation obtained from patch at each grid point 308 % .DUDY 309 % .DVDX: 310 % .DVDY 311 272 312 [Data,errormsg,result_conv]= civ_series(Param); 273 313 if ~isempty(errormsg) -
trunk/src/series.m
r855 r856 429 429 430 430 %------------------------------------------------------------------------ 431 % --- fct activated by the browser under 'Open campaign '431 % --- fct activated by the browser under 'Open campaign/Browse...' 432 432 %------------------------------------------------------------------------ 433 433 function MenuBrowseCampaign_Callback(hObject, eventdata, handles) 434 434 435 %% look for the previously opened file 'oldfile' 436 InputTable=get(handles.InputTable,'Data'); 437 RootPathCell=InputTable(:,1); 438 SubDirCell=InputTable(:,2); 439 oldfile=fullfile(RootPathCell{1},SubDirCell{1}); 440 if isempty(oldfile) 441 % use a file name stored in prefdir 442 dir_perso=prefdir; 443 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 444 if exist(profil_perso,'file') 445 h=load (profil_perso); 446 if isfield(h,'RootPath') && ischar(h.RootPath) 447 oldfile=h.RootPath; 448 end 449 end 450 end 451 %% launch the browser 452 fileinput=uigetfile_uvmat('pick an input file in the series',oldfile); 453 hh=dir(fileinput); 454 if numel(hh)>1 455 msgbox_uvmat('ERROR','invalid input, probably a broken link'); 456 else 457 if ~isempty(fileinput) 458 display_file_name(handles,fileinput,'one') 459 end 460 end 461 append='one'; 435 462 set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0]) 436 463 drawnow 437 InputTable=get(handles.InputTable,'Data'); 438 RootPath=InputTable{1,1}; 439 CampaignPath=fileparts(fileparts(RootPath)); 440 DirFull=uigetfile_uvmat('define this path as the Campaign folder:',CampaignPath,'uigetdir'); 441 if ~ischar(DirFull)|| ~exist(DirFull,'dir') 442 return 443 end 444 OutPut=browse_data(DirFull);% open the GUI browse_data to get select a campaign dir, experiment and device 464 browse_campaign(handles,append); 465 466 %------------------------------------------------------------------------ 467 % --- fct activated by the browser under 'Open campaign/Browse...' 468 %------------------------------------------------------------------------ 469 function MenuBrowseCampaignAppend_Callback(hObject, eventdata, handles) 470 append='append'; 471 browse_campaign(handles,append); 472 473 %------------------------------------------------------------------------ 474 function browse_campaign(handles,append); 475 476 %% look for the previously opened file 'oldfile' 477 478 % 479 % 480 % InputTable=get(handles.InputTable,'Data'); 481 % RootPath=InputTable{1,1}; 482 % CampaignPath=fileparts(fileparts(RootPath)); 483 % DirFull=uigetfile_uvmat('define this path as the Campaign folder:',CampaignPath,'uigetdir'); 484 % if ~ischar(DirFull)|| ~exist(DirFull,'dir') 485 % return 486 % end 487 OutPut=browse_data(oldfile);% open the GUI browse_data to get select a campaign dir, experiment and device 445 488 if ~isfield(OutPut,'Campaign') 446 489 return … … 468 511 MenuCampaign=[{get(handles.MenuCampaign_1,'Label')};{get(handles.MenuCampaign_2,'Label')};... 469 512 {get(handles.MenuCampaign_3,'Label')};{get(handles.MenuCampaign_4,'Label')};{get(handles.MenuCampaign_5,'Label')}]; 470 check_dir=isempty(find(strcmp(Dir Full,MenuCampaign)));513 check_dir=isempty(find(strcmp(DirName,MenuCampaign))); 471 514 if check_dir %insert the new campaign in the list if it is not found 472 515 MenuCampaign(end)=[]; %suppress the last item 473 MenuCampaign=[{Dir Full};MenuCampaign];%insert the new campaign516 MenuCampaign=[{DirName};MenuCampaign];%insert the new campaign 474 517 for ilist=1:numel(MenuCampaign) 475 518 set(handles.(['MenuCampaign_' num2str(ilist)]),'Label',MenuCampaign{ilist}) … … 479 522 profil_perso=fullfile(dir_perso,'uvmat_perso.mat'); 480 523 if exist(profil_perso,'file') 481 save (profil_perso,'MenuCampaign',' RootPath','-append'); %store the file names for future opening of uvmat524 save (profil_perso,'MenuCampaign','-append'); %store the file names for future opening of uvmat 482 525 else 483 save (profil_perso,'MenuCampaign',' RootPath','-V6'); %store the file names for future opening of uvmat526 save (profil_perso,'MenuCampaign','-V6'); %store the file names for future opening of uvmat 484 527 end 485 528 end … … 1955 1998 end 1956 1999 1957 %% Activate the Action fct 2000 %% Activate the Action fct to adapt the configuration of the GUI series and bring specific parameters in SeriesData 1958 2001 Param=read_GUI_series(handles);% read the parameters from the GUI series 1959 2002 ParamOut=h_fun(Param);%run the selected Action function to get the relevant input -
trunk/src/series/civ_input.m
r855 r856 165 165 set(handles.ref_j,'String',num2str(Param.IndexRange.first_j)) 166 166 end 167 set(handles.ConfigSource,'String','\default') 167 168 168 169 %% set the menus of image pairs and default selection for civ_input %%%%%%%%%%%%%%%%%%% … … 340 341 set(handles.civ_input,'WindowStyle','modal')% Make the GUI modal 341 342 drawnow 342 uiwait(handles.civ_input); 343 uiwait(handles.civ_input);% wait for OK action to end the function 343 344 344 345 … … 368 369 %------------------------------------------------------------------------ 369 370 function SetDefaultParam_Callback(hObject, eventdata, handles) 370 371 hseries=findobj(allchild(0),'Name','series');% look for the GUI series 372 hhseries=guidata(hseries);%handles of elements in the GUI series 373 SeriesData=get(hseries,'UserData');%read parameters on the GUI series 374 if isfield (SeriesData,'ActionInput') 375 SeriesData=rmfield(SeriesData,'ActionInput');% remove recorded civ parameters 376 end 377 set(hseries,'UserData',SeriesData) 378 series('ActionName_Callback',hObject,eventdata,hhseries); % 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 379 440 380 441 % ----------------------------------------------------------------------- … … 771 832 if isempty(errormsg) 772 833 set(handles.ref_i,'BackgroundColor',[1 1 1]) 834 set(handles.ref_j,'BackgroundColor',[1 1 1]) 773 835 else 774 836 msgbox_uvmat('ERROR',errormsg) … … 827 889 828 890 %% determine nom_type_nc, nomenclature type of the .nc files: 829 [nom_type_nc]=nomtype2pair(nom_type_ima,mode);891 %[nom_type_nc]=nomtype2pair(nom_type_ima,mode); 830 892 831 893 %% reads .nc subdirectoy and image numbers from the interface … … 920 982 921 983 %% determine the default selection in the pair menu for Civ1 922 ichoice=find(select,1);% index of selected pair984 ichoice=find(select,1);% index of first selected pair 923 985 if (isempty(ichoice) || ichoice < 1); ichoice=1; end; 924 986 initial=get(handles.ListPairCiv1,'Value');%initial choice of pair … … 1081 1143 1082 1144 %------------------------------------------------------------------------ 1083 % --- Executes on button press in CheckMask.1145 % --- Executes on selection in menu CorrSmooth. 1084 1146 function num_CorrSmooth_Callback(hObject, eventdata, handles) 1085 1147 set(handles.configSource,'String','NEW') 1086 set(handles. configSource,'BackgroundColor',[1 0 1])1148 set(handles.OK,'BackgroundColor',[1 0 1]) 1087 1149 %------------------------------------------------------------------------ 1088 1150 … … 1423 1485 set(hObject,'BackgroundColor',[1 0 1]) 1424 1486 set(handles.configSource,'String','NEW') 1425 set(handles. configSource,'BackgroundColor',[1 0 1])1487 set(handles.OK,'BackgroundColor',[1 0 1]) 1426 1488 %------------------------------------------------------------------------ 1427 1489 % --- Executes on button press in CheckMask: common to all panels (civ1, Civ2..) … … 1685 1747 end 1686 1748 set(handles.configSource,'String','NEW') 1687 set(handles. configSource,'BackgroundColor',[1 0 1])1749 set(handles.OK,'BackgroundColor',[1 0 1]) 1688 1750 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1689 1751 %%%%%%%%%%%%%% TEST functions … … 1820 1882 if get(handles.TestCiv2,'Value') 1821 1883 set(handles.TestCiv2,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch 1822 % TO UPDATE TO UPDATE TO UPDATE TO UPDATE 1823 [Data,Param.Civ2]=get_param_civ2(handles); 1824 Grid=civ_matlab(Param);% get the grid of x, y positions set for PIV 1825 hview_field=view_field(Data); %view the image in the GUI view_field 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 1826 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 1827 1914 hhview_field=guihandles(hview_field); 1828 1915 set(hview_field,'CurrentAxes',hhview_field.PlotAxes) 1829 1916 ViewData=get(hview_field,'UserData'); 1830 1917 ViewData.CivHandle=handles.civ_input;% indicate the handle of the civ GUI in view_field 1831 ViewData.PlotAxes.B=imread(Param.Civ1.ImageName_B);%store the second image in the UserData of the GUI view_field 1832 ViewData.PlotAxes.X=Grid.Civ1_X; %keep the set of points in memeory 1833 ViewData.PlotAxes.Y=Grid.Civ1_Y; 1834 set(hview_field,'UserData',ViewData) 1835 corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display 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'); 1836 1933 if isempty(corrfig) 1837 1934 corrfig=figure; … … 1839 1936 set(corrfig,'name','image correlation') 1840 1937 set(corrfig,'DeleteFcn',{@closeview_field})% 1841 % end1842 1938 set(handles.TestCiv1,'BackgroundColor',[1 0 0]) 1843 1939 else … … 1851 1947 delete(hview_field) 1852 1948 end 1853 end 1949 end 1854 1950 else 1855 1951 hview_field=findobj(allchild(0),'Tag','view_field'); %view the image in the GUI view_field … … 2084 2180 2085 2181 %------------------------------------------------------------------------ 2086 % --- Executes on button press in I nportParam.2087 %------------------------------------------------------------------------ 2088 function I nportParam_Callback(hObject, eventdata, handles)2182 % --- Executes on button press in ImportParam. 2183 %------------------------------------------------------------------------ 2184 function ImportParam_Callback(hObject, eventdata, handles) 2089 2185 hseries=findobj(allchild(0),'Tag','series'); 2090 2186 hhseries=guidata(hseries); … … 2116 2212 if isfield(Param.ActionInput,'Program')&& strcmp(Param.ActionInput.Program,'civ_series') 2117 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) 2118 2215 check_input=1; 2119 update_CivOptions(handles,0) 2120 2216 update_CivOptions(handles,0) 2121 2217 end 2122 2218 end … … 2138 2234 if isempty(find(strcmp(get(gco,'Tag'),ListExclude),1))% if the selected uicontrol is not in the Exclude list 2139 2235 set(handles.ConfigSource,'String','NEW')% indicate that the configuration is new 2140 set(handles.ConfigSource,'BackgroundColor',[1 0 1])% 2141 end 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) -
trunk/src/series/civ_series.m
r855 r856 58 58 Data.AllowInputSort='off';% allow alphabetic sorting of the list of input file SubDir (options 'off'/'on', 'off' by default) 59 59 Data.WholeIndexRange='off';% prescribes the file index ranges from min to max (options 'off'/'on', 'off' by default) 60 if isfield(Data,'ActionInput') && strcmp(Data.ActionInput.PairIndices.ListPairMode,'pair j1-j2')60 if isfield(Data,'ActionInput') && isfield(Data.ActionInput,'PairIndices')&& strcmp(Data.ActionInput.PairIndices.ListPairMode,'pair j1-j2') 61 61 Data.Desable_j_index='on';% hide the j index in series (set by the pair choice in civ_input) 62 62 end … … 174 174 j1_series_Civ2=j1_series_Civ1; 175 175 j2_series_Civ2=j2_series_Civ1; 176 NomTypeNc= NomType;176 NomTypeNc=Param.InputTable{1,4}; 177 177 case 'PIV volume' 178 178 % TODO, TODO … … 329 329 330 330 %%%%% MAIN LOOP %%%%%% 331 maskname='';% initiate the mask name 331 332 for ifield=1:NbField 332 333 if ~isempty(RUNHandle)% update the waitbar in interactive mode with GUI series (checkrun=1) … … 360 361 if isfield (Param.ActionInput,'Civ1') 361 362 par_civ1=Param.ActionInput.Civ1; 362 if CheckInputFile % read input images (except in mode Test where it is introduced directly in Param.ActionInput.Civ1 )363 if CheckInputFile % read input images (except in mode Test where it is introduced directly in Param.ActionInput.Civ1.ImageNameA and B) 363 364 try 364 365 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(ifield),[],j1_series_Civ1(ifield)); … … 422 423 Data.VarAttribute{4}.Role='vector_y'; 423 424 Data.VarAttribute{5}.Role='warnflag'; 424 425 if par_civ1.CheckMask&&~isempty(par_civ1.Mask) 426 if strcmp(maskname,par_civ1.Mask)% mask exist, not already read in civ1 427 par_civ1.Mask=mask; %use mask already opened 428 else 429 par_civ1.Mask=imread(par_civ1.Mask);%update the mask, an store it for future use 430 mask=par_civ1.Mask; 431 maskname=par_civ1.Mask; 432 end 433 end 425 434 if strcmp(Param.ActionInput.ListCompareMode, 'PIV volume') 426 435 Data.ListVarName=[Data.ListVarName 'Civ1_Z']; … … 429 438 for ivol=1:NbSlice 430 439 % caluclate velocity data (y and v in indices, reverse to y component) 431 [xtable ytable utable vtable ctable F result_converrormsg] = civ (par_civ1);440 [xtable, ytable, utable, vtable, ctable, F, result_conv, errormsg] = civ (par_civ1); 432 441 if ~isempty(errormsg) 433 442 disp_uvmat('ERROR',errormsg,checkrun) … … 444 453 else %usual PIV 445 454 % caluclate velocity data (y and v in indices, reverse to y component) 446 [xtable ytable utable vtable ctable F result_converrormsg] = civ (par_civ1);455 [xtable, ytable, utable, vtable, ctable, F, result_conv, errormsg] = civ (par_civ1); 447 456 if ~isempty(errormsg) 448 457 disp_uvmat('ERROR',errormsg,checkrun) … … 473 482 [Data,tild,tild,errormsg]=nc2struct(CivFile);%read civ1 and fix1 data in the existing netcdf file 474 483 end 475 else 484 elseif isfield(Param,'Civ1_X') 476 485 Data.ListGlobalAttribute={}; 477 486 Data.ListVarName={}; … … 572 581 if isfield (Param.ActionInput,'Civ2') 573 582 par_civ2=Param.ActionInput.Civ2; 574 par_civ2.ImageA=[]; 575 par_civ2.ImageB=[]; 576 i1=i1_series_Civ2(ifield); 577 i2=i1; 578 if ~isempty(i2_series_Civ2) 579 i2=i2_series_Civ2(ifield); 580 end 581 j1=1; 582 if ~isempty(j1_series_Civ2) 583 j1=j1_series_Civ2(ifield); 584 end 585 j2=j1; 586 if ~isempty(j2_series_Civ2) 587 j2=j2_series_Civ2(ifield); 588 end 589 ImageName_A_Civ2=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1,[],j1); 590 591 if strcmp(ImageName_A_Civ2,ImageName_A) && isequal(FrameIndex_A_Civ1(ifield),FrameIndex_A_Civ2(ifield)) 592 par_civ2.ImageA=par_civ1.ImageA; 593 else 594 [par_civ2.ImageA,VideoObject_A] = read_image(ImageName_A_Civ2,FileType_A,VideoObject_A,FrameIndex_A_Civ2(ifield)); 595 end 596 ImageName_B_Civ2=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2,[],j2); 597 if strcmp(ImageName_B_Civ2,ImageName_B) && isequal(FrameIndex_B_Civ1(ifield),FrameIndex_B_Civ2) 598 par_civ2.ImageB=par_civ1.ImageB; 599 else 600 [par_civ2.ImageB,VideoObject_B] = read_image(ImageName_B_Civ2,FileType_B,VideoObject_B,FrameIndex_B_Civ2(ifield)); 601 end 602 603 ncfile=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i1,i2,j1,j2); 604 par_civ2.ImageWidth=FileInfo_A.Width; 605 par_civ2.ImageHeight=FileInfo_A.Height; 606 607 if isfield(par_civ2,'Grid')% grid points set as input file 608 if ischar(par_civ2.Grid)%read the grid file if the input is a file name 609 par_civ2.Grid=dlmread(par_civ2.Grid); 610 par_civ2.Grid(1,:)=[];%the first line must be removed (heading in the grid file) 611 end 612 else% automatic grid 613 minix=floor(par_civ2.Dx/2)-0.5; 614 maxix=minix+par_civ2.Dx*floor((par_civ2.ImageWidth-1)/par_civ2.Dx); 615 miniy=floor(par_civ2.Dy/2)-0.5; 616 maxiy=minix+par_civ2.Dy*floor((par_civ2.ImageHeight-1)/par_civ2.Dy); 617 [GridX,GridY]=meshgrid(minix:par_civ2.Dx:maxix,miniy:par_civ2.Dy:maxiy); 618 par_civ2.Grid(:,1)=reshape(GridX,[],1); 619 par_civ2.Grid(:,2)=reshape(GridY,[],1); 620 end 621 Shiftx=zeros(size(par_civ2.Grid,1),1);% shift expected from civ1 data 622 Shifty=zeros(size(par_civ2.Grid,1),1); 623 nbval=zeros(size(par_civ2.Grid,1),1); 583 if CheckInputFile % read input images (except in mode Test where it is introduced directly in Param.ActionInput.Civ1.ImageNameA and B) 584 par_civ2.ImageA=[]; 585 par_civ2.ImageB=[]; 586 i1=i1_series_Civ2(ifield); 587 i2=i1; 588 if ~isempty(i2_series_Civ2) 589 i2=i2_series_Civ2(ifield); 590 end 591 j1=1; 592 if ~isempty(j1_series_Civ2) 593 j1=j1_series_Civ2(ifield); 594 end 595 j2=j1; 596 if ~isempty(j2_series_Civ2) 597 j2=j2_series_Civ2(ifield); 598 end 599 ImageName_A_Civ2=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1,[],j1); 600 601 if strcmp(ImageName_A_Civ2,ImageName_A) && isequal(FrameIndex_A_Civ1(ifield),FrameIndex_A_Civ2(ifield)) 602 par_civ2.ImageA=par_civ1.ImageA; 603 else 604 [par_civ2.ImageA,VideoObject_A] = read_image(ImageName_A_Civ2,FileType_A,VideoObject_A,FrameIndex_A_Civ2(ifield)); 605 end 606 ImageName_B_Civ2=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2,[],j2); 607 if strcmp(ImageName_B_Civ2,ImageName_B) && isequal(FrameIndex_B_Civ1(ifield),FrameIndex_B_Civ2) 608 par_civ2.ImageB=par_civ1.ImageB; 609 else 610 [par_civ2.ImageB,VideoObject_B] = read_image(ImageName_B_Civ2,FileType_B,VideoObject_B,FrameIndex_B_Civ2(ifield)); 611 end 612 if strcmp(Param.ActionInput.ListCompareMode,'PIV') 613 ncfile=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i1,i2,j1,j2); 614 else % displacement 615 ncfile=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i2,[],j2); 616 end 617 par_civ2.ImageWidth=FileInfo_A.Width; 618 par_civ2.ImageHeight=FileInfo_A.Height; 619 if isfield(par_civ2,'Grid')% grid points set as input file 620 if ischar(par_civ2.Grid)%read the grid file if the input is a file name 621 par_civ2.Grid=dlmread(par_civ2.Grid); 622 par_civ2.Grid(1,:)=[];%the first line must be removed (heading in the grid file) 623 end 624 else% automatic grid 625 minix=floor(par_civ2.Dx/2)-0.5; 626 maxix=minix+par_civ2.Dx*floor((par_civ2.ImageWidth-1)/par_civ2.Dx); 627 miniy=floor(par_civ2.Dy/2)-0.5; 628 maxiy=minix+par_civ2.Dy*floor((par_civ2.ImageHeight-1)/par_civ2.Dy); 629 [GridX,GridY]=meshgrid(minix:par_civ2.Dx:maxix,miniy:par_civ2.Dy:maxiy); 630 par_civ2.Grid(:,1)=reshape(GridX,[],1); 631 par_civ2.Grid(:,2)=reshape(GridY,[],1); 632 end 633 end 624 634 if par_civ2.CheckDeformation 625 635 DUDX=zeros(size(par_civ2.Grid,1),1); … … 629 639 end 630 640 631 % get the guess from patch1 or patch2 (case 'CheckCiv3') 632 if isfield (par_civ2,'CheckCiv3') && par_civ2.CheckCiv3 %get the guess from patch2 633 SubRange= Data.Civ2_SubRange; 634 NbCentres=Data.Civ2_NbCentres; 635 Coord_tps=Data.Civ2_Coord_tps; 636 U_tps=Data.Civ2_U_tps; 637 V_tps=Data.Civ2_V_tps; 638 CivStage=Data.CivStage; 639 Civ1_Dt=Data.Civ2_Dt; 640 Data=[];%reinitialise the result structure Data 641 Data.ListGlobalAttribute={'Conventions','Program','CivStage'}; 642 Data.Conventions='uvmat/civdata';% states the conventions used for the description of field variables and attributes 643 Data.Program='civ_series'; 644 Data.CivStage=CivStage; 645 Data.ListVarName={}; 646 Data.VarDimName={}; 647 else % get the guess from patch1 648 SubRange= Data.Civ1_SubRange; 649 NbCentres=Data.Civ1_NbCentres; 650 Coord_tps=Data.Civ1_Coord_tps; 651 U_tps=Data.Civ1_U_tps; 652 V_tps=Data.Civ1_V_tps; 653 Civ1_Dt=Data.Civ1_Dt; 654 end 655 NbSubDomain=size(SubRange,3); 641 % get the guess from patch1 or patch2 (case 'CheckCiv3') 642 if CheckInputFile % read input images (except in mode Test where it is introduced directly in Param.ActionInput.Civ1.ImageNameA and B) 643 if isfield (par_civ2,'CheckCiv3') && par_civ2.CheckCiv3 %get the guess from patch2 644 SubRange= Data.Civ2_SubRange; 645 NbCentres=Data.Civ2_NbCentres; 646 Coord_tps=Data.Civ2_Coord_tps; 647 U_tps=Data.Civ2_U_tps; 648 V_tps=Data.Civ2_V_tps; 649 CivStage=Data.CivStage; 650 Civ1_Dt=Data.Civ2_Dt; 651 Data=[];%reinitialise the result structure Data 652 Data.ListGlobalAttribute={'Conventions','Program','CivStage'}; 653 Data.Conventions='uvmat/civdata';% states the conventions used for the description of field variables and attributes 654 Data.Program='civ_series'; 655 Data.CivStage=CivStage; 656 Data.ListVarName={}; 657 Data.VarDimName={}; 658 else % get the guess from patch1 659 SubRange= Data.Civ1_SubRange; 660 NbCentres=Data.Civ1_NbCentres; 661 Coord_tps=Data.Civ1_Coord_tps; 662 U_tps=Data.Civ1_U_tps; 663 V_tps=Data.Civ1_V_tps; 664 Civ1_Dt=Data.Civ1_Dt; 665 end 666 else 667 SubRange= par_civ2.Civ1_SubRange; 668 NbCentres=par_civ2.Civ1_NbCentres; 669 Coord_tps=par_civ2.Civ1_Coord_tps; 670 U_tps=par_civ2.Civ1_U_tps; 671 V_tps=par_civ2.Civ1_V_tps; 672 Civ1_Dt=par_civ2.Civ1_Dt; 673 Data.ListVarName={}; 674 Data.VarDimName={}; 675 end 676 Shiftx=zeros(size(par_civ2.Grid,1),1);% shift expected from civ1 data 677 Shifty=zeros(size(par_civ2.Grid,1),1); 678 nbval=zeros(size(par_civ2.Grid,1),1);% nbre of interpolated values at each grid point (from the different patch subdomains) 679 NbSubDomain=size(SubRange,3); 656 680 for isub=1:NbSubDomain% for each sub-domain of Patch1 657 681 nbvec_sub=NbCentres(isub);% nbre of Civ vectors in the subdomain … … 660 684 epoints = par_civ2.Grid(ind_sel,:);% coordinates of interpolation sites 661 685 ctrs=Coord_tps(1:nbvec_sub,:,isub) ;%(=initial points) ctrs 662 nbval(ind_sel)=nbval(ind_sel)+1;% records the number of values for eac ninterpolation point (in case of subdomain overlap)663 EM = tps_eval(epoints,ctrs); 686 nbval(ind_sel)=nbval(ind_sel)+1;% records the number of values for each interpolation point (in case of subdomain overlap) 687 EM = tps_eval(epoints,ctrs); 664 688 Shiftx(ind_sel)=Shiftx(ind_sel)+EM*U_tps(1:nbvec_sub+3,isub); 665 689 Shifty(ind_sel)=Shifty(ind_sel)+EM*V_tps(1:nbvec_sub+3,isub); … … 672 696 end 673 697 end 674 mask=''; 675 if par_civ2.CheckMask&&~isempty(par_civ2.Mask)&& ~strcmp(maskname,par_civ2.Mask)% mask exist, not already read in civ1 676 mask=imread(par_civ2.Mask); 698 if par_civ2.CheckMask&&~isempty(par_civ2.Mask) 699 if strcmp(maskname,par_civ2.Mask)% mask exist, not already read in civ1 700 par_civ2.Mask=mask; %use mask already opened 701 else 702 par_civ2.Mask=imread(par_civ2.Mask);%update the mask, and store it for future use 703 mask=par_civ2.Mask; 704 maskname=par_civ2.Mask; 705 end 677 706 end 678 707 ibx2=ceil(par_civ2.CorrBoxSize(1)/2); … … 680 709 par_civ2.SearchBoxSize(1)=2*ibx2+9;% search ara +-4 pixels around the guess 681 710 par_civ2.SearchBoxSize(2)=2*iby2+9; 682 Civ2_Dt=time(i2+1,j2+1)-time(i1+1,j1+1); 711 if strcmp(Param.ActionInput.ListCompareMode,'displacement') 712 Civ1_Dt=1; 713 Civ2_Dt=1; 714 elseif exist('time','var') 715 Civ2_Dt=time(i2+1,j2+1)-time(i1+1,j1+1); 716 else 717 Civ2_Dt=1;%TO CHECK, TEST 718 end 683 719 par_civ2.SearchBoxShift=(Civ2_Dt/Civ1_Dt)*[Shiftx(nbval>=1)./nbval(nbval>=1) Shifty(nbval>=1)./nbval(nbval>=1)]; 684 720 par_civ2.Grid=[par_civ2.Grid(nbval>=1,1)-par_civ2.SearchBoxShift(:,1)/2 par_civ2.Grid(nbval>=1,2)-par_civ2.SearchBoxShift(:,2)/2];% grid taken at the extrapolated origin of the displacement vectors … … 690 726 end 691 727 % calculate velocity data (y and v in indices, reverse to y component) 692 [xtable ytable utable vtable ctable F] = civ (par_civ2); 728 [xtable, ytable, utable, vtable, ctable, F,result_conv,errormsg] = civ (par_civ2); 729 693 730 list_param=(fieldnames(Param.ActionInput.Civ2))'; 694 731 Civ2_param=regexprep(list_param,'^.+','Civ2_$0');% insert 'Civ2_' before each string in list_param 695 732 Civ2_param=[{'Civ2_ImageA','Civ2_ImageB','Civ2_Time','Civ2_Dt'} Civ2_param]; %insert the names of the two input images 696 %indicate the values of all the global attributes in the output data 733 %indicate the values of all the global attributes in the output data 734 if exist('ImageName_A','var') 697 735 Data.Civ2_ImageA=ImageName_A; 698 736 Data.Civ2_ImageB=ImageName_B; 699 737 Data.Civ2_Time=(time(i2+1,j2+1)+time(i1+1,j1+1))/2; 700 738 Data.Civ2_Dt=Civ2_Dt; 701 % Data.Civ2_Time=1; 702 % Data.Civ2_Dt=1; 739 end 740 % Data.Civ2_Time=1; 741 % Data.Civ2_Dt=1; 703 742 for ilist=1:length(list_param) 704 743 Data.(Civ2_param{4+ilist})=Param.ActionInput.Civ2.(list_param{ilist}); … … 725 764 %% Fix2 726 765 if isfield (Param.ActionInput,'Fix2') 727 766 list_param=fieldnames(Param.ActionInput.Fix2)'; 728 767 Fix2_param=regexprep(list_param,'^.+','Fix2_$0');% insert 'Fix1_' before each string in ListFixParam 729 768 %indicate the values of all the global attributes in the output data … … 824 863 %INPUT: 825 864 % par_civ: structure of input parameters, with fields: 826 % .CorrBoxSize 827 % .SearchBoxSize 828 % .SearchBoxShift 829 % .ImageHeight 830 % .ImageWidth 831 % .Dx, Dy 832 % .Grid 833 % .Mask 834 % .MinIma 865 % .ImageA: first image for correlation (matrix) 866 % .ImageB: second image for correlation(matrix) 867 % .CorrBoxSize: 1,2 vector giving the size of the correlation box in x and y 868 % .SearchBoxSize: 1,2 vector giving the size of the search box in x and y 869 % .SearchBoxShift: 1,2 vector or 2 column matrix (for civ2) giving the shift of the search box in x and y 870 % .CorrSmooth: =1 or 2 determines the choice of the sub-pixel determination of the correlation max 871 % .ImageWidth: nb of pixels of the image in x 872 % .Dx, Dy: mesh for the PIV calculation 873 % .Grid: grid giving the PIV calculation points (alternative to .Dx .Dy) 874 % .Mask: name of a mask file or mask image matrix itself 875 % .MinIma: thresholds for image luminosity 835 876 % .MaxIma 836 % .image1:first image (matrix) 837 % image2: second image (matrix) 838 % ibx2,iby2: half size of the correlation box along x and y, in px (size=(2*iby2+1,2*ibx2+1) 839 % isx2,isy2: half size of the search box along x and y, in px (size=(2*isy2+1,2*isx2+1) 840 % shiftx, shifty: shift of the search box (in pixel index, yshift reversed) 841 % step: mesh of the measurement points (in px) 842 % subpixfinder=1 or 2 controls the curve fitting of the image correlation 843 % mask: =[] for no mask 844 % roi: 4 element vector defining a region of interest: x position, y position, width, height, (in image indices), for the whole image, roi=[]; 877 % .CheckDeformation=1 for subpixel interpolation and image deformation (linear transform) 878 % .DUDX: matrix of deformation obtained from patch at each grid point 879 % .DUDY 880 % .DVDX: 881 % .DVDY 882 845 883 function [xtable,ytable,utable,vtable,ctable,F,result_conv,errormsg] = civ (par_civ) 846 884 847 885 %% prepare measurement grid 848 886 if isfield(par_civ,'Grid')% grid points set as input 849 if ischar(par_civ.Grid)%read the drid file if the input is a file name887 if ischar(par_civ.Grid)%read the grid file if the input is a file name 850 888 par_civ.Grid=dlmread(par_civ.Grid); 851 889 par_civ.Grid(1,:)=[];%the first line must be removed (heading in the grid file) 852 890 end 891 % else par_civ.Grid is already an array 853 892 else% automatic grid 854 893 minix=floor(par_civ.Dx/2)-0.5; … … 889 928 return % get the grid only, no civ calculation 890 929 elseif ischar(par_civ.Mask) 891 par_civ.Mask=imread(par_civ.Mask); 930 par_civ.Mask=imread(par_civ.Mask);% read the mask if not allready done 892 931 end 893 932 end … … 948 987 sum_square=1;% default 949 988 mesh=1;% default 950 CheckDecimal=isfield(par_civ,'CheckDecimal')&& par_civ.CheckDecimal==1; 951 if CheckDecimal 952 mesh=0.2;%mesh in pixels for subpixel image interpolation 953 CheckDeformation=isfield(par_civ,'CheckDeformation')&& par_civ.CheckDeformation==1; 954 end 955 % vector=[0 0];%default 956 for ivec=1:nbvec 957 iref=round(par_civ.Grid(ivec,1)+0.5);% xindex on the image A for the middle of the correlation box 958 jref=round(par_civ.ImageHeight-par_civ.Grid(ivec,2)+0.5);% yindex on the image B for the middle of the correlation box 959 %if ~(checkmask && par_civ.Mask(jref,iref)<=20) %velocity not set to zero by the black mask 960 % if jref-iby2<1 || jref+iby2>par_civ.ImageHeight|| iref-ibx2<1 || iref+ibx2>par_civ.ImageWidth||... 961 % jref+shifty(ivec)-isy2<1||jref+shifty(ivec)+isy2>par_civ.ImageHeight|| iref+shiftx(ivec)-isx2<1 || iref+shiftx(ivec)+isx2>par_civ.ImageWidth % we are outside the image 962 % F(ivec)=3; 963 % else 964 F(ivec)=0; 965 subrange1_x=iref-ibx2:iref+ibx2;% x indices defining the first subimage 966 subrange1_y=jref-iby2:jref+iby2;% y indices defining the first subimage 967 subrange2_x=iref+shiftx(ivec)-isx2:iref+shiftx(ivec)+isx2;%x indices defining the second subimage 968 subrange2_y=jref+shifty(ivec)-isy2:jref+shifty(ivec)+isy2;%y indices defining the second subimage 969 image1_crop=MinA*ones(numel(subrange1_y),numel(subrange1_x));% default value=min of image A 970 image2_crop=MinA*ones(numel(subrange2_y),numel(subrange2_x));% default value=min of image A 971 check1_x=subrange1_x>=1 & subrange1_x<=par_civ.ImageWidth;% check which points in the subimage 1 are contained in the initial image 1 972 check1_y=subrange1_y>=1 & subrange1_y<=par_civ.ImageHeight; 973 check2_x=subrange2_x>=1 & subrange2_x<=par_civ.ImageWidth;% check which points in the subimage 2 are contained in the initial image 2 974 check2_y=subrange2_y>=1 & subrange2_y<=par_civ.ImageHeight; 975 976 image1_crop(check1_y,check1_x)=par_civ.ImageA(subrange1_y(check1_y),subrange1_x(check1_x));%extract a subimage (correlation box) from image A 977 image2_crop(check2_y,check2_x)=par_civ.ImageB(subrange2_y(check2_y),subrange2_x(check2_x));%extract a larger subimage (search box) from image B 978 image1_mean=mean(mean(image1_crop)); 979 image2_mean=mean(mean(image2_crop)); 980 %threshold on image minimum 981 if check_MinIma && (image1_mean < par_civ.MinIma || image2_mean < par_civ.MinIma) 982 F(ivec)=3; 983 end 984 %threshold on image maximum 985 if check_MaxIma && (image1_mean > par_civ.MaxIma || image2_mean > par_civ.MaxIma) 986 F(ivec)=3; 987 end 988 % end 989 if F(ivec)~=3 990 image1_crop=image1_crop-image1_mean;%substract the mean 991 image2_crop=image2_crop-image2_mean; 992 if CheckDecimal 993 xi=(1:mesh:size(image1_crop,2)); 994 yi=(1:mesh:size(image1_crop,1))'; 989 CheckDeformation=isfield(par_civ,'CheckDeformation')&& par_civ.CheckDeformation==1; 990 if CheckDeformation 991 mesh=0.25;%mesh in pixels for subpixel image interpolation (x 4 in each direction) 992 end 993 if par_civ.CorrSmooth~=0 % par_civ.CorrSmooth=0 implies no civ computation (just input image and grid points viven) 994 for ivec=1:nbvec 995 iref=round(par_civ.Grid(ivec,1)+0.5);% xindex on the image A for the middle of the correlation box 996 jref=round(par_civ.ImageHeight-par_civ.Grid(ivec,2)+0.5);% yindex on the image B for the middle of the correlation box 997 F(ivec)=0; 998 subrange1_x=iref-ibx2:iref+ibx2;% x indices defining the first subimage 999 subrange1_y=jref-iby2:jref+iby2;% y indices defining the first subimage 1000 subrange2_x=iref+shiftx(ivec)-isx2:iref+shiftx(ivec)+isx2;%x indices defining the second subimage 1001 subrange2_y=jref+shifty(ivec)-isy2:jref+shifty(ivec)+isy2;%y indices defining the second subimage 1002 image1_crop=MinA*ones(numel(subrange1_y),numel(subrange1_x));% default value=min of image A 1003 image2_crop=MinA*ones(numel(subrange2_y),numel(subrange2_x));% default value=min of image A 1004 check1_x=subrange1_x>=1 & subrange1_x<=par_civ.ImageWidth;% check which points in the subimage 1 are contained in the initial image 1 1005 check1_y=subrange1_y>=1 & subrange1_y<=par_civ.ImageHeight; 1006 check2_x=subrange2_x>=1 & subrange2_x<=par_civ.ImageWidth;% check which points in the subimage 2 are contained in the initial image 2 1007 check2_y=subrange2_y>=1 & subrange2_y<=par_civ.ImageHeight; 1008 image1_crop(check1_y,check1_x)=par_civ.ImageA(subrange1_y(check1_y),subrange1_x(check1_x));%extract a subimage (correlation box) from image A 1009 image2_crop(check2_y,check2_x)=par_civ.ImageB(subrange2_y(check2_y),subrange2_x(check2_x));%extract a larger subimage (search box) from image B 1010 image1_mean=mean(mean(image1_crop)); 1011 image2_mean=mean(mean(image2_crop)); 1012 %threshold on image minimum 1013 if check_MinIma && (image1_mean < par_civ.MinIma || image2_mean < par_civ.MinIma) 1014 F(ivec)=3; 1015 end 1016 %threshold on image maximum 1017 if check_MaxIma && (image1_mean > par_civ.MaxIma || image2_mean > par_civ.MaxIma) 1018 F(ivec)=3; 1019 end 1020 1021 if F(ivec)~=3 1022 image1_crop=image1_crop-image1_mean;%substract the mean 1023 image2_crop=image2_crop-image2_mean; 995 1024 if CheckDeformation 1025 xi=(1:mesh:size(image1_crop,2)); 1026 yi=(1:mesh:size(image1_crop,1))'; 996 1027 [XI,YI]=meshgrid(xi-ceil(size(image1_crop,2)/2),yi-ceil(size(image1_crop,1)/2)); 997 1028 XIant=XI-par_civ.DUDX(ivec)*XI-par_civ.DUDY(ivec)*YI+ceil(size(image1_crop,2)/2); 998 1029 YIant=YI-par_civ.DVDX(ivec)*XI-par_civ.DVDY(ivec)*YI+ceil(size(image1_crop,1)/2); 999 1030 image1_crop=interp2(image1_crop,XIant,YIant); 1000 else 1001 image1_crop=interp2(image1_crop,xi,yi); 1002 end 1003 xi=(1:mesh:size(image2_crop,2)); 1004 yi=(1:mesh:size(image2_crop,1))'; 1005 image2_crop=interp2(image2_crop,xi,yi); 1006 end 1007 sum_square=sum(sum(image1_crop.*image1_crop)); 1008 %reference: Oliver Pust, PIV: Direct Cross-Correlation 1009 result_conv= conv2(image2_crop,flipdim(flipdim(image1_crop,2),1),'valid'); 1010 corrmax= max(max(result_conv)); 1011 result_conv=(result_conv/corrmax)*255; %normalize, peak=always 255 1012 %Find the correlation max, at 255 1013 [y,x] = find(result_conv==255,1); 1014 if ~isempty(y) && ~isempty(x) 1015 try 1016 if par_civ.CorrSmooth==1 1017 [vector,F(ivec)] = SUBPIXGAUSS (result_conv,x,y); 1018 elseif par_civ.CorrSmooth==2 1019 [vector,F(ivec)] = SUBPIX2DGAUSS (result_conv,x,y); 1020 end 1021 % if ~isfield(par_civ,'CheckDeformation') 1022 utable(ivec)=vector(1)*mesh+shiftx(ivec); 1023 vtable(ivec)=vector(2)*mesh+shifty(ivec); 1024 % else 1025 % utable(ivec)=shiftx(ivec);% TEST TEST !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 1026 % vtable(ivec)=shifty(ivec); 1027 % end 1028 xtable(ivec)=iref+utable(ivec)/2-0.5;% convec flow (velocity taken at the point middle from imgae 1 and 2) 1029 ytable(ivec)=jref+vtable(ivec)/2-0.5;% and position of pixel 1=0.5 (convention for image coordinates=0 at the edge) 1030 iref=round(xtable(ivec));% image index for the middle of the vector 1031 jref=round(ytable(ivec)); 1032 if checkmask && par_civ.Mask(jref,iref)<200 && par_civ.Mask(jref,iref)>=100 1033 utable(ivec)=0; 1034 vtable(ivec)=0; 1031 xi=(1:mesh:size(image2_crop,2)); 1032 yi=(1:mesh:size(image2_crop,1))'; 1033 image2_crop=interp2(image2_crop,xi,yi); 1034 end 1035 sum_square=sum(sum(image1_crop.*image1_crop)); 1036 %reference: Oliver Pust, PIV: Direct Cross-Correlation 1037 result_conv= conv2(image2_crop,flipdim(flipdim(image1_crop,2),1),'valid'); 1038 corrmax= max(max(result_conv)); 1039 result_conv=(result_conv/corrmax)*255; %normalize, peak=always 255 1040 %Find the correlation max, at 255 1041 [y,x] = find(result_conv==255,1); 1042 if ~isempty(y) && ~isempty(x) 1043 try 1044 if par_civ.CorrSmooth==1 1045 [vector,F(ivec)] = SUBPIXGAUSS (result_conv,x,y); 1046 elseif par_civ.CorrSmooth==2 1047 [vector,F(ivec)] = SUBPIX2DGAUSS (result_conv,x,y); 1048 end 1049 utable(ivec)=vector(1)*mesh+shiftx(ivec); 1050 vtable(ivec)=vector(2)*mesh+shifty(ivec); 1051 xtable(ivec)=iref+utable(ivec)/2-0.5;% convec flow (velocity taken at the point middle from imgae 1 and 2) 1052 ytable(ivec)=jref+vtable(ivec)/2-0.5;% and position of pixel 1=0.5 (convention for image coordinates=0 at the edge) 1053 iref=round(xtable(ivec));% image index for the middle of the vector 1054 jref=round(ytable(ivec)); 1055 if checkmask && par_civ.Mask(jref,iref)<200 && par_civ.Mask(jref,iref)>=100 1056 utable(ivec)=0; 1057 vtable(ivec)=0; 1058 F(ivec)=3; 1059 end 1060 ctable(ivec)=corrmax/sum_square;% correlation value 1061 catch ME 1035 1062 F(ivec)=3; 1036 1063 end 1037 ctable(ivec)=corrmax/sum_square;% correlation value 1038 catch ME 1064 else 1039 1065 F(ivec)=3; 1040 1066 end 1041 else1042 F(ivec)=3;1043 1067 end 1044 1068 end -
trunk/src/uvmat.m
r853 r856 487 487 set(handles.MenuOpenCampaign,'ForegroundColor',[1 1 0]) 488 488 drawnow 489 RootPath=get(handles.RootPath,'String'); 490 if isempty(RootPath) 491 RootPath=get(handles.RootPath,'UserData');%use Rootpath recored from the personal file at uvmat opening 492 end 493 CampaignPath=fileparts(fileparts(RootPath)); 494 DirFull=uigetfile_uvmat('define this path as the Campaign folder:',CampaignPath,'uigetdir'); 495 %DirFull = uigetdir(CampaignPath,'Select a Campaign dir, then press OK'); 496 if isempty(DirFull) 497 return 498 end 499 OutPut=browse_data(DirFull,'on');% open the GUI browse_data to get select a campaign dir, experiment and device 489 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 490 DataSeries=fullfile(RootPath,SubDir); 491 if isempty(DataSeries) %loads the previously stored file name and set it as default in the file_input box 492 DataSeries=get(handles.RootPath,'UserData'); 493 end 494 % RootPath=get(handles.RootPath,'String'); 495 % if isempty(RootPath) 496 % RootPath=get(handles.RootPath,'UserData');%use Rootpath recored from the personal file at uvmat opening 497 % end 498 % CampaignPath=fileparts(fileparts(RootPath)); 499 % DirFull=uigetfile_uvmat('define this path as the Campaign folder:',CampaignPath,'uigetdir'); 500 % %DirFull = uigetdir(CampaignPath,'Select a Campaign dir, then press OK'); 501 % if isempty(DirFull) 502 % return 503 % end 504 if isempty(DataSeries)||~ischar(DataSeries) 505 DataSeries=pwd; 506 end 507 OutPut=browse_data(DataSeries,'on');% open the GUI browse_data to get select a campaign dir, experiment and device 500 508 if ~isfield(OutPut,'Campaign') 501 509 return 502 510 end 503 fileinput=uigetfile_uvmat('pick an input file',fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1})); 511 DataSeries=fullfile(OutPut.Campaign,OutPut.Experiment{1},OutPut.DataSeries{1}); 512 fileinput=uigetfile_uvmat('pick an input file',DataSeries); 504 513 hh=dir(fileinput); 505 514 if numel(hh)>1 … … 511 520 MenuCampaign=[{get(handles.MenuCampaign_1,'Label')};{get(handles.MenuCampaign_2,'Label')};... 512 521 {get(handles.MenuCampaign_3,'Label')};{get(handles.MenuCampaign_4,'Label')};{get(handles.MenuCampaign_5,'Label')}]; 513 check_dir=isempty(find(strcmp(D irFull,MenuCampaign)));522 check_dir=isempty(find(strcmp(DataSeries,MenuCampaign))); 514 523 if check_dir %insert the new campaign in the list if it is not found 515 524 MenuCampaign(end)=[]; %suppress the last item 516 MenuCampaign=[{D irFull};MenuCampaign];%insert the new campaign525 MenuCampaign=[{DataSeries};MenuCampaign];%insert the new campaign 517 526 for ilist=1:numel(MenuCampaign) 518 527 set(handles.(['MenuCampaign_' num2str(ilist)]),'Label',MenuCampaign{ilist})
Note: See TracChangeset
for help on using the changeset viewer.