Changeset 855
- Timestamp:
- Jan 23, 2015, 9:48:26 AM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/mouse_down.m
r809 r855 246 246 end 247 247 248 if isempty(huvmat)%further options require the uvmat GUI249 return250 end251 252 %% ruler has second priority253 if test_ruler && ~isempty(xy)254 AxeData.RulerCoord(1,1:2)=xy(1,1:2);255 AxeData.RulerHandle=line([xy(1,1) xy(1,1)],[xy(1,2) xy(1,2)],'Color','m','Tag','ruler');256 AxeData.Drawing='ruler';257 set(hchild,'UserData',AxeData);258 return259 end260 261 248 %% PIV test 262 249 if test_piv … … 268 255 copyobj(AxeData.TitleHandle,newaxes) 269 256 colorbar 270 end 257 % export image correlation matrix and local U,V values in the work space 258 global DataCorrImage 259 DataCorrImage.Corr=get(AxeData.CurrentCorrImage,'CData'); 260 Uvec=get(AxeData.CurrentVector,'XData'); 261 DataCorrImage.U=Uvec(2); 262 Vvec=get(AxeData.CurrentVector,'YData'); 263 DataCorrImage.V=Vvec(2); 264 evalin('base','global DataCorrImage')%make CurData global in the workspace 265 evalin('base','DataCorrImage') %display CurData in the workspace 266 commandwindow; %brings the Matlab command window to the front 267 end 268 269 if isempty(huvmat)%further options require the uvmat GUI 270 return 271 end 272 273 %% ruler has second priority 274 if test_ruler && ~isempty(xy) 275 AxeData.RulerCoord(1,1:2)=xy(1,1:2); 276 AxeData.RulerHandle=line([xy(1,1) xy(1,1)],[xy(1,2) xy(1,2)],'Color','m','Tag','ruler'); 277 AxeData.Drawing='ruler'; 278 set(hchild,'UserData',AxeData); 279 return 280 end 281 271 282 272 283 %% desable object creation and vector editing if NbDim different from 2 -
trunk/src/mouse_motion.m
r837 r855 240 240 xround=Field.X(ind_pt); 241 241 yround=Field.Y(ind_pt); 242 % par.Grid=[xround size(Field.A,1)-yround+1];243 242 par.Grid=[xround yround]; 244 243 % mark the correlation box with a rectangle … … 247 246 par.ImageHeight=size(par.ImageA,1); 248 247 par.ImageWidth=size(par.ImageA,2); 249 Param. Civ1=par;248 Param.ActionInput.Civ1=par; 250 249 ibx2=floor((par.CorrBoxSize(1)-1)/2); 251 250 iby2=floor((par.CorrBoxSize(2)-1)/2); … … 269 268 set(hhhh,'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2]) 270 269 end 271 [Data,errormsg,result_conv]= civ_matlab(Param); 270 Param.Action.RUN=1; 271 Param.ActionInput.ListCompareMode='PIV'; 272 [Data,errormsg,result_conv]= civ_series(Param); 272 273 if ~isempty(errormsg) 273 274 text_displ_5=errormsg; -
trunk/src/series.m
r852 r855 1460 1460 if strcmp(ActionExt,'.m')% case of Matlab function (uncompiled) 1461 1461 NbCore=1;% one core used only (limitation of Matlab licences) 1462 msgbox_uvmat('WARNING','Number of cores =1: select the compiled version civ_matlab.sh for multi-core processing');1462 msgbox_uvmat('WARNING','Number of cores =1: select the compiled version .sh for multi-core processing'); 1463 1463 extra_oar=''; 1464 1464 else -
trunk/src/series/civ_input.m
r854 r855 83 83 set(handles.CheckThreshold,'Visible','on') 84 84 set(handles.CheckDeformation,'Value',0)% desactivate (work in progress) 85 set(handles.CheckDecimal,'Value',0)% desactivate (work in progress)85 %set(handles.CheckDecimal,'Value',0)% desactivate (work in progress) 86 86 end 87 87 switch Param.Action.ActionName … … 169 169 170 170 %% display the min and max indices for the whole file series 171 if isempty(Param.IndexRange.MaxIndex_i)|| isempty(Param.IndexRange.MinIndex_i) 172 msgbox_uvmat('ERROR','REFRESH the input files in the GUI series') 173 return 174 end 171 175 MaxIndex_i=Param.IndexRange.MaxIndex_i(iview_image); 172 176 MinIndex_i=Param.IndexRange.MinIndex_i(iview_image); … … 281 285 end 282 286 else %case of netcdf file opening, start with the stage read in the file if the input file is being refreshed 283 if isequal(get(hhseries.REFRESH,'BackgroundColor'),[1 1 0]) && ~isfield(Param.ActionInput,'ConfigSource') 284 answer=msgbox_uvmat('INPUT_Y-N',['import the civ parameters from the netcdf file']); 285 if strcmp(answer,'Yes') 287 if isequal(get(hhseries.REFRESH,'BackgroundColor'),[1 1 0]) &&... 288 ~(isfield(Param,'ActionInput') && isfield(Param.ActionInput,'ConfigSource')) 289 % answer=msgbox_uvmat('INPUT_Y-N',['import the civ parameters from the netcdf file']); 290 % if strcmp(answer,'Yes') 286 291 for index = 1:min(ind_opening,5) 287 292 set(handles.(ListOptions{index}),'value',0) … … 294 299 end 295 300 checkrefresh=1; 296 end301 % end 297 302 end 298 303 if ind_opening>=3 299 set(handles. iterate,'Visible','on')% make visible the switch 'iterate/repet' for Civ2.304 set(handles.CheckCiv3,'Visible','on')% make visible the switch 'iterate/repet' for Civ2. 300 305 else 301 set(handles. iterate,'Visible','off')306 set(handles.CheckCiv3,'Visible','off') 302 307 end 303 308 end … … 493 498 end 494 499 if max(checkbox(1:3))==0 && get(handles.CheckCiv2,'UserData')==6,% no operation asked before Civ2 and input file ready for civ3 495 set(handles. iterate,'Visible','on')496 else 497 set(handles. iterate,'Visible','off')500 set(handles.CheckCiv3,'Visible','on') 501 else 502 set(handles.CheckCiv3,'Visible','off') 498 503 end 499 504 … … 513 518 %------------------------------------------------------------------------ 514 519 515 ActionInput=read_GUI(handles.civ_input); 516 517 %% correct inp put inconsistencies520 ActionInput=read_GUI(handles.civ_input);% read the infos on the GUI civ_input 521 522 %% correct input inconsistencies 518 523 if isfield(ActionInput,'Civ1') 519 524 checkeven=(mod(ActionInput.Civ1.CorrBoxSize,2)==0); … … 531 536 end 532 537 538 %% correct mask or grid name for Windows system (replace '\' by '/') 539 if isfield(ActionInput,'Civ1') 540 if isfield(ActionInput.Civ1,'Mask') 541 ActionInput.Civ1.Mask=regexprep(ActionInput.Civ1.Mask,'\','/'); 542 end 543 if isfield(ActionInput.Civ1,'Grid') 544 ActionInput.Civ1.Grid=regexprep(ActionInput.Civ1.Grid,'\','/'); 545 end 546 end 547 if isfield(ActionInput,'Civ2') 548 if isfield(ActionInput.Civ2,'Mask') 549 ActionInput.Civ2.Mask=regexprep(ActionInput.Civ2.Mask,'\','/'); 550 end 551 if isfield(ActionInput.Civ2,'Grid') 552 ActionInput.Civ2.Grid=regexprep(ActionInput.Civ2.Grid,'\','/'); 553 end 554 end 555 556 %% exit the GUI and close it 533 557 handles.output.ActionInput=ActionInput; 534 % correct mask or grid name for Windows system (replace '\' by '/')535 if isfield(handles.output.ActionInput,'Civ1')536 if isfield(handles.output.ActionInput.Civ1,'Mask')537 handles.output.ActionInput.Civ1.Mask=regexprep(handles.output.ActionInput.Civ1.Mask,'\','/');538 end539 if isfield(handles.output.ActionInput.Civ1,'Grid')540 handles.output.ActionInput.Civ1.Grid=regexprep(handles.output.ActionInput.Civ1.Grid,'\','/');541 end542 end543 if isfield(handles.output.ActionInput,'Civ2')544 if isfield(handles.output.ActionInput.Civ2,'Mask')545 handles.output.ActionInput.Civ2.Mask=regexprep(handles.output.ActionInput.Civ2.Mask,'\','/');546 end547 if isfield(handles.output.ActionInput.Civ2,'Grid')548 handles.output.ActionInput.Civ2.Grid=regexprep(handles.output.ActionInput.Civ2.Grid,'\','/');549 end550 end551 558 guidata(hObject, handles);% Update handles structure 552 559 uiresume(handles.civ_input); … … 1689 1696 drawnow 1690 1697 if get(handles.TestCiv1,'Value') 1691 set(handles.TestCiv1,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch 1692 [Data,Param.Civ1]=get_param_civ1(handles); 1693 Grid=civ_matlab(Param);% get the grid of x, y positions set for PIV 1694 hview_field=view_field(Data); %view the image in the GUI view_field 1698 set(handles.TestCiv1,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch 1699 %Param.Action.RUN=1; 1700 Param.ActionInput=read_GUI(handles.civ_input); 1701 par_civ=Param.ActionInput.Civ1; 1702 [Data,ImageName_B]=get_param_civ1(handles); 1703 1704 %% create the figure view_field for image visualization 1705 hview_field=view_field(Data); %view the image in the GUI view_field 1695 1706 set(0,'CurrentFigure',hview_field) 1696 1707 hhview_field=guihandles(hview_field); … … 1698 1709 ViewData=get(hview_field,'UserData'); 1699 1710 ViewData.CivHandle=handles.civ_input;% indicate the handle of the civ GUI in view_field 1700 ViewData.PlotAxes.B=imread(Param.Civ1.ImageName_B);%store the second image in the UserData of the GUI view_field 1701 ViewData.PlotAxes.X=Grid.Civ1_X; %keep the set of points in memeory 1702 ViewData.PlotAxes.Y=Grid.Civ1_Y; 1703 set(hview_field,'UserData',ViewData) 1704 corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display 1711 ViewData.PlotAxes.B=imread(ImageName_B);%store the second image in the UserData of the GUI view_field 1712 1713 %% prepare measurement grid 1714 if isfield(par_civ,'Grid')% grid points set as input 1715 par_civ.Grid=dlmread(par_civ.Grid); 1716 par_civ.Grid(1,:)=[];%the first line must be removed (heading in the grid file) 1717 else% automatic grid 1718 minix=floor(par_civ.Dx/2)-0.5; 1719 maxix=minix+par_civ.Dx*floor((size(Data.A,2)-1)/par_civ.Dx); 1720 miniy=floor(par_civ.Dy/2)-0.5; 1721 maxiy=minix+par_civ.Dy*floor((size(Data.A,1)-1)/par_civ.Dy); 1722 [GridX,GridY]=meshgrid(minix:par_civ.Dx:maxix,miniy:par_civ.Dy:maxiy); 1723 ViewData.PlotAxes.X=reshape(GridX,[],1); 1724 ViewData.PlotAxes.Y=reshape(GridY,[],1); 1725 end 1726 1727 set(hview_field,'UserData',ViewData)% store the info in the UserData of image view_field 1728 1729 %% look for a current figure for image correlation display 1730 corrfig=findobj(allchild(0),'tag','corrfig'); 1705 1731 if isempty(corrfig) 1706 1732 corrfig=figure; … … 1708 1734 set(corrfig,'name','image correlation') 1709 1735 set(corrfig,'DeleteFcn',{@closeview_field})% 1710 % end1711 1736 set(handles.TestCiv1,'BackgroundColor',[1 0 0]) 1712 1737 else … … 1733 1758 function TestPatch1_Callback(hObject, eventdata, handles) 1734 1759 1735 if get(handles.TestPatch1,'Value') 1736 if get(handles.CheckCiv1,'Value') 1737 if ~get(handles.CheckFix1,'Value') 1738 msgbox_uvmat('ERROR','perform FIX1 before testing Patch1') 1739 return 1740 end 1741 set(handles.TestPatch1,'BackgroundColor',[1 1 0]) 1742 drawnow 1743 [Data,Param.Civ1]=get_param_civ1(handles); 1744 Param.Fix1=read_GUI(handles.Fix1); 1745 [Data,errormsg]=civ_matlab(Param);% get the civ1 results 1746 errormsg=struct2nc('test_civ1.nc',Data); 1747 InputFile='test_civ1.nc'; 1748 if ~isempty(errormsg) 1749 msgbox_uvmat('ERROR',['error in temporary file writing: ' errormsg]) 1750 return 1751 end 1752 else 1753 hseries=findobj(allchild(0),'Tag','series'); 1754 hhseries=guidata(hseries); 1755 InputTable=get(hhseries.InputTable,'Data'); 1756 if ~strcmp(InputTable{1,5},'.nc'); 1757 msgbox_uvmat('ERROR', 'To test patch, first perform Civ1 and Fix1, then open the resulting netcdf file with ''series''') 1758 return 1759 end 1760 set(handles.TestPatch1,'BackgroundColor',[1 1 0]) 1761 drawnow 1762 ref_i=str2double(get(handles.ref_i,'String')); 1763 if strcmp(get(handles.ref_j,'Visible'),'on') 1764 ref_j=str2double(get(handles.ref_j,'String')); 1765 else 1766 ref_j=1;%default 1767 end 1768 PairString=get(hhseries.PairString,'Data'); 1769 [i1,i2,j1,j2] = get_file_index(ref_i,ref_j,PairString{1}); 1770 InputFile=fullfile_uvmat(InputTable{1,1},InputTable{1,2},InputTable{1,3},InputTable{1,5},InputTable{1,4},... 1771 i1,i2,j1,j2); 1772 end 1773 Param=[]; 1774 Param.Patch1=read_GUI(handles.Patch1); 1775 Param.Patch1.CivFile=InputFile; 1776 SmoothingParam=(Param.Patch1.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value 1777 Data=nc2struct(InputFile); 1760 if get(handles.TestPatch1,'Value')% if TestPatch1 is activated 1761 set(handles.TestPatch1,'BackgroundColor',[1 1 0])%paint TestPatch1 button in yellow to induicate activation 1762 hseries=findobj(allchild(0),'Tag','series'); 1763 Param=read_GUI(hseries); 1764 Param.Action.RUN=1; 1765 Param.ActionInput=read_GUI(handles.civ_input); 1766 Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series 1767 [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results 1768 1769 %% prepare Param for iterative Patch processing without input file reading 1770 Param.Civ1_X=Data.Civ1_X; 1771 Param.Civ1_Y=Data.Civ1_Y; 1772 Param.Civ1_U=Data.Civ1_U; 1773 Param.Civ1_V=Data.Civ1_V; 1774 Param.Civ1_FF=Data.Civ1_FF; 1775 Param=rmfield(Param,'InputTable');%desactivate input file reading 1776 if isfield(Param.ActionInput,'Civ1') 1777 Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant 1778 end 1779 if isfield(Param.ActionInput,'Fix1') 1780 Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant 1781 end 1782 SmoothingParam=(Param.ActionInput.Patch1.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value 1778 1783 NbGood=numel(find(Data.Civ1_FF==0)); 1779 1784 for irho=1:7 1780 Param. Patch1.FieldSmooth=SmoothingParam(irho);1781 [Data,errormsg]= civ_matlab(Param);% get the grid of x, y positions set for PIV1785 Param.ActionInput.Patch1.FieldSmooth=SmoothingParam(irho); 1786 [Data,errormsg]= civ_series(Param);%apply the processing fct 1782 1787 if ~isempty(errormsg) 1783 1788 msgbox_uvmat('ERROR',errormsg) … … 1794 1799 grid on 1795 1800 legend('rms velocity diff. Patch1-Civ1 (pixels)','proportion of excluded vectors (between 0 to 1)') 1796 XLabel('smoothing parameter')1797 YLabel('smoothing effect')1801 xlabel('smoothing parameter') 1802 ylabel('smoothing effect') 1798 1803 set(handles.TestPatch1,'BackgroundColor',[1 0 0]) 1799 1804 else … … 2020 2025 2021 2026 %------------------------------------------------------------------------ 2022 function [Data, par_civ1]=get_param_civ1(handles)2027 function [Data,ImageName_B]=get_param_civ1(handles) 2023 2028 2024 2029 ref_i=str2double(get(handles.ref_i,'String'));% read reference i index … … 2068 2073 Data.nx=[1 size(Data.A,2)]; 2069 2074 Data.CoordUnit='pixel';% used to set equal scaling for x and y in image dispa=ly 2070 par_civ1=read_GUI(handles.Civ1);2071 FileInfo=get_file_info(ImageName_A);2072 par_civ1.FileTypeA=FileInfo.FileType;2073 par_civ1.ImageWidth=size(Data.A,2);2074 par_civ1.ImageHeight=size(Data.A,1);2075 par_civ1.Mask='all';% will provide only the grid set for PIV, no image correlation2076 par_civ1.FrameIndexA=num2str(i1);2077 par_civ1.FrameIndexB=num2str(i2);2078 par_civ1.ImageName_B=ImageName_B;2075 % par_civ1=read_GUI(handles.Civ1); 2076 % FileInfo=get_file_info(ImageName_A); 2077 % par_civ1.FileTypeA=FileInfo.FileType; 2078 % par_civ1.ImageWidth=size(Data.A,2); 2079 % par_civ1.ImageHeight=size(Data.A,1); 2080 % par_civ1.Mask='all';% will provide only the grid set for PIV, no image correlation 2081 % par_civ1.FrameIndexA=num2str(i1); 2082 % par_civ1.FrameIndexB=num2str(i2); 2083 % par_civ1.ImageName_B=ImageName_B; 2079 2084 2080 2085 %------------------------------------------------------------------------ … … 2122 2127 end 2123 2128 2124 % --- Executes on selection change in iterate.2125 function iterate_Callback(hObject, eventdata, handles)2129 % --- Executes on selection change in CheckCiv3. 2130 function CheckCiv3_Callback(hObject, eventdata, handles) 2126 2131 2127 2132 %------------------------------------------------------------------------ -
trunk/src/series/civ_series.m
r854 r855 5 5 % filter_tps: make interpolation-smoothing 6 6 %------------------------------------------------------------------------ 7 % function [Data,errormsg,result_conv]= civ_series(Param ,ncfile)7 % function [Data,errormsg,result_conv]= civ_series(Param) 8 8 % 9 9 %OUTPUT … … 13 13 % 14 14 %INPUT: 15 % Param: input images and processing parameters 16 % .Civ1: for civ1 17 % .Fix1: 18 % .Patch1: 19 % .Civ2: for civ2 20 % .Fix2: 21 % .Patch2: 22 % ncfile: name of a netcdf file to be created for the result (extension .nc) 23 % 15 % Param: Matlab structure of input parameters 16 % Param contains info of the GUI series using the fct read_GUI. 17 % Param.Action.RUN = 0 (to set the status of the GUI series) or =1 to RUN the computation 18 % Param.InputTable: sets the input file(s) 19 % if absent, the fct looks for input data in Param.ActionInput (test mode) 20 % Param.OutputSubDir: sets the folder name of output file(s, 21 % if absent no file is produced, result in the output structure Data (test mode) 22 % Param.ActionInput: substructure with the parameters provided by the GUI civ_input 23 % .Civ1: parameters for civ1 24 % .Fix1: parameters for fix1 25 % .Patch1: 26 % .Civ2: for civ2 27 % .Fix2: 28 % .Patch2: 29 24 30 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 25 31 % Copyright 2011-2014, LEGI / CNRS UJF G-INP, Joel.Sommeria@legi.grenoble-inp.fr … … 73 79 checkrun=0; 74 80 end 81 82 %% test input 75 83 if ~isfield(Param,'ActionInput') 76 84 disp_uvmat('ERROR','no parameter set for PIV',checkrun) 77 85 return 78 86 end 79 hseries=findobj(allchild(0),'Tag','series'); 80 RUNHandle=findobj(hseries,'Tag','RUN');%handle of RUN button in GUI series 81 WaitbarHandle=findobj(hseries,'Tag','Waitbar');%handle of waitbar in GUI series 82 83 %% input files and indexing 84 % NbField=1; 85 MaxIndex_i=Param.IndexRange.MaxIndex_i; 86 MinIndex_i=Param.IndexRange.MinIndex_i; 87 MaxIndex_j=ones(size(MaxIndex_i));MinIndex_j=ones(size(MinIndex_i)); 88 if isfield(Param.IndexRange,'MaxIndex_j')&& isfield(Param.IndexRange,'MinIndex_j') 89 MaxIndex_j=Param.IndexRange.MaxIndex_j; 90 MinIndex_j=Param.IndexRange.MinIndex_j; 91 end 92 if isfield(Param,'InputTable') 93 [tild,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 94 % iview_nc=0;% series index (iview) for an input nc file (for civ2 or patch2) 95 iview_A=0;% series index (iview) for the first image series 96 iview_B=0;% series index (iview) for the second image series (only non zero for option 'shift' comparing two image series ) 97 if Param.ActionInput.CheckCiv1 98 iview_A=1;% usual PIV, the image series is on the first line of the table 99 elseif Param.ActionInput.CheckCiv2 % civ2 is performed without Civ1, a netcdf file series is needed in the first table line 100 iview_A=2;% the second line is used for the input images of Civ2 101 end 102 if strcmp(Param.ActionInput.ListCompareMode,'shift') 103 iview_B=iview_A+1; % the second image series is on the next line of the input table 104 end 105 if iview_A~=0 106 RootPath_A=Param.InputTable{iview_A,1}; 107 RootFile_A=Param.InputTable{iview_A,3}; 108 SubDir_A=Param.InputTable{iview_A,2}; 109 NomType_A=Param.InputTable{iview_A,4}; 110 FileExt_A=Param.InputTable{iview_A,5}; 111 if iview_B==0 112 iview_B=iview_A;% the second image series is the same as the first 113 end 114 RootPath_B=Param.InputTable{iview_B,1}; 115 RootFile_B=Param.InputTable{iview_B,3}; 116 SubDir_B=Param.InputTable{iview_B,2}; 117 NomType_B=Param.InputTable{iview_B,4}; 118 FileExt_B=Param.InputTable{iview_B,5}; 119 end 120 121 PairCiv2=''; 122 switch Param.ActionInput.ListCompareMode 123 case 'PIV' 124 PairCiv1=Param.ActionInput.PairIndices.ListPairCiv1; 125 if isfield(Param.ActionInput.PairIndices,'ListPairCiv2') 126 PairCiv2=Param.ActionInput.PairIndices.ListPairCiv2;%string which determines the civ2 pair 127 end 128 if iview_A==1% if Civ1 is performed 129 [i1_series_Civ1,i2_series_Civ1,j1_series_Civ1,j2_series_Civ1,check_bounds,NomTypeNc]=... 130 find_pair_indices(PairCiv1,i1_series{1},j1_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j); 131 if ~isempty(PairCiv2) 132 [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds_Civ2]=... 133 find_pair_indices(PairCiv2,i1_series{1},j1_series{1},MinIndex_i(1),MaxIndex_i(1),MinIndex_j(1),MaxIndex_j(1)); 134 check_bounds=check_bounds | check_bounds_Civ2; 87 iview_A=0;%default values 88 NbField=1; 89 RUNHandle=[]; 90 CheckInputFile=isfield(Param,'InputTable');%= 1 in test use for TestCiv (no nc file involved) 91 CheckOutputFile=isfield(Param,'OutputSubDir');%= 1 in test use for TestPatch (no nc file produced) 92 93 %% input files and indexing (skipped in Test mode) 94 if CheckInputFile 95 hseries=findobj(allchild(0),'Tag','series'); 96 RUNHandle=findobj(hseries,'Tag','RUN');%handle of RUN button in GUI series 97 WaitbarHandle=findobj(hseries,'Tag','Waitbar');%handle of waitbar in GUI series 98 MaxIndex_i=Param.IndexRange.MaxIndex_i; 99 MinIndex_i=Param.IndexRange.MinIndex_i; 100 MaxIndex_j=ones(size(MaxIndex_i));MinIndex_j=ones(size(MinIndex_i)); 101 if isfield(Param.IndexRange,'MaxIndex_j')&& isfield(Param.IndexRange,'MinIndex_j') 102 MaxIndex_j=Param.IndexRange.MaxIndex_j; 103 MinIndex_j=Param.IndexRange.MinIndex_j; 104 end 105 if isfield(Param,'InputTable') 106 [tild,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 107 % iview_nc=0;% series index (iview) for an input nc file (for civ2 or patch2) 108 iview_A=0;% series index (iview) for the first image series 109 iview_B=0;% series index (iview) for the second image series (only non zero for option 'shift' comparing two image series ) 110 if Param.ActionInput.CheckCiv1 111 iview_A=1;% usual PIV, the image series is on the first line of the table 112 elseif Param.ActionInput.CheckCiv2 % civ2 is performed without Civ1, a netcdf file series is needed in the first table line 113 iview_A=2;% the second line is used for the input images of Civ2 114 end 115 if strcmp(Param.ActionInput.ListCompareMode,'shift') 116 iview_B=iview_A+1; % the second image series is on the next line of the input table 117 end 118 if iview_A~=0 119 RootPath_A=Param.InputTable{iview_A,1}; 120 RootFile_A=Param.InputTable{iview_A,3}; 121 SubDir_A=Param.InputTable{iview_A,2}; 122 NomType_A=Param.InputTable{iview_A,4}; 123 FileExt_A=Param.InputTable{iview_A,5}; 124 if iview_B==0 125 iview_B=iview_A;% the second image series is the same as the first 126 end 127 RootPath_B=Param.InputTable{iview_B,1}; 128 RootFile_B=Param.InputTable{iview_B,3}; 129 SubDir_B=Param.InputTable{iview_B,2}; 130 NomType_B=Param.InputTable{iview_B,4}; 131 FileExt_B=Param.InputTable{iview_B,5}; 132 end 133 134 PairCiv2=''; 135 switch Param.ActionInput.ListCompareMode 136 case 'PIV' 137 PairCiv1=Param.ActionInput.PairIndices.ListPairCiv1; 138 if isfield(Param.ActionInput.PairIndices,'ListPairCiv2') 139 PairCiv2=Param.ActionInput.PairIndices.ListPairCiv2;%string which determines the civ2 pair 135 140 end 136 else% we start from an existing Civ1 file 137 i1_series_Civ1=i1_series{1}; 138 i2_series_Civ1=i2_series{1}; 139 j1_series_Civ1=j1_series{1}; 140 j2_series_Civ1=j2_series{1}; 141 NomTypeNc=Param.InputTable{1,4}; 142 if ~isempty(PairCiv2) 143 [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds,NomTypeNc]=... 144 find_pair_indices(PairCiv2,i1_series{2},j1_series{2},MinIndex_i(2),MaxIndex_i(2),MinIndex_j(2),MaxIndex_j(2)); 141 if iview_A==1% if Civ1 is performed 142 [i1_series_Civ1,i2_series_Civ1,j1_series_Civ1,j2_series_Civ1,check_bounds,NomTypeNc]=... 143 find_pair_indices(PairCiv1,i1_series{1},j1_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j); 144 if ~isempty(PairCiv2) 145 [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds_Civ2]=... 146 find_pair_indices(PairCiv2,i1_series{1},j1_series{1},MinIndex_i(1),MaxIndex_i(1),MinIndex_j(1),MaxIndex_j(1)); 147 check_bounds=check_bounds | check_bounds_Civ2; 148 end 149 else% we start from an existing Civ1 file 150 i1_series_Civ1=i1_series{1}; 151 i2_series_Civ1=i2_series{1}; 152 j1_series_Civ1=j1_series{1}; 153 j2_series_Civ1=j2_series{1}; 154 NomTypeNc=Param.InputTable{1,4}; 155 if ~isempty(PairCiv2) 156 [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds,NomTypeNc]=... 157 find_pair_indices(PairCiv2,i1_series{2},j1_series{2},MinIndex_i(2),MaxIndex_i(2),MinIndex_j(2),MaxIndex_j(2)); 158 end 145 159 end 146 end 147 % i1_series_Civ1=i1_series_Civ1(~check_bounds); 148 % i2_series_Civ1=i2_series_Civ1(~check_bounds); 149 % j1_series_Civ1=j1_series_Civ1(~check_bounds); 150 % j2_series_Civ1=j2_series_Civ1(~check_bounds); 151 case 'displacement' 152 i1_series_Civ1=Param.ActionInput.OriginIndex*ones(size(i1_series{1})); 153 i2_series_Civ1=i1_series{1};i2_series_Civ2=i1_series{1}; 154 j1_series_Civ1=ones(size(i1_series{1}));% first j index is 1 155 if isempty(j1_series_Civ1) 156 j2_series_Civ1=ones(size(i1_series{1})); 157 else 158 j2_series_Civ1=j1_series_Civ1; 159 end 160 i1_series_Civ2=i1_series_Civ1; 161 j1_series_Civ2=j1_series_Civ1; 162 j2_series_Civ2=j2_series_Civ1; 163 NomTypeNc=NomType; 164 case 'shift' 165 i1_series_Civ1=i1_series{1};i1_series_Civ2=i1_series{1}; 166 i2_series_Civ1=i1_series{2};i2_series_Civ2=i1_series{2}; 167 if isempty(j1_series{1}) 168 j1_series_Civ1=ones(size(i1_series{1})); 169 j2_series_Civ1=ones(size(i1_series{2})); 170 else 171 j1_series_Civ1=j1_series{1}; 172 j2_series_Civ1=j1_series{2}; 173 end 174 j1_series_Civ2=j1_series_Civ1; 175 j2_series_Civ2=j2_series_Civ1; 176 NomTypeNc=NomType_A; 177 end 178 if isempty(j1_series_Civ1) 179 FrameIndex_A_Civ1=i1_series_Civ1; 180 FrameIndex_B_Civ1=i2_series_Civ1; 181 j1_series_Civ1=ones(size(i1_series_Civ1)); 182 j2_series_Civ1=ones(size(i1_series_Civ1)); 183 else 184 FrameIndex_A_Civ1=j1_series_Civ1; 185 FrameIndex_B_Civ1=j2_series_Civ1; 186 end 187 if isempty(PairCiv2) 160 % i1_series_Civ1=i1_series_Civ1(~check_bounds); 161 % i2_series_Civ1=i2_series_Civ1(~check_bounds); 162 % j1_series_Civ1=j1_series_Civ1(~check_bounds); 163 % j2_series_Civ1=j2_series_Civ1(~check_bounds); 164 case 'displacement' 165 i1_series_Civ1=Param.ActionInput.OriginIndex*ones(size(i1_series{1})); 166 i2_series_Civ1=i1_series{1};i2_series_Civ2=i1_series{1}; 167 j1_series_Civ1=ones(size(i1_series{1}));% first j index is 1 168 if isempty(j1_series_Civ1) 169 j2_series_Civ1=ones(size(i1_series{1})); 170 else 171 j2_series_Civ1=j1_series_Civ1; 172 end 173 i1_series_Civ2=i1_series_Civ1; 174 j1_series_Civ2=j1_series_Civ1; 175 j2_series_Civ2=j2_series_Civ1; 176 NomTypeNc=NomType; 177 case 'PIV volume' 178 % TODO, TODO 179 end 180 if isempty(j1_series_Civ1) 181 FrameIndex_A_Civ1=i1_series_Civ1; 182 FrameIndex_B_Civ1=i2_series_Civ1; 183 j1_series_Civ1=ones(size(i1_series_Civ1)); 184 j2_series_Civ1=ones(size(i1_series_Civ1)); 185 else 186 FrameIndex_A_Civ1=j1_series_Civ1; 187 FrameIndex_B_Civ1=j2_series_Civ1; 188 end 189 if isempty(PairCiv2) 188 190 FrameIndex_A_Civ2=FrameIndex_A_Civ1; 189 191 FrameIndex_B_Civ2=FrameIndex_B_Civ1; 190 else 191 if isempty(j1_series_Civ2) 192 FrameIndex_A_Civ2=i1_series_Civ2; 193 FrameIndex_B_Civ2=i2_series_Civ2; 194 j1_series_Civ2=ones(size(i1_series_Civ2)); 195 j2_series_Civ2=ones(size(i1_series_Civ2)); 196 else 197 FrameIndex_A_Civ2=j1_series_Civ2; 198 FrameIndex_B_Civ2=j2_series_Civ2; 199 end 200 end 201 if isempty(i1_series_Civ1)||(~isempty(PairCiv2) && isempty(i1_series_Civ2)) 202 disp_uvmat('ERROR','no image pair fo civ in the input file index range',checkrun) 203 return 204 end 205 end 206 207 %% check the first image pair 208 try 209 if Param.ActionInput.CheckCiv1% Civ1 is performed 210 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(1),[],j1_series_Civ1(1)); 211 if ~exist(ImageName_A,'file') 212 disp_uvmat('ERROR',['first input image ' ImageName_A ' does not exist'],checkrun) 192 else 193 if isempty(j1_series_Civ2) 194 FrameIndex_A_Civ2=i1_series_Civ2; 195 FrameIndex_B_Civ2=i2_series_Civ2; 196 j1_series_Civ2=ones(size(i1_series_Civ2)); 197 j2_series_Civ2=ones(size(i1_series_Civ2)); 198 else 199 FrameIndex_A_Civ2=j1_series_Civ2; 200 FrameIndex_B_Civ2=j2_series_Civ2; 201 end 202 end 203 if isempty(i1_series_Civ1)||(~isempty(PairCiv2) && isempty(i1_series_Civ2)) 204 disp_uvmat('ERROR','no image pair fo civ in the input file index range',checkrun) 213 205 return 214 206 end 215 [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A); 216 FileType_A=FileInfo_A.FileType; 217 if strcmp(FileInfo_A.FileType,'netcdf') 218 FieldName_A=Param.InputFields.FieldName; 219 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_A,{FieldName_A}); 220 par_civ1.ImageA=DataIn.(FieldName_A); 221 else 222 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(1)); 223 end 224 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(1),[],j2_series_Civ1(1)); 225 if ~exist(ImageName_B,'file') 226 disp_uvmat('ERROR',['first input image ' ImageName_B ' does not exist'],checkrun) 207 end 208 209 %% check the first image pair 210 try 211 if Param.ActionInput.CheckCiv1% Civ1 is performed 212 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(1),[],j1_series_Civ1(1)); 213 if ~exist(ImageName_A,'file') 214 disp_uvmat('ERROR',['first input image ' ImageName_A ' does not exist'],checkrun) 215 return 216 end 217 [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A); 218 FileType_A=FileInfo_A.FileType; 219 if strcmp(FileInfo_A.FileType,'netcdf') 220 FieldName_A=Param.InputFields.FieldName; 221 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_A,{FieldName_A}); 222 par_civ1.ImageA=DataIn.(FieldName_A); 223 else 224 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(1)); 225 end 226 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(1),[],j2_series_Civ1(1)); 227 if ~exist(ImageName_B,'file') 228 disp_uvmat('ERROR',['first input image ' ImageName_B ' does not exist'],checkrun) 229 return 230 end 231 [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B); 232 FileType_B=FileInfo_B.FileType; 233 if strcmp(FileInfo_B.FileType,'netcdf') 234 FieldName_B=Param.InputFields.FieldName; 235 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_B,{FieldName_B}); 236 par_civ1.ImageB=DataIn.(FieldName_B); 237 else 238 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(1)); 239 end 240 NbField=numel(i1_series_Civ1); 241 elseif Param.ActionInput.CheckCiv2 % Civ2 is performed without Civ1 242 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ2(1),[],j1_series_Civ2(1)); 243 if ~exist(ImageName_A,'file') 244 disp_uvmat('ERROR',['first input image ' ImageName_A ' does not exist'],checkrun) 245 return 246 end 247 [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A); 248 FileType_A=FileInfo_A.FileType; 249 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileInfo_A.FileType,VideoObject_A,FrameIndex_A_Civ2(1)); 250 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ2(1),[],j2_series_Civ2(1)); 251 if ~exist(ImageName_B,'file') 252 disp_uvmat('ERROR',['first input image ' ImageName_B ' does not exist'],checkrun) 253 return 254 end 255 [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B); 256 FileType_B=FileInfo_B.FileType; 257 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ2(1)); 258 NbField=numel(i1_series_Civ2); 259 else 260 NbField=numel(i1_series_Civ1);% no image used (only fix or patch) TO CHECK 261 end 262 catch ME 263 if ~isempty(ME.message) 264 disp_uvmat('ERROR', ['error reading input image: ' ME.message],checkrun) 227 265 return 228 266 end 229 [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B); 230 FileType_B=FileInfo_B.FileType; 231 if strcmp(FileInfo_B.FileType,'netcdf') 232 FieldName_B=Param.InputFields.FieldName; 233 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_B,{FieldName_B}); 234 par_civ1.ImageB=DataIn.(FieldName_B); 235 else 236 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(1)); 237 end 238 NbField=numel(i1_series_Civ1); 239 elseif Param.ActionInput.CheckCiv2 % Civ2 is performed without Civ1 240 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ2(1),[],j1_series_Civ2(1)); 241 if ~exist(ImageName_A,'file') 242 disp_uvmat('ERROR',['first input image ' ImageName_A ' does not exist'],checkrun) 243 return 244 end 245 [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A); 246 FileType_A=FileInfo_A.FileType; 247 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileInfo_A.FileType,VideoObject_A,FrameIndex_A_Civ2(1)); 248 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ2(1),[],j2_series_Civ2(1)); 249 if ~exist(ImageName_B,'file') 250 disp_uvmat('ERROR',['first input image ' ImageName_B ' does not exist'],checkrun) 251 return 252 end 253 [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B); 254 FileType_B=FileInfo_B.FileType; 255 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ2(1)); 256 NbField=numel(i1_series_Civ2); 257 else 258 NbField=numel(i1_series_Civ1);% no image used (only fix or patch) TO CHECK 259 end 260 catch ME 261 if ~isempty(ME.message) 262 disp_uvmat('ERROR', ['error reading input image: ' ME.message],checkrun) 263 return 264 end 265 end 266 267 268 %% Output directory 269 OutputDir=[Param.OutputSubDir Param.OutputDirExt]; 270 267 end 268 269 270 %% Output directory 271 OutputDir=''; 272 if CheckOutputFile 273 OutputDir=[Param.OutputSubDir Param.OutputDirExt]; 274 end 275 end 276 277 %% prepare output Data 271 278 Data.ListGlobalAttribute={'Conventions','Program','CivStage'}; 272 279 Data.Conventions='uvmat/civdata';% states the conventions used for the description of field variables and attributes … … 323 330 %%%%% MAIN LOOP %%%%%% 324 331 for ifield=1:NbField 325 update_waitbar(WaitbarHandle,ifield/NbField) 326 if ~isempty(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue') 327 disp('program stopped by user') 328 break 329 end 330 if iview_A==0 331 ncfile=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},Param.InputTable{1,5},... 332 NomTypeNc,i1_series_Civ1(ifield),i2_series_Civ1(ifield),j1_series_Civ1(ifield),j2_series_Civ1(ifield)); 333 else 334 if iview_A==1% if Civ1 is performed 335 Civ1Dir=OutputDir; 336 else 337 Civ1Dir=Param.InputTable{1,2}; 338 end 339 if strcmp(Param.ActionInput.ListCompareMode,'PIV') 340 ncfile=fullfile_uvmat(RootPath_A,Civ1Dir,RootFile_A,'.nc',NomTypeNc,i1_series_Civ1(ifield),i2_series_Civ1(ifield),... 341 j1_series_Civ1(ifield),j2_series_Civ1(ifield)); 342 else 343 ncfile=fullfile_uvmat(RootPath_A,Civ1Dir,RootFile_A,'.nc',NomTypeNc,i2_series_Civ1(ifield),[],... 344 j1_series_Civ1(ifield),j2_series_Civ1(ifield)); 332 if ~isempty(RUNHandle)% update the waitbar in interactive mode with GUI series (checkrun=1) 333 update_waitbar(WaitbarHandle,ifield/NbField) 334 if get(RUNHandle,'Value')&& ~strcmp(get(RUNHandle,'BusyAction'),'queue') 335 disp('program stopped by user') 336 break 337 end 338 end 339 if CheckInputFile 340 if iview_A==0 % no nc file has been entered 341 ncfile=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},Param.InputTable{1,5},... 342 NomTypeNc,i1_series_Civ1(ifield),i2_series_Civ1(ifield),j1_series_Civ1(ifield),j2_series_Civ1(ifield)); 343 else% an existing nc file has been entered 344 if iview_A==1% if Civ1 is performed 345 Civ1Dir=OutputDir; 346 else 347 Civ1Dir=Param.InputTable{1,2}; 348 end 349 if strcmp(Param.ActionInput.ListCompareMode,'PIV') 350 ncfile=fullfile_uvmat(RootPath_A,Civ1Dir,RootFile_A,'.nc',NomTypeNc,i1_series_Civ1(ifield),i2_series_Civ1(ifield),... 351 j1_series_Civ1(ifield),j2_series_Civ1(ifield)); 352 else 353 ncfile=fullfile_uvmat(RootPath_A,Civ1Dir,RootFile_A,'.nc',NomTypeNc,i2_series_Civ1(ifield),[],... 354 j1_series_Civ1(ifield),j2_series_Civ1(ifield)); 355 end 345 356 end 346 357 end … … 349 360 if isfield (Param.ActionInput,'Civ1') 350 361 par_civ1=Param.ActionInput.Civ1; 351 try352 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(ifield),[],j1_series_Civ1(ifield));353 if strcmp(FileInfo_A.FileType,'netcdf')354 FieldName_A=Param.InputFields.FieldName;355 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_A,{FieldName_A});356 par_civ1.ImageA=DataIn.(FieldName_A);357 else358 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(ifield));359 end360 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(ifield),[],j2_series_Civ1(ifield));361 if strcmp(FileInfo_B.FileType,'netcdf')362 FieldName_B=Param.InputFields.FieldName;363 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_B,{FieldName_B});364 par_civ1.ImageB=DataIn.(FieldName_B);365 else366 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(ifield));367 end368 catch ME369 if ~isempty(ME.message)370 disp_uvmat('ERROR', ['error reading input image: ' ME.message],checkrun)371 return372 end373 end374 par_civ1.ImageWidth=size(par_civ1.ImageA,2);%FileInfo_A.Width;375 par_civ1.ImageHeight=size(par_civ1.ImageA,1);%FileInfo_A.Height;376 list_param=(fieldnames(Param.ActionInput.Civ1))';377 ind_remove=find(strcmp('TestCiv1',list_param));378 list_param(ind_remove)=[];379 Civ1_param=regexprep(list_param,'^.+','Civ1_$0');% insert 'Civ1_' before each string in list_param380 Civ1_param=[{'Civ1_ImageA','Civ1_ImageB','Civ1_Time','Civ1_Dt'} Civ1_param]; %insert the names of the two input images381 %indicate the values of all the global attributes in the output data382 Data.Civ1_ImageA=ImageName_A;383 Data.Civ1_ImageB=ImageName_B;384 i1=i1_series_Civ1(ifield);385 i2=i1;386 if ~isempty(i2_series_Civ1)387 i2=i2_series_Civ1(ifield);388 end389 j1=1;390 if ~isempty(j1_series_Civ1)391 j1=j1_series_Civ1(ifield);392 end393 j2=j1;394 if ~isempty(j2_series_Civ1)395 j2=j2_series_Civ1(ifield);396 end397 Data.Civ1_Time=(time(i2+1,j2+1)+time(i1+1,j1+1))/2;398 Data.Civ1_Dt=time(i2+1,j2+1)-time(i1+1,j1+1);399 for ilist=1:length(list_param)400 Data.(Civ1_param{4+ilist})=Param.ActionInput.Civ1.(list_param{ilist});401 end402 Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ1_param];403 Data.CivStage=1;404 362 if CheckInputFile % read input images (except in mode Test where it is introduced directly in Param.ActionInput.Civ1) 363 try 364 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(ifield),[],j1_series_Civ1(ifield)); 365 if strcmp(FileInfo_A.FileType,'netcdf')% case of input images in format netcdf 366 FieldName_A=Param.InputFields.FieldName; 367 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_A,{FieldName_A}); 368 par_civ1.ImageA=DataIn.(FieldName_A); 369 else % usual image formats for image A 370 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(ifield)); 371 end 372 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(ifield),[],j2_series_Civ1(ifield)); 373 if strcmp(FileInfo_B.FileType,'netcdf') % case of input images in format netcdf 374 FieldName_B=Param.InputFields.FieldName; 375 [DataIn,tild,tild,errormsg]=nc2struct(ImageName_B,{FieldName_B}); 376 par_civ1.ImageB=DataIn.(FieldName_B); 377 else % usual image formats for image B 378 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(ifield)); 379 end 380 catch ME % display errors in reading input images 381 if ~isempty(ME.message) 382 disp_uvmat('ERROR', ['error reading input image: ' ME.message],checkrun) 383 return 384 end 385 end 386 par_civ1.ImageWidth=size(par_civ1.ImageA,2);%FileInfo_A.Width; 387 par_civ1.ImageHeight=size(par_civ1.ImageA,1);%FileInfo_A.Height; 388 list_param=(fieldnames(Param.ActionInput.Civ1))'; 389 list_param(strcmp('TestCiv1',list_param))=[];% remove the parameter TestCiv1 from the list 390 Civ1_param=regexprep(list_param,'^.+','Civ1_$0');% insert 'Civ1_' before each string in list_param 391 Civ1_param=[{'Civ1_ImageA','Civ1_ImageB','Civ1_Time','Civ1_Dt'} Civ1_param]; %insert the names of the two input images 392 %indicate the values of all the global attributes in the output data 393 Data.Civ1_ImageA=ImageName_A; 394 Data.Civ1_ImageB=ImageName_B; 395 i1=i1_series_Civ1(ifield); 396 i2=i1; 397 if ~isempty(i2_series_Civ1) 398 i2=i2_series_Civ1(ifield); 399 end 400 j1=1; 401 if ~isempty(j1_series_Civ1) 402 j1=j1_series_Civ1(ifield); 403 end 404 j2=j1; 405 if ~isempty(j2_series_Civ1) 406 j2=j2_series_Civ1(ifield); 407 end 408 Data.Civ1_Time=(time(i2+1,j2+1)+time(i1+1,j1+1))/2; 409 Data.Civ1_Dt=time(i2+1,j2+1)-time(i1+1,j1+1); 410 for ilist=1:length(list_param) 411 Data.(Civ1_param{4+ilist})=Param.ActionInput.Civ1.(list_param{ilist}); 412 end 413 Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ1_param]; 414 Data.CivStage=1; 415 end 405 416 % set the list of variables 406 417 Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_F','Civ1_C'};% cell array containing the names of the fields to record … … 448 459 if exist('ncfile','var') 449 460 CivFile=ncfile; 450 elseif isfield(Param.Patch1,'CivFile') 451 CivFile=Param.Patch1.CivFile; 452 end 453 [Data,tild,tild,errormsg]=nc2struct(CivFile,'ListGlobalAttribute','absolut_time_T0'); %look for the constant 'absolut_time_T0' to detect old civx data format 454 if ~isempty(errormsg) 455 disp_uvmat('ERROR',errormsg,checkrun) 456 return 457 end 458 if ~isempty(Data.absolut_time_T0')%read civx file 459 check_civx=1;% test for old civx data format 460 [Data,vardetect,ichoice]=nc2struct(CivFile);%read the variables in the netcdf file 461 else 462 [Data,tild,tild,errormsg]=nc2struct(CivFile);%read civ1 and fix1 data in the existing netcdf file 461 % elseif isfield(Param.Patch1,'CivFile') 462 % CivFile=Param.Patch1.CivFile; 463 % end 464 [Data,tild,tild,errormsg]=nc2struct(CivFile,'ListGlobalAttribute','absolut_time_T0'); %look for the constant 'absolut_time_T0' to detect old civx data format 465 if ~isempty(errormsg) 466 disp_uvmat('ERROR',errormsg,checkrun) 467 return 468 end 469 if ~isempty(Data.absolut_time_T0')%read civx file 470 check_civx=1;% test for old civx data format 471 [Data,vardetect,ichoice]=nc2struct(CivFile);%read the variables in the netcdf file 472 else 473 [Data,tild,tild,errormsg]=nc2struct(CivFile);%read civ1 and fix1 data in the existing netcdf file 474 end 475 else 476 Data.ListGlobalAttribute={}; 477 Data.ListVarName={}; 478 Data.VarDimName={}; 479 Data.Civ1_X=Param.Civ1_X; 480 Data.Civ1_Y=Param.Civ1_Y; 481 Data.Civ1_U=Param.Civ1_U; 482 Data.Civ1_V=Param.Civ1_V; 483 Data.Civ1_FF=Param.Civ1_FF; 463 484 end 464 485 end … … 511 532 return 512 533 end 534 535 % record the processing parameters of Patch1 as global attributes in the result nc file 513 536 list_param=fieldnames(Param.ActionInput.Patch1)'; 514 ind_remove=find(strcmp('TestPatch1',list_param)); 515 list_param(ind_remove)=[]; 516 Patch1_param=regexprep(list_param,'^.+','Patch1_$0');% insert 'Fix1_' before each string in ListFixParam 517 %indicate the values of all the global attributes in the output data 537 list_param(strcmp('TestPatch1',list_param))=[];% remove 'TestPatch1' from the list of parameters 538 Patch1_param=regexprep(list_param,'^.+','Patch1_$0');% insert 'Patch1_' before each parameter name 518 539 for ilist=1:length(list_param) 519 540 Data.(Patch1_param{ilist})=Param.ActionInput.Patch1.(list_param{ilist}); 520 541 end 542 Data.CivStage=3;% record the new state of processing 521 543 Data.ListGlobalAttribute=[Data.ListGlobalAttribute Patch1_param]; 522 544 523 % Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch1_FieldSmooth','Patch1_MaxDiff','Patch1_SubDomainSize'}]; 524 % Data.Patch1_FieldSmooth=Param.ActionInput.Patch1.FieldSmooth; 525 % Data.Patch1_MaxDiff=Param.ActionInput.Patch1.MaxDiff; 526 % Data.Patch1_SubDomainSize=Param.ActionInput.Patch1.SubDomainSize; 545 % list the variables to record 527 546 nbvar=length(Data.ListVarName); 528 547 Data.ListVarName=[Data.ListVarName {'Civ1_U_smooth','Civ1_V_smooth','Civ1_SubRange','Civ1_NbCentres','Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps'}]; … … 534 553 Data.VarAttribute{nbvar+6}.Role='vector_x'; 535 554 Data.VarAttribute{nbvar+7}.Role='vector_y'; 536 Data.Civ1_U_smooth= zeros(size(Data.Civ1_X));537 Data.Civ1_V_smooth= zeros(size(Data.Civ1_X));555 Data.Civ1_U_smooth=Data.Civ1_U; % zeros(size(Data.Civ1_X)); 556 Data.Civ1_V_smooth=Data.Civ1_V; %zeros(size(Data.Civ1_X)); 538 557 if isfield(Data,'Civ1_FF') 539 558 ind_good=find(Data.Civ1_FF==0); … … 541 560 ind_good=1:numel(Data.Civ1_X); 542 561 end 562 563 % perform Patch calculation using the UVMAT fct 'filter_tps' 543 564 [Data.Civ1_SubRange,Data.Civ1_NbCentres,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=... 544 565 filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomainSize,Data.Patch1_FieldSmooth,Data.Patch1_MaxDiff); 545 Data.Civ1_U_smooth(ind_good)=Ures; 566 Data.Civ1_U_smooth(ind_good)=Ures;% take the interpolated (smoothed) velocity values for good vectors, keep 0 for the others 546 567 Data.Civ1_V_smooth(ind_good)=Vres; 547 568 Data.Civ1_FF(ind_good)=FFres; 548 Data.CivStage=3;549 569 end 550 570 … … 554 574 par_civ2.ImageA=[]; 555 575 par_civ2.ImageB=[]; 556 % if ~isfield(Param.Civ1,'ImageA') 557 i1=i1_series_Civ2(ifield); 576 i1=i1_series_Civ2(ifield); 558 577 i2=i1; 559 578 if ~isempty(i2_series_Civ2) … … 610 629 end 611 630 612 % get the guess from patch1 or patch2 (case ' iterate')613 if isfield (par_civ2,' iterate') && strcmp(par_civ2.iterate,'civ3')631 % get the guess from patch1 or patch2 (case 'CheckCiv3') 632 if isfield (par_civ2,'CheckCiv3') && par_civ2.CheckCiv3 %get the guess from patch2 614 633 SubRange= Data.Civ2_SubRange; 615 634 NbCentres=Data.Civ2_NbCentres; … … 626 645 Data.ListVarName={}; 627 646 Data.VarDimName={}; 628 else 647 else % get the guess from patch1 629 648 SubRange= Data.Civ1_SubRange; 630 649 NbCentres=Data.Civ1_NbCentres; … … 781 800 782 801 %% write result in a netcdf file if requested 783 if exist('ncfile','var')802 if CheckOutputFile 784 803 errormsg=struct2nc(ncfile,Data); 785 804 if isempty(errormsg) … … 824 843 % mask: =[] for no mask 825 844 % roi: 4 element vector defining a region of interest: x position, y position, width, height, (in image indices), for the whole image, roi=[]; 826 function [xtable ytable utable vtable ctable F result_conv errormsg] = civ (par_civ) 827 %this funtion performs the DCC PIV analysis. Recent window-deformation 828 %methods perform better and will maybe be implemented in the future. 845 function [xtable,ytable,utable,vtable,ctable,F,result_conv,errormsg] = civ (par_civ) 829 846 830 847 %% prepare measurement grid … … 866 883 result_conv=[]; 867 884 errormsg=''; 868 885 869 886 %% prepare mask 870 887 if isfield(par_civ,'Mask') && ~isempty(par_civ.Mask)
Note: See TracChangeset
for help on using the changeset viewer.