- Timestamp:
- Dec 13, 2024, 8:57:14 PM (12 months ago)
- Location:
- trunk/src
- Files:
-
- 6 edited
-
civ.m (modified) (7 diffs)
-
mouse_motion.m (modified) (5 diffs)
-
read_civdata.m (modified) (1 diff)
-
series/civ_input.m (modified) (5 diffs)
-
series/civ_series.m (modified) (22 diffs)
-
uvmat.m (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r1168 r1169 44 44 %% prepare measurement grid if not given as input 45 45 if ~isfield(par_civ,'Grid')% grid points defining central positions of the sub-images in image A 46 % if ischar(par_civ.Grid)%read the grid file if the input is a file name (grid in x, y image coordinates)47 % par_civ.Grid=dlmread(par_civ.Grid);48 % par_civ.Grid(1,:)=[];%the first line must be removed (heading in the grid file)49 % end50 % % else par_civ.Grid is already an array, no action here51 % else% automatic grid in x, y image coordinates52 46 nbinterv_x=floor((npx_ima-1)/par_civ.Dx); 53 47 gridlength_x=nbinterv_x*par_civ.Dx; … … 114 108 checkmask=0; 115 109 MinA=min(min(par_civ.ImageA)); 116 %MinB=min(min(par_civ.ImageB));117 %check_undefined=false(size(par_civ.ImageA));118 110 if isfield(par_civ,'Mask') && ~isempty(par_civ.Mask) 119 111 checkmask=1; … … 126 118 127 119 %% compute image correlations: MAINLOOP on velocity vectors 128 corrmax=0;129 120 sum_square=1;% default 130 121 mesh=1;% default … … 134 125 par_civ.CorrSmooth=2;% use SUBPIX2DGAUSS (take into account more points near the max) 135 126 end 136 127 137 128 if par_civ.CorrSmooth~=0 % par_civ.CorrSmooth=0 implies no civ computation (just input image and grid points given) 138 129 for ivec=1:nbvec … … 141 132 FF(ivec)=0; 142 133 ibx2=floor(CorrBoxSizeX(ivec)/2); 143 iby2=floor(CorrBoxSizeY(ivec)/2);144 isx2=ibx2+ceil(par_civ.SearchRange(1));145 isy2=iby2+ceil(par_civ.SearchRange(2));134 iby2=floor(CorrBoxSizeY(ivec)/2); 135 isx2=ibx2+ceil(par_civ.SearchRange(1)); 136 isy2=iby2+ceil(par_civ.SearchRange(2)); 146 137 subrange1_x=iref-ibx2:iref+ibx2;% x indices defining the first subimage 147 138 subrange1_y=jref-iby2:jref+iby2;% y indices defining the first subimage … … 216 207 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 217 208 corrmax= max(max(result_conv)); 218 209 219 210 %result_conv=(result_conv/corrmax); %normalize, peak=always 255 220 211 %Find the correlation max, at 255 … … 280 271 peaky = y; peakx=x; 281 272 if y < npy && y > 1 && x < npx-1 && x > 1 282 FF=false; % no error by the limited search box273 FF=false; % no error by the limited search box 283 274 max_conv=result_conv(y,x);% max correlation 284 275 %peak2noise= max(4,max_conv/std(reshape(result_conv,1,[])));% ratio of max conv to standard deviation of correlations (estiamtion of noise level), set to value 4 if it is too low 285 276 peak2noise=100;% TODO: make this threshold more precise, depending on the image noise 286 result_conv=result_conv*peak2noise/max_conv;% renormalise the correlation with respect to the noise 277 result_conv=result_conv*peak2noise/max_conv;% renormalise the correlation with respect to the noise 287 278 result_conv(result_conv<1)=1; %set to 1 correlation values smaller than 1 (=0 by discretisation, to avoid divergence in the log) 288 279 -
trunk/src/mouse_motion.m
r1168 r1169 238 238 if test_piv 239 239 [dd,ind_pt]=min(abs(Field.X-xy(1,1))+abs(Field.Y-xy(1,2))); 240 if isfield(hhciv,'TestCiv2') && strcmp(get(hhciv.Civ2,'Visible'),'on')&& ...241 strcmp(get(hhciv.TestCiv2,'Visible'),'on')&& get(hhciv.TestCiv2,'Value')% if TestCiv2 is activated242 CivOption='Civ2';243 Param.CheckCiv1=0;244 par_civ=read_GUI(hhciv.Civ2);%read the Civ2 panel in civ_input245 par_civ.Civ1_SubRange=Field.Civ1_SubRange;% get the subranges used for patch246 par_civ.Civ1_NbCentres=Field.Civ1_NbCentres;% get the nbre of civ1 data points in each subrange247 par_civ.Civ1_Coord_tps=Field.Civ1_Coord_tps;% get the positions of the centres (Civ1 data)248 par_civ.Civ1_U_tps=Field.Civ1_U_tps;% get the tps coefficients for spline, U component249 par_civ.Civ1_V_tps=Field.Civ1_V_tps;% get the tps coefficients for spline, V component250 par_civ.Civ1_Dt=Field.Civ1_Dt;251 par_civ.Civ2_Dt=Field.Civ2_Dt;252 shiftx=Field.ShiftX(ind_pt);% get field info stored in the cuirrent figure253 shifty=Field.ShiftY(ind_pt);254 else255 CivOption='Civ1';256 240 Param.CheckCiv2=0; 257 241 par_civ=read_GUI(hhciv.Civ1);%read the Civ1 panel in civ_input 258 242 shiftx=par_civ.SearchBoxShift(1); 259 243 shifty=par_civ.SearchBoxShift(2); 260 end261 244 xround=Field.X(ind_pt); 262 245 yround=Field.Y(ind_pt); … … 284 267 285 268 % perform the PIV calculation as the single point xround yround 286 Param.ActionInput.CheckCiv1=1;287 % Param.CheckFix1=0;288 % Param.CheckPatch1=0;%desactivate all calculations except Civ2 or Civ1289 Param.Action.RUN=1;290 Param.ActionInput.ListCompareMode='PIV';291 Param.ActionInput.PairIndices=read_GUI(hhciv.PairIndices);292 269 par_civ.ImageA=Field.A; 293 270 par_civ.ImageB=Field.B; … … 295 272 par_civ.ImageWidth=size(par_civ.ImageA,2); 296 273 par_civ.Grid=[xround yround];% PIV calculation with a single point 297 Param.ActionInput.(CivOption)=par_civ; 298 [Data,errormsg,result_conv]= civ_series(Param); 274 [~,~,utable,vtable,~,~,result_conv,errormsg]= civ(par_civ); 299 275 if ~isempty(errormsg) 300 276 text_displ_5=errormsg; 301 277 else 302 % rangx(1)=-(isx2-ibx2)+shiftx;303 % rangx(2)=isx2-ibx2+shiftx;304 % rangy(1)=-(isy2-iby2)-shifty;305 % rangy(2)=(isy2-iby2)-shifty;306 278 rangx(1)=-isx2+shiftx; 307 279 rangx(2)=isx2+shiftx; … … 320 292 set(0,'CurrentFigure',corrfig(1)) 321 293 AxeData.CurrentCorrImage=imagesc(rangx,-rangy,result_conv,[0 1]);% plot the correlation map, with full colormap from 0 to 1 322 AxeData.CurrentVector=line([0 Data.([CivOption '_U'])],[0 Data.([CivOption '_V'])],'Tag','vector');294 AxeData.CurrentVector=line([0 utable],[0 vtable],'Tag','vector'); 323 295 AxeData.TitleHandle=title(['[x,y]= ' num2str(par_civ.Grid) ' px']); 324 296 colorbar … … 339 311 set(ParentAxe,'XLim',rangx) 340 312 set(ParentAxe,'YLim',[-rangy(2) -rangy(1)]) 341 set(AxeData.CurrentVector,'XData',[0 Data.([CivOption '_U'])],'YData',[0 Data.([CivOption '_V'])]);313 set(AxeData.CurrentVector,'XData',[0 utable],'YData',[0 vtable]); 342 314 set(AxeData.TitleHandle,'String',['[x,y]= ' num2str(par_civ.Grid) ' px']) 343 315 end -
trunk/src/read_civdata.m
r1162 r1169 93 93 94 94 %% reading data 95 [Data,tild,tild,errormsg]=nc2struct(FileName,'ListGlobalAttribute','Conventions','CivStage'); 95 [Data,tild,tild,errormsg]=nc2struct(FileName,'ListGlobalAttribute','Conventions','CivStage');% read the global attributes to get Data.CivStage 96 96 if ~isempty(errormsg) 97 97 errormsg=['read_civdata: ' errormsg]; -
trunk/src/series/civ_input.m
r1167 r1169 1532 1532 drawnow 1533 1533 if get(handles.TestCiv1,'Value') 1534 set(handles.TestCiv1,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch 1534 set(handles.TestCiv1,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch 1535 1535 set(handles.CheckFix1,'value',0)% desactivate next step 1536 1536 set(handles.CheckPatch1,'value',0)% desactivate next step … … 1539 1539 set(handles.CheckPatch2,'value',0)% desactivate next step 1540 1540 update_CivOptions(handles,0) 1541 hseries=findobj(allchild(0),'Tag','series'); 1542 Param=read_GUI(hseries); 1543 Param.Action.RUN=1; 1544 Param.ActionInput=read_GUI(handles.civ_input); 1545 if isfield(Param.ActionInput,'Fix1') 1546 Param.ActionInput=rmfield(Param.ActionInput,'Fix1'); 1547 end 1548 if isfield(Param.ActionInput,'Patch1') 1549 Param.ActionInput=rmfield(Param.ActionInput,'Patch1'); 1550 end 1551 if isfield(Param.ActionInput,'Civ2')%remove options that may be selected beyond Patch1 1552 Param.ActionInput=rmfield(Param.ActionInput,'Civ2'); 1553 end 1554 if isfield(Param.ActionInput,'Fix2') 1555 Param.ActionInput=rmfield(Param.ActionInput,'Fix2'); 1556 end 1557 if isfield(Param.ActionInput,'Patch2') 1558 Param.ActionInput=rmfield(Param.ActionInput,'Patch2'); 1559 end 1560 if isfield(Param,'OutputSubDir') 1561 Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series 1562 end 1563 Param.ActionInput.Civ1.CorrSmooth=0;% launch Civ1 with no data point (to get the image names for A and B) 1564 Param.IndexRange.first_i=str2num(get(handles.ref_i,'String')); 1565 Param.IndexRange.last_i=str2num(get(handles.ref_i,'String')); 1566 if strcmp(get(handles.ref_j,'Visible'),'on') 1567 Param.IndexRange.first_j=str2num(get(handles.ref_j,'String')); 1568 Param.IndexRange.last_j=Param.IndexRange.first_j; 1569 else 1570 Param.IndexRange.first_j=1; 1571 Param.IndexRange.last_j=1; 1572 end 1573 [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results 1574 if ~isempty(errormsg), return, end % rmq: error msg displayed in civ_series 1575 1576 %% create image data ImageData for display 1577 ImageData.ListVarName={'ny','nx','A'}; 1578 ImageData.VarDimName= {'ny','nx',{'ny','nx'}}; 1579 ImageData.VarAttribute{1}.Role='coord_y'; 1580 ImageData.VarAttribute{2}.Role='coord_x'; 1581 ImageData.VarAttribute{3}.Role='scalar'; 1582 ImageData.A=imread(Data.Civ1_ImageA); % read the first image 1583 if ndims(ImageData.A)==3 %case of color image 1584 ImageData.VarDimName= {'ny','nx',{'ny','nx','rgb'}}; 1585 end 1586 ImageData.ny=[size(ImageData.A,1) 1]; 1587 ImageData.nx=[1 size(ImageData.A,2)]; 1588 ImageData.CoordUnit='pixel';% used to set equal scaling for x and y in image dispa=ly 1589 1590 %% create the figure view_field for image visualization 1591 hview_field=view_field(ImageData); %view the image in the GUI view_field 1592 set(0,'CurrentFigure',hview_field) 1593 hhview_field=guihandles(hview_field); 1594 set(hview_field,'CurrentAxes',hhview_field.PlotAxes) 1595 ViewData=get(hview_field,'UserData'); 1596 ViewData.CivHandle=handles.civ_input;% indicate the handle of the civ GUI in view_field 1597 ViewData.PlotAxes.X=Data.Civ1_X'; 1598 ViewData.PlotAxes.Y=Data.Civ1_Y'; 1599 ViewData.PlotAxes.B=imread(Data.Civ1_ImageB);%store the second image in the UserData of the GUI view_field 1600 set(hview_field,'UserData',ViewData)% store the info in the UserData of image view_field 1541 % get info from the GUI 'series' 1542 hseries=findobj(allchild(0),'Tag','series'); 1543 Param=read_GUI(hseries); 1544 Param.Action.RUN=1; 1545 Param.ActionInput=read_GUI(handles.civ_input); 1546 i1=str2num(get(handles.ref_i,'String')); %references indices 1547 i2=i1; 1548 j1=1; 1549 if strcmp(get(handles.ref_j,'Visible'),'on') 1550 j1=str2num(get(handles.ref_j,'String')); 1551 end 1552 j2=j1; 1553 str_civ=Param.ActionInput.PairIndices.ListPairCiv1; 1554 r=regexp(str_civ,'^\D(?<ind>[i|j])=( -| )(?<num1>\d+)\|(?<num2>\d+)','names'); 1555 if ~isempty(r) 1556 if strmp(r.ind,'i') 1557 i1=i1-str2num(r.num1); 1558 i2=i2 +str2num(r.num2); 1559 elseif strmp(r.ind,'j') 1560 j1=j1-str2num(r.num1); 1561 j2=j2 +str2num(r.num2); 1562 end 1563 else % mode='j1-j2'; 1564 r=regexp(str_civ,'^j= (?<num1>[a-z])-(?<num2>[a-z])','names'); 1565 if isempty(r) 1566 r=regexp(str_civ,'^j= (?<num1>[A-Z])-(?<num2>[A-Z])','names'); 1567 if isempty(r) 1568 r=regexp(str_civ,'^j= (?<num1>\d+)-(?<num2>\d+)','names'); 1569 end 1570 end 1571 if isempty(r) 1572 disp('wrong pair mode input option') 1573 else 1574 j1=stra2num(r.num1); 1575 j2=stra2num(r.num2); 1576 end 1577 end 1578 1579 par_civ1=Param.ActionInput.Civ1; 1580 1581 if strcmp(Param.ActionInput.ListCompareMode,'displacement') 1582 ImageName_A=Param.ActionInput.RefFile; 1583 else 1584 RootPath_A=Param.InputTable{1,1}; 1585 SubDir_A=Param.InputTable{1,2}; 1586 RootFile_A=Param.InputTable{1,3}; 1587 NomType_A=Param.InputTable{1,4}; 1588 FileExt_A=Param.InputTable{1,5}; 1589 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1,[],j1); 1590 ImageName_B=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i2,[],j2); 1591 end 1592 par_civ1.ImageA = read_image(ImageName_A); 1593 par_civ1.ImageB = read_image(ImageName_B); 1594 par_civ1.CorrSmooth=0;% will give only the grid of data points expected for PIV, computations will be activated by the fct mouse_motion.m 1595 [Data.Civ1_X,Data.Civ1_Y,Data.Civ1_U,Data.Civ1_V,Data.Civ1_C,Data.Civ1_FF, ~, errormsg]=civ(par_civ1); 1596 if ~isempty(errormsg) 1597 disp(errormsg) 1598 return 1599 end % rmq: error msg displayed in civ_series 1600 1601 %% create image data ImageData for display 1602 ImageData.ListVarName={'ny','nx','A'}; 1603 ImageData.VarDimName= {'ny','nx',{'ny','nx'}}; 1604 ImageData.VarAttribute{1}.Role='coord_y'; 1605 ImageData.VarAttribute{2}.Role='coord_x'; 1606 ImageData.VarAttribute{3}.Role='scalar'; 1607 ImageData.A=par_civ1.ImageA; % get the first image 1608 if ndims(ImageData.A)==3 %case of color image 1609 ImageData.VarDimName= {'ny','nx',{'ny','nx','rgb'}}; 1610 end 1611 ImageData.ny=[size(ImageData.A,1) 1]; 1612 ImageData.nx=[1 size(ImageData.A,2)]; 1613 ImageData.CoordUnit='pixel';% used to set equal scaling for x and y in image dispa=ly 1614 1615 %% create the figure view_field for image visualization 1616 hview_field=view_field(ImageData); %view the image in the GUI view_field 1617 set(0,'CurrentFigure',hview_field) 1618 hhview_field=guihandles(hview_field); 1619 set(hview_field,'CurrentAxes',hhview_field.PlotAxes) 1620 ViewData=get(hview_field,'UserData'); 1621 ViewData.CivHandle=handles.civ_input;% indicate the handle of the civ GUI in view_field 1622 ViewData.PlotAxes.X=Data.Civ1_X'; 1623 ViewData.PlotAxes.Y=Data.Civ1_Y'; 1624 ViewData.PlotAxes.B=par_civ1.ImageB;%store the second image in the UserData of the GUI view_field 1625 set(hview_field,'UserData',ViewData)% store the info in the UserData of image view_field, to be used by mouse_motion.m 1601 1626 1602 1627 %% look for a current figure for image correlation display … … 1623 1648 if ~isempty(hview_field) 1624 1649 delete(hview_field) 1625 end 1650 end 1626 1651 end 1627 1652 … … 1636 1661 %--------------------------------------------------------------------- 1637 1662 function NomTypeNc=nomtype2pair(NomTypeIma,mode_selected) 1638 %--------------------------------------------------------------------- 1663 %--------------------------------------------------------------------- 1639 1664 % OUTPUT: 1640 1665 % NomTypeNc … … 1645 1670 NomTypeNc=NomTypeIma;%default 1646 1671 switch mode_selected 1647 case 'pair j1-j2' 1648 if ~isempty(regexp(NomTypeIma,'a$'))1649 NomTypeNc=[NomTypeIma 'b'];1650 elseif ~isempty(regexp(NomTypeIma,'A$'))1651 NomTypeNc=[NomTypeIma 'B'];1652 else1653 r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names');1654 if ~isempty(r)1655 NomTypeNc='_1_1-2';1656 end1657 end1658 case 'series(Dj)' 1659 % r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names');1660 % if ~isempty(r)1661 NomTypeNc='_1_1-2';1662 % end1663 case 'series(Di)'1672 case 'pair j1-j2' 1673 if ~isempty(regexp(NomTypeIma,'a$')) 1674 NomTypeNc=[NomTypeIma 'b']; 1675 elseif ~isempty(regexp(NomTypeIma,'A$')) 1676 NomTypeNc=[NomTypeIma 'B']; 1677 else 1678 r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); 1679 if ~isempty(r) 1680 NomTypeNc='_1_1-2'; 1681 end 1682 end 1683 case 'series(Dj)' 1684 % r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); 1685 % if ~isempty(r) 1686 NomTypeNc='_1_1-2'; 1687 % end 1688 case 'series(Di)' 1664 1689 r=regexp(NomTypeIma,'(?<num1>\d+)_(?<num2>\d+)$','names'); 1665 1690 if ~isempty(r) -
trunk/src/series/civ_series.m
r1168 r1169 3 3 % civ: PIV function itself 4 4 % detect_false: put a flag to false vectors after detection by various criteria 5 % filter_tps: make interpolation-smoothing 5 % filter_tps: make interpolation-smoothing 6 6 %------------------------------------------------------------------------ 7 7 % function [Data,errormsg,result_conv]= civ_series(Param) … … 15 15 % Param: Matlab structure of input parameters 16 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 17 % Param.Action.RUN = 0 (to set the status of the GUI series) or =1 to RUN the computation 18 18 % Param.InputTable: sets the input file(s) 19 19 % if absent, the fct looks for input data in Param.ActionInput (test mode) … … 93 93 return 94 94 end 95 iview_A=0;%default values95 %iview_A=0;%default values 96 96 NbField=1; 97 97 RUNHandle=[]; 98 CheckInputFile=isfield(Param,'InputTable');%= 1 in test use for TestCiv (no nc file involved)99 CheckOutputFile=isfield(Param,'OutputSubDir');%= 1 in test use for TestPatch (no nc file produced)98 % CheckInputFile=isfield(Param,'InputTable');%= 1 in test use for TestCiv (no nc file involved) 99 % CheckOutputFile=isfield(Param,'OutputSubDir');%= 1 in test use for TestPatch (no nc file produced) 100 100 101 101 %% input files and indexing (skipped in Test mode) 102 if CheckInputFile 103 hseries=findobj(allchild(0),'Tag','series'); 104 RUNHandle=findobj(hseries,'Tag','RUN');%handle of RUN button in GUI series 105 WaitbarHandle=findobj(hseries,'Tag','Waitbar');%handle of waitbar in GUI series 106 MaxIndex_i=Param.IndexRange.MaxIndex_i; 107 MinIndex_i=Param.IndexRange.MinIndex_i; 108 MaxIndex_j=ones(size(MaxIndex_i));MinIndex_j=ones(size(MinIndex_i)); 109 if isfield(Param.IndexRange,'MaxIndex_j')&& isfield(Param.IndexRange,'MinIndex_j') 110 MaxIndex_j=Param.IndexRange.MaxIndex_j; 111 MinIndex_j=Param.IndexRange.MinIndex_j; 112 end 113 if isfield(Param,'InputTable') 114 [~,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 115 iview_A=0;% series index (iview) for the first image series 116 iview_B=0;% series index (iview) for the second image series (only non zero for option 'shift' comparing two image series ) 117 if Param.ActionInput.CheckCiv1 118 iview_A=1;% usual PIV, the image series is on the first line of the table 119 else % Civ1 has been already stored in a netcdf file input 120 iview_A=2;% the second line is used for the input images 121 end 122 if iview_A~=0 123 RootPath_A=Param.InputTable{iview_A,1}; 124 RootFile_A=Param.InputTable{iview_A,3}; 125 SubDir_A=Param.InputTable{iview_A,2}; 126 NomType_A=Param.InputTable{iview_A,4}; 127 FileExt_A=Param.InputTable{iview_A,5}; 128 if iview_B==0 129 iview_B=iview_A;% the second image series is the same as the first 130 end 131 RootPath_B=Param.InputTable{iview_B,1}; 132 RootFile_B=Param.InputTable{iview_B,3}; 133 SubDir_B=Param.InputTable{iview_B,2}; 134 NomType_B=Param.InputTable{iview_B,4}; 135 FileExt_B=Param.InputTable{iview_B,5}; 136 end 137 138 PairCiv2=''; 139 switch Param.ActionInput.ListCompareMode 140 case 'PIV' 141 PairCiv1=Param.ActionInput.PairIndices.ListPairCiv1; 142 if isfield(Param.ActionInput.PairIndices,'ListPairCiv2') 143 PairCiv2=Param.ActionInput.PairIndices.ListPairCiv2;%string which determines the civ2 pair 102 hseries=findobj(allchild(0),'Tag','series'); 103 RUNHandle=findobj(hseries,'Tag','RUN');%handle of RUN button in GUI series 104 WaitbarHandle=findobj(hseries,'Tag','Waitbar');%handle of waitbar in GUI series 105 MaxIndex_i=Param.IndexRange.MaxIndex_i; 106 MinIndex_i=Param.IndexRange.MinIndex_i; 107 MaxIndex_j=ones(size(MaxIndex_i));MinIndex_j=ones(size(MinIndex_i)); 108 if isfield(Param.IndexRange,'MaxIndex_j')&& isfield(Param.IndexRange,'MinIndex_j') 109 MaxIndex_j=Param.IndexRange.MaxIndex_j; 110 MinIndex_j=Param.IndexRange.MinIndex_j; 111 end 112 if isfield(Param,'InputTable') 113 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 114 % iview_A=0;% series index (iview) for the first image series 115 iview_B=0;% series index (iview) for the second image series (only non zero for option 'shift' comparing two image series ) 116 if Param.ActionInput.CheckCiv1 117 iview_A=1;% usual PIV, the image series is on the first line of the table 118 else % Civ1 has been already stored in a netcdf file input 119 iview_A=2;% the second line is used for the input images 120 end 121 % if iview_A~=0 122 RootPath_A=Param.InputTable{iview_A,1}; 123 RootFile_A=Param.InputTable{iview_A,3}; 124 SubDir_A=Param.InputTable{iview_A,2}; 125 NomType_A=Param.InputTable{iview_A,4}; 126 FileExt_A=Param.InputTable{iview_A,5}; 127 if iview_B==0 128 iview_B=iview_A;% the second image series is the same as the first 129 end 130 RootPath_B=Param.InputTable{iview_B,1}; 131 RootFile_B=Param.InputTable{iview_B,3}; 132 SubDir_B=Param.InputTable{iview_B,2}; 133 NomType_B=Param.InputTable{iview_B,4}; 134 FileExt_B=Param.InputTable{iview_B,5}; 135 PairCiv2=''; 136 137 switch Param.ActionInput.ListCompareMode 138 case 'PIV' 139 PairCiv1=Param.ActionInput.PairIndices.ListPairCiv1; 140 if isfield(Param.ActionInput.PairIndices,'ListPairCiv2') 141 PairCiv2=Param.ActionInput.PairIndices.ListPairCiv2;%string which determines the civ2 pair 142 end 143 if iview_A==1% if Civ1 is performed 144 [i1_series_Civ1,i2_series_Civ1,j1_series_Civ1,j2_series_Civ1,check_bounds,NomTypeNc]=... 145 find_pair_indices(PairCiv1,i1_series{1},j1_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j); 146 if ~isempty(PairCiv2) 147 [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds_Civ2]=... 148 find_pair_indices(PairCiv2,i1_series{1},j1_series{1},MinIndex_i(1),MaxIndex_i(1),MinIndex_j(1),MaxIndex_j(1)); 149 check_bounds=check_bounds | check_bounds_Civ2; 144 150 end 145 if iview_A==1% if Civ1 is performed 146 [i1_series_Civ1,i2_series_Civ1,j1_series_Civ1,j2_series_Civ1,check_bounds,NomTypeNc]=... 147 find_pair_indices(PairCiv1,i1_series{1},j1_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j); 148 if ~isempty(PairCiv2) 149 [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds_Civ2]=... 150 find_pair_indices(PairCiv2,i1_series{1},j1_series{1},MinIndex_i(1),MaxIndex_i(1),MinIndex_j(1),MaxIndex_j(1)); 151 check_bounds=check_bounds | check_bounds_Civ2; 152 end 153 else% we start from an existing Civ1 file 154 i1_series_Civ1=i1_series{1}; 155 i2_series_Civ1=i2_series{1}; 156 j1_series_Civ1=j1_series{1}; 157 j2_series_Civ1=j2_series{1}; 158 NomTypeNc=Param.InputTable{1,4}; 159 if ~isempty(PairCiv2) 160 [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds,NomTypeNc]=... 161 find_pair_indices(PairCiv2,i1_series{2},j1_series{2},MinIndex_i(2),MaxIndex_i(2),MinIndex_j(2),MaxIndex_j(2)); 162 end 151 else% we start from an existing Civ1 file 152 i1_series_Civ1=i1_series{1}; 153 i2_series_Civ1=i2_series{1}; 154 j1_series_Civ1=j1_series{1}; 155 j2_series_Civ1=j2_series{1}; 156 NomTypeNc=Param.InputTable{1,4}; 157 if ~isempty(PairCiv2) 158 [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds,NomTypeNc]=... 159 find_pair_indices(PairCiv2,i1_series{2},j1_series{2},MinIndex_i(2),MaxIndex_i(2),MinIndex_j(2),MaxIndex_j(2)); 163 160 end 164 case 'displacement' 165 if isfield(Param.ActionInput,'OriginIndex') 161 end 162 case 'displacement' 163 if isfield(Param.ActionInput,'OriginIndex') 166 164 i1_series_Civ1=Param.ActionInput.OriginIndex*ones(size(i1_series{1})); 167 else 168 i1_series_Civ1=ones(size(i1_series{1})); 169 end 170 i1_series_Civ2=i1_series_Civ1; 171 i2_series_Civ1=i1_series{1}; 172 i2_series_Civ2=i1_series{1}; 173 j1_series_Civ1=[];% no j index variation for the ref image 174 j1_series_Civ2=[]; 175 if isempty(j1_series{1}) 176 j2_series_Civ1=ones(size(i1_series_Civ1)); 177 else 178 j2_series_Civ1=j1_series{1};% if j index exist 179 end 180 j2_series_Civ2=j2_series_Civ1; 181 NomTypeNc='_1'; 182 end 183 %determine frame indices for input with movie or other multiframe input file 184 if isempty(j1_series_Civ1)% simple movie with index i 185 FrameIndex_A_Civ1=i1_series_Civ1; 186 FrameIndex_B_Civ1=i2_series_Civ1; 187 j1_series_Civ1=ones(size(i1_series_Civ1)); 165 else 166 i1_series_Civ1=ones(size(i1_series{1})); 167 end 168 i1_series_Civ2=i1_series_Civ1; 169 i2_series_Civ1=i1_series{1}; 170 i2_series_Civ2=i1_series{1}; 171 j1_series_Civ1=[];% no j index variation for the ref image 172 j1_series_Civ2=[]; 173 if isempty(j1_series{1}) 174 j2_series_Civ1=ones(size(i1_series_Civ1)); 175 else 176 j2_series_Civ1=j1_series{1};% if j index exist 177 end 178 j2_series_Civ2=j2_series_Civ1; 179 NomTypeNc='_1'; 180 end 181 %determine frame indices for input with movie or other multiframe input file 182 if isempty(j1_series_Civ1)% simple movie with index i 183 FrameIndex_A_Civ1=i1_series_Civ1; 184 FrameIndex_B_Civ1=i2_series_Civ1; 185 j1_series_Civ1=ones(size(i1_series_Civ1)); 186 if strcmp(Param.ActionInput.ListCompareMode,'PIV') 187 j2_series_Civ1=ones(size(i1_series_Civ1)); 188 end 189 else % movie for each burst or volume (index j) 190 FrameIndex_A_Civ1=j1_series_Civ1; 191 FrameIndex_B_Civ1=j2_series_Civ1; 192 end 193 if isempty(PairCiv2) 194 FrameIndex_A_Civ2=FrameIndex_A_Civ1; 195 FrameIndex_B_Civ2=FrameIndex_B_Civ1; 196 else 197 if isempty(j1_series_Civ2) 198 FrameIndex_A_Civ2=i1_series_Civ2; 199 FrameIndex_B_Civ2=i2_series_Civ2; 200 j1_series_Civ2=ones(size(i1_series_Civ2)); 188 201 if strcmp(Param.ActionInput.ListCompareMode,'PIV') 189 j2_series_Civ1=ones(size(i1_series_Civ1)); 190 end 191 else % movie for each burst or volume (index j) 192 FrameIndex_A_Civ1=j1_series_Civ1; 193 FrameIndex_B_Civ1=j2_series_Civ1; 194 end 195 if isempty(PairCiv2) 196 FrameIndex_A_Civ2=FrameIndex_A_Civ1; 197 FrameIndex_B_Civ2=FrameIndex_B_Civ1; 202 j2_series_Civ2=ones(size(i1_series_Civ2)); 203 end 198 204 else 199 if isempty(j1_series_Civ2) 200 FrameIndex_A_Civ2=i1_series_Civ2; 201 FrameIndex_B_Civ2=i2_series_Civ2; 202 j1_series_Civ2=ones(size(i1_series_Civ2)); 203 if strcmp(Param.ActionInput.ListCompareMode,'PIV') 204 j2_series_Civ2=ones(size(i1_series_Civ2)); 205 end 206 else 207 FrameIndex_A_Civ2=j1_series_Civ2; 208 FrameIndex_B_Civ2=j2_series_Civ2; 209 end 210 end 211 if isempty(i1_series_Civ1)||(~isempty(PairCiv2) && isempty(i1_series_Civ2)) 212 disp_uvmat('ERROR','no image pair for civ in the input file index range',checkrun) 213 return 214 end 215 end 216 217 %% check the first image pair 218 if Param.ActionInput.CheckCiv1% Civ1 is performed 219 NbField=numel(i1_series_Civ1); 220 elseif Param.ActionInput.CheckCiv2 % Civ2 is performed without Civ1 221 NbField=numel(i1_series_Civ2); 222 else 223 NbField=numel(i1_series_Civ1);% no image used (only detect_false or patch) TO CHECK 224 end 225 226 %% Output directory 227 OutputDir=''; 228 if CheckOutputFile 229 OutputDir=[Param.OutputSubDir Param.OutputDirExt]; 230 end 205 FrameIndex_A_Civ2=j1_series_Civ2; 206 FrameIndex_B_Civ2=j2_series_Civ2; 207 end 208 end 209 if isempty(i1_series_Civ1)||(~isempty(PairCiv2) && isempty(i1_series_Civ2)) 210 disp_uvmat('ERROR','no image pair for civ in the input file index range',checkrun) 211 return 212 end 213 end 214 215 %% check the first image pair 216 if Param.ActionInput.CheckCiv1% Civ1 is performed 217 NbField=numel(i1_series_Civ1); 218 elseif Param.ActionInput.CheckCiv2 % Civ2 is performed without Civ1 219 NbField=numel(i1_series_Civ2); 220 else 221 NbField=numel(i1_series_Civ1);% no image used (only detect_false or patch) TO CHECK 231 222 end 232 223 233 224 %% prepare output Data 225 OutputDir=[Param.OutputSubDir Param.OutputDirExt]; 234 226 ListGlobalAttribute={'Conventions','Program','CivStage'}; 235 227 Data.Conventions='uvmat/civdata';% states the conventions used for the description of field variables and attributes … … 241 233 242 234 %% get timing from the ImaDoc file or input video 243 if iview_A~=0244 XmlFileName=find_imadoc(RootPath_A,SubDir_A);245 Time=[];246 if ~isempty(XmlFileName)247 XmlData=imadoc2struct(XmlFileName);248 if isfield(XmlData,'Time')249 Time=XmlData.Time;250 end251 if isfield(XmlData,'Camera')252 if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice)253 NbSlice_calib{iview}=XmlData.Camera.NbSlice;% Nbre of slices for Zindex in phys transform254 if ~isequal(NbSlice_calib{iview},NbSlice_calib{1})255 msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series');256 end257 end258 if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit)259 TimeUnit=XmlData.Camera.TimeUnit;260 end261 end262 end263 end235 % if iview_A~=0 236 XmlFileName=find_imadoc(RootPath_A,SubDir_A); 237 Time=[]; 238 if ~isempty(XmlFileName) 239 XmlData=imadoc2struct(XmlFileName);%read the time from XmlFileName 240 if isfield(XmlData,'Time') 241 Time=XmlData.Time; 242 end 243 if isfield(XmlData,'Camera') 244 if isfield(XmlData.Camera,'NbSlice')&& ~isempty(XmlData.Camera.NbSlice) 245 NbSlice_calib{iview}=XmlData.Camera.NbSlice;% Nbre of slices for Zindex in phys transform 246 if ~isequal(NbSlice_calib{iview},NbSlice_calib{1}) 247 msgbox_uvmat('WARNING','inconsistent number of Z indices for the two field series'); 248 end 249 end 250 if isfield(XmlData.Camera,'TimeUnit')&& ~isempty(XmlData.Camera.TimeUnit) 251 TimeUnit=XmlData.Camera.TimeUnit; 252 end 253 end 254 end 255 % end 264 256 265 257 %%%%% MAIN LOOP %%%%%% … … 284 276 end 285 277 end 286 % if CheckInputFile287 if CheckOutputFile288 OutputPath=fullfile(Param.OutputPath,Param.Experiment,Param.Device);289 if iview_A==0 % no nc file has been entered290 ncfile=fullfile_uvmat(OutputPath,Param.InputTable{1,2},Param.InputTable{1,3},Param.InputTable{1,5},...291 NomTypeNc,i1_series_Civ1(ifield),i2_series_Civ1(ifield),j1_series_Civ1(ifield),j2_series_Civ1(ifield));292 else% an existing nc file has been entered293 if iview_A==1% if Civ1 is performed294 Civ1Dir=OutputDir;295 else296 Civ1Dir=Param.InputTable{1,2};297 end298 if strcmp(Param.ActionInput.ListCompareMode,'PIV')299 ncfile=fullfile_uvmat(OutputPath,Civ1Dir,RootFile_A,'.nc',NomTypeNc,i1_series_Civ1(ifield),i2_series_Civ1(ifield),...300 j1_series_Civ1(ifield),j2_series_Civ1(ifield));301 else302 ncfile=fullfile_uvmat(OutputPath,Civ1Dir,RootFile_A,'.nc',NomTypeNc,i2_series_Civ1(ifield),[],...303 j1_series_Civ1(ifield),j2_series_Civ1(ifield));304 end305 end306 ncfile_out=ncfile;% by default307 308 if isfield (Param.ActionInput,'Civ2')309 i1_civ2=i1_series_Civ2(ifield);310 i2_civ2=i1_civ2;311 if ~isempty(i2_series_Civ2)312 i2_civ2=i2_series_Civ2(ifield);313 end314 j1_civ2=1;315 if ~isempty(j1_series_Civ2)316 j1_civ2=j1_series_Civ2(ifield);317 end318 j2_civ2=i1_civ2;319 if ~isempty(j2_series_Civ2)320 j2_civ2=j2_series_Civ2(ifield);321 end322 if strcmp(Param.ActionInput.ListCompareMode,'PIV')323 ncfile_out=fullfile_uvmat(OutputPath,OutputDir,RootFile_A,'.nc',NomTypeNc,i1_civ2,i2_civ2,j1_civ2,j2_civ2);324 else % displacement325 ncfile_out=fullfile_uvmat(OutputPath,OutputDir,RootFile_A,'.nc',NomTypeNc,i2_civ2,[],j2_civ2);326 end327 end328 if ~CheckOverwrite && exist(ncfile_out,'file')329 disp(['existing output file ' ncfile_out ' already exists, skip to next field'])330 continue% skip iteration if the mode overwrite is desactivated and the result file already exists331 end332 end278 % % if CheckInputFile 279 % if CheckOutputFile 280 OutputPath=fullfile(Param.OutputPath,Param.Experiment,Param.Device); 281 % if iview_A==0 % no nc file has been entered 282 % ncfile=fullfile_uvmat(OutputPath,Param.InputTable{1,2},Param.InputTable{1,3},Param.InputTable{1,5},... 283 % NomTypeNc,i1_series_Civ1(ifield),i2_series_Civ1(ifield),j1_series_Civ1(ifield),j2_series_Civ1(ifield)); 284 % else% an existing nc file has been entered 285 % if iview_A==1% if Civ1 is performed 286 % Civ1Dir=OutputDir; 287 % else 288 % Civ1Dir=Param.InputTable{1,2}; 289 % end 290 if strcmp(Param.ActionInput.ListCompareMode,'PIV') 291 ncfile=fullfile_uvmat(OutputPath,OutputDir,RootFile_A,'.nc',NomTypeNc,i1_series_Civ1(ifield),i2_series_Civ1(ifield),... 292 j1_series_Civ1(ifield),j2_series_Civ1(ifield)); 293 else 294 ncfile=fullfile_uvmat(OutputPath,OutputDir,RootFile_A,'.nc',NomTypeNc,i2_series_Civ1(ifield),[],... 295 j1_series_Civ1(ifield),j2_series_Civ1(ifield)); 296 end 297 % end 298 ncfile_out=ncfile;% by default 299 300 if isfield (Param.ActionInput,'Civ2') 301 i1_civ2=i1_series_Civ2(ifield); 302 i2_civ2=i1_civ2; 303 if ~isempty(i2_series_Civ2) 304 i2_civ2=i2_series_Civ2(ifield); 305 end 306 j1_civ2=1; 307 if ~isempty(j1_series_Civ2) 308 j1_civ2=j1_series_Civ2(ifield); 309 end 310 j2_civ2=i1_civ2; 311 if ~isempty(j2_series_Civ2) 312 j2_civ2=j2_series_Civ2(ifield); 313 end 314 if strcmp(Param.ActionInput.ListCompareMode,'PIV') 315 ncfile_out=fullfile_uvmat(OutputPath,OutputDir,RootFile_A,'.nc',NomTypeNc,i1_civ2,i2_civ2,j1_civ2,j2_civ2); 316 else % displacement 317 ncfile_out=fullfile_uvmat(OutputPath,OutputDir,RootFile_A,'.nc',NomTypeNc,i2_civ2,[],j2_civ2); 318 end 319 end 320 if ~CheckOverwrite && exist(ncfile_out,'file') 321 disp(['existing output file ' ncfile_out ' already exists, skip to next field']) 322 continue% skip iteration if the mode overwrite is desactivated and the result file already exists 323 end 324 % end 333 325 ImageName_A='';ImageName_B='';%default 334 326 VideoObject_A=[];VideoObject_B=[]; … … 337 329 % if Civ1 computation is requested 338 330 if Param.ActionInput.CheckCiv1 339 if CheckInputFile 340 disp('civ1 started') 341 end 331 disp('civ1 started') 342 332 par_civ1=Param.ActionInput.Civ1;% parameters for civ1 343 if CheckInputFile % read input images (except in mode Test where it is introduced directly in Param.ActionInput.Civ1.ImageNameA and B) 344 try 345 if strcmp(Param.ActionInput.ListCompareMode,'displacement') 346 ImageName_A=Param.ActionInput.RefFile; 347 else 348 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(ifield),[],j1_series_Civ1(ifield)); 333 %if CheckInputFile % read input images (except in mode Test where it is introduced directly in Param.ActionInput.Civ1.ImageNameA and B) 334 try 335 if strcmp(Param.ActionInput.ListCompareMode,'displacement') 336 ImageName_A=Param.ActionInput.RefFile; 337 else 338 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(ifield),[],j1_series_Civ1(ifield)); 339 end 340 if strcmp(FileExt_A,'.nc')% case of input images in format netcdf 341 FieldName_A=Param.InputFields.FieldName; 342 [DataIn,~,~,errormsg]=nc2struct(ImageName_A,{FieldName_A}); 343 par_civ1.ImageA=DataIn.(FieldName_A); 344 else % usual image formats for image A 345 if isempty(FileType_A)% open the image object if not already done in case of movie input 346 [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A); 347 FileType_A=FileInfo_A.FileType; 348 if isempty(Time) && ~isempty(find(strcmp(FileType_A,{'mmreader','video','cine_phantom'}), 1))% case of video input 349 Time=zeros(FileInfo_A.NumberOfFrames+1,2); 350 Time(:,2)=(0:1/FileInfo_A.FrameRate:(FileInfo_A.NumberOfFrames)/FileInfo_A.FrameRate)'; 351 end 352 if ~isempty(FileType_A) && isempty(Time)% Time = index i +0.001 index j by default 353 MaxIndex_i=max(i2_series_Civ1); 354 MaxIndex_j=max(j2_series_Civ1); 355 Time=(1:MaxIndex_i)'*ones(1,MaxIndex_j); 356 Time=Time+0.001*ones(MaxIndex_i,1)*(1:MaxIndex_j); 357 Time=[zeros(1,MaxIndex_j);Time];% insert a first line of zeros 358 Time=[zeros(MaxIndex_i+1,1) Time];% insert a first column of zeros 359 end 349 360 end 350 if strcmp(FileExt_A,'.nc')% case of input images in format netcdf 351 FieldName_A=Param.InputFields.FieldName; 352 [DataIn,~,~,errormsg]=nc2struct(ImageName_A,{FieldName_A}); 353 par_civ1.ImageA=DataIn.(FieldName_A); 354 else % usual image formats for image A 355 if isempty(FileType_A)% open the image object if not already done in case of movie input 356 [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A); 357 FileType_A=FileInfo_A.FileType; 358 if isempty(Time) && ~isempty(find(strcmp(FileType_A,{'mmreader','video','cine_phantom'}), 1))% case of video input 359 Time=zeros(FileInfo_A.NumberOfFrames+1,2); 360 Time(:,2)=(0:1/FileInfo_A.FrameRate:(FileInfo_A.NumberOfFrames)/FileInfo_A.FrameRate)'; 361 end 362 if ~isempty(FileType_A) && isempty(Time)% Time = index i +0.001 index j by default 363 MaxIndex_i=max(i2_series_Civ1); 364 MaxIndex_j=max(j2_series_Civ1); 365 Time=(1:MaxIndex_i)'*ones(1,MaxIndex_j); 366 Time=Time+0.001*ones(MaxIndex_i,1)*(1:MaxIndex_j); 367 Time=[zeros(1,MaxIndex_j);Time];% insert a first line of zeros 368 Time=[zeros(MaxIndex_i+1,1) Time];% insert a first column of zeros 369 end 370 end 371 if isempty(regexp(ImageName_A,'(^http://)|(^https://)', 'once')) && ~exist(ImageName_A,'file') 372 disp([ImageName_A ' missing']) 373 continue 374 end 375 tsart_input=tic; 376 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(ifield)); 377 time_input=toc(tsart_input); 378 end 379 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(ifield),[],j2_series_Civ1(ifield)); 380 if isempty(FileType_B)% determine the image type for the first field 381 [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B); 382 FileType_B=FileInfo_B.FileType; 383 end 384 if isempty(regexp(ImageName_B,'(^http://)|(^https://)', 'once')) && ~exist(ImageName_B,'file') 385 disp([ImageName_B ' missing']) 361 if isempty(regexp(ImageName_A,'(^http://)|(^https://)', 'once')) && ~exist(ImageName_A,'file') 362 disp([ImageName_A ' missing']) 386 363 continue 387 364 end 388 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(ifield)); 389 catch ME % display errors in reading input images 390 if ~isempty(ME.message) 391 disp_uvmat('ERROR', ['error reading input image: ' ME.message],checkrun) 392 continue 393 end 394 end 395 396 % par_civ1.ImageWidth=size(par_civ1.ImageA,2); 397 % par_civ1.ImageHeight=size(par_civ1.ImageA,1); 398 list_param=(fieldnames(Param.ActionInput.Civ1))'; 399 list_param(strcmp('TestCiv1',list_param))=[];% remove the parameter TestCiv1 from the list 400 Civ1_param=regexprep(list_param,'^.+','Civ1_$0');% insert 'Civ1_' before each string in list_param 401 Civ1_param=[{'Civ1_ImageA','Civ1_ImageB','Civ1_Time','Civ1_Dt'} Civ1_param]; %insert the names of the two input images 402 %indicate the values of all the global attributes in the output data 403 Data.Civ1_ImageA=ImageName_A; 404 Data.Civ1_ImageB=ImageName_B; 405 i1=i1_series_Civ1(ifield); 406 i2=i1; 407 if ~isempty(i2_series_Civ1) 408 i2=i2_series_Civ1(ifield); 409 end 410 j1=1; 411 if ~isempty(j1_series_Civ1) 412 j1=j1_series_Civ1(ifield); 413 end 414 j2=j1; 415 if ~isempty(j2_series_Civ1) 416 j2=j2_series_Civ1(ifield); 417 end 418 if strcmp(Param.ActionInput.ListCompareMode,'displacement') 419 Data.Civ1_Time=Time(i2+1,j2+1);% the Time is the Time of the secodn image 420 Data.Civ1_Dt=1;% Time interval is 1, to yield displacement instead of velocity=displacement/Dt at reading 421 else 422 Data.Civ1_Time=(Time(i2+1,j2+1)+Time(i1+1,j1+1))/2;% the Time is the Time at the middle of the image pair 423 Data.Civ1_Dt=Time(i2+1,j2+1)-Time(i1+1,j1+1); 424 end 425 for ilist=1:length(list_param) 426 Data.(Civ1_param{4+ilist})=Param.ActionInput.Civ1.(list_param{ilist}); 427 end 428 Data.ListGlobalAttribute=[ListGlobalAttribute Civ1_param]; 429 430 Data.CivStage=1; 365 tsart_input=tic; 366 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(ifield)); 367 time_input=toc(tsart_input); 368 end 369 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(ifield),[],j2_series_Civ1(ifield)); 370 if isempty(FileType_B)% determine the image type for the first field 371 [FileInfo_B,VideoObject_B]=get_file_info(ImageName_B); 372 FileType_B=FileInfo_B.FileType; 373 end 374 if isempty(regexp(ImageName_B,'(^http://)|(^https://)', 'once')) && ~exist(ImageName_B,'file') 375 disp([ImageName_B ' missing']) 376 continue 377 end 378 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(ifield)); 379 catch ME % display errors in reading input images 380 if ~isempty(ME.message) 381 disp_uvmat('ERROR', ['error reading input image: ' ME.message],checkrun) 382 continue 383 end 384 end 385 386 % par_civ1.ImageWidth=size(par_civ1.ImageA,2); 387 % par_civ1.ImageHeight=size(par_civ1.ImageA,1); 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 if strcmp(Param.ActionInput.ListCompareMode,'displacement') 409 Data.Civ1_Time=Time(i2+1,j2+1);% the Time is the Time of the second image 410 Data.Civ1_Dt=1;% Time interval is 1, to yield displacement instead of velocity=displacement/Dt at reading 431 411 else 432 i1=Param.ActionInput.PairIndices.ref_i; %case of TESTmode 433 end 412 Data.Civ1_Time=(Time(i2+1,j2+1)+Time(i1+1,j1+1))/2;% the Time is the Time at the middle of the image pair 413 Data.Civ1_Dt=Time(i2+1,j2+1)-Time(i1+1,j1+1); 414 end 415 for ilist=1:length(list_param) 416 Data.(Civ1_param{4+ilist})=Param.ActionInput.Civ1.(list_param{ilist}); 417 end 418 Data.ListGlobalAttribute=[ListGlobalAttribute Civ1_param]; 419 Data.CivStage=1; 420 434 421 % set the list of variables 435 422 Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_FF'};% cell array containing the names of the fields to record … … 489 476 490 477 % caluclate velocity data 491 % tstart_civ1=tic;492 478 [Data.Civ1_X,Data.Civ1_Y,Data.Civ1_U,Data.Civ1_V,Data.Civ1_C,Data.Civ1_FF, result_conv, errormsg] = civ (par_civ1); 493 479 if ~isempty(errormsg) … … 495 481 return 496 482 end 497 % 498 % if exist('ncfile','var') 499 % CivFile=ncfile; 500 % % [Data,tild,tild,errormsg]=nc2struct(CivFile,'ListGlobalAttribute','absolut_time_T0'); %look for the constant 'absolut_time_T0' to detect old civx data format 501 % % if ~isempty(errormsg) 502 % % disp_uvmat('ERROR',errormsg,checkrun) 503 % % return 504 % % end 505 % [Data,tild,tild,errormsg]=nc2struct(CivFile);%read civ1 and fix1 data in the existing netcdf file 506 % if ~isempty(errormsg) 507 % disp(errormsg) 508 % return 509 % end 510 % elseif isfield(Param,'Civ1_X') 511 % Data.ListGlobalAttribute={}; 512 % Data.ListVarName={}; 513 % Data.VarDimName={}; 514 % Data.Civ1_X=Param.Civ1_X; 515 % Data.Civ1_Y=Param.Civ1_Y; 516 % Data.Civ1_U=Param.Civ1_U; 517 % Data.Civ1_V=Param.Civ1_V; 518 % Data.Civ1_FF=Param.Civ1_FF; 519 % end 520 end 521 483 end 484 522 485 523 486 %% Fix1 … … 542 505 end 543 506 %% Patch1 544 if isfield (Param.ActionInput,'Patch1')507 if Param.ActionInput.CheckPatch1 && isfield (Param.ActionInput,'Patch1') 545 508 disp('patch1 started') 546 tstart_patch1=tic;547 509 tstart_patch1=tic; 510 548 511 % record the processing parameters of Patch1 as global attributes in the result nc file 549 512 list_param=fieldnames(Param.ActionInput.Patch1)'; … … 574 537 end 575 538 if isempty(ind_good) 576 disp_uvmat('ERROR','all vectors of civ1 are bad, check input parameters' ,checkrun)577 return578 end 579 539 disp_uvmat('ERROR','all vectors of civ1 are bad, check input parameters' ,checkrun) 540 return 541 end 542 580 543 % perform Patch calculation using the UVMAT fct 'filter_tps' 581 544 [Data.Civ1_SubRange,Data.Civ1_NbCentres,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,~,Ures, Vres,~,FFres]=... … … 593 556 tstart_civ2=tic; 594 557 par_civ2=Param.ActionInput.Civ2; 595 if CheckInputFile % read input images (except in mode Test where it is introduced directly in Param.ActionInput.Civ1.ImageNameA and B) 596 par_civ2.ImageA=[]; 597 par_civ2.ImageB=[]; 598 if strcmp(Param.ActionInput.ListCompareMode,'displacement') 599 ImageName_A_Civ2=Param.ActionInput.RefFile; 600 else 601 ImageName_A_Civ2=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_civ2,[],j1_civ2); 602 end 603 if strcmp(ImageName_A_Civ2,ImageName_A) && isequal(FrameIndex_A_Civ1(ifield),FrameIndex_A_Civ2(ifield)) 604 par_civ2.ImageA=par_civ1.ImageA; 605 else 606 [par_civ2.ImageA,VideoObject_A] = read_image(ImageName_A_Civ2,FileType_A,VideoObject_A,FrameIndex_A_Civ2(ifield)); 607 end 608 ImageName_B_Civ2=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_civ2,[],j2_civ2); 609 if strcmp(ImageName_B_Civ2,ImageName_B) && isequal(FrameIndex_B_Civ1(ifield),FrameIndex_B_Civ2) 610 par_civ2.ImageB=par_civ1.ImageB; 611 else 612 [par_civ2.ImageB,VideoObject_B] = read_image(ImageName_B_Civ2,FileType_B,VideoObject_B,FrameIndex_B_Civ2(ifield)); 613 end 614 [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A_Civ2); 615 [npy_ima,npx_ima]=size(par_civ2.ImageA(:,:)); 616 % par_civ2.ImageWidth=FileInfo_A.Width; 617 % par_civ2.ImageHeight=FileInfo_A.Height; 618 619 if par_civ2.CheckGrid &&~isempty(par_civ2.Grid) % case of input grid 620 GridData=nc2struct(Param.ActionInput.Civ2.Grid); 621 par_civ2.Grid=GridData.Grid; 622 par_civ2.CorrBoxSize=GridData.CorrBox; 623 624 else% automatic grid 625 nbinterv_x=floor((npx_ima-1)/par_civ2.Dx); 626 gridlength_x=nbinterv_x*par_civ2.Dx; 627 minix=ceil((npx_ima-gridlength_x)/2); 628 nbinterv_y=floor((npy_ima-1)/par_civ2.Dy); 629 gridlength_y=nbinterv_y*par_civ2.Dy; 630 miniy=ceil((npy_ima-gridlength_y)/2); 631 [GridX,GridY]=meshgrid(minix:par_civ2.Dx:npx_ima-1,miniy:par_civ2.Dy:npy_ima-1); 632 par_civ2.Grid=zeros(numel(GridX),2); 633 par_civ2.Grid(:,1)=reshape(GridX,[],1); 634 par_civ2.Grid(:,2)=reshape(GridY,[],1);% increases with array index 635 636 end 637 end 638 558 % if CheckInputFile % read input images (except in mode Test where it is introduced directly in Param.ActionInput.Civ1.ImageNameA and B) 559 par_civ2.ImageA=[]; 560 par_civ2.ImageB=[]; 561 if strcmp(Param.ActionInput.ListCompareMode,'displacement') 562 ImageName_A_Civ2=Param.ActionInput.RefFile; 563 else 564 ImageName_A_Civ2=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_civ2,[],j1_civ2); 565 end 566 if strcmp(ImageName_A_Civ2,ImageName_A) && isequal(FrameIndex_A_Civ1(ifield),FrameIndex_A_Civ2(ifield)) 567 par_civ2.ImageA=par_civ1.ImageA; 568 else 569 [par_civ2.ImageA,VideoObject_A] = read_image(ImageName_A_Civ2,FileType_A,VideoObject_A,FrameIndex_A_Civ2(ifield)); 570 end 571 ImageName_B_Civ2=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_civ2,[],j2_civ2); 572 if strcmp(ImageName_B_Civ2,ImageName_B) && isequal(FrameIndex_B_Civ1(ifield),FrameIndex_B_Civ2) 573 par_civ2.ImageB=par_civ1.ImageB; 574 else 575 [par_civ2.ImageB,VideoObject_B] = read_image(ImageName_B_Civ2,FileType_B,VideoObject_B,FrameIndex_B_Civ2(ifield)); 576 end 577 % [FileInfo_A,VideoObject_A]=get_file_info(ImageName_A_Civ2); 578 npy_ima=size(par_civ2.ImageA,1); 579 npx_ima=size(par_civ2.ImageA,2); 580 if par_civ2.CheckGrid &&~isempty(par_civ2.Grid) % case of input grid 581 GridData=nc2struct(Param.ActionInput.Civ2.Grid); 582 par_civ2.Grid=GridData.Grid; 583 par_civ2.CorrBoxSize=GridData.CorrBox; 584 else% automatic grid 585 nbinterv_x=floor((npx_ima-1)/par_civ2.Dx); 586 gridlength_x=nbinterv_x*par_civ2.Dx; 587 minix=ceil((npx_ima-gridlength_x)/2); 588 nbinterv_y=floor((npy_ima-1)/par_civ2.Dy); 589 gridlength_y=nbinterv_y*par_civ2.Dy; 590 miniy=ceil((npy_ima-gridlength_y)/2); 591 [GridX,GridY]=meshgrid(minix:par_civ2.Dx:npx_ima-1,miniy:par_civ2.Dy:npy_ima-1); 592 par_civ2.Grid=zeros(numel(GridX),2); 593 par_civ2.Grid(:,1)=reshape(GridX,[],1); 594 par_civ2.Grid(:,2)=reshape(GridY,[],1);% increases with array index 595 end 596 639 597 % get the guess from patch1 or patch2 (case 'CheckCiv3') 640 % if CheckInputFile % read input images (except in mode Test where it is introduced directly in Param.ActionInput.Civ1.ImageNameA and B) 641 if isfield (par_civ2,'CheckCiv3') && par_civ2.CheckCiv3 %get the guess from patch2 642 SubRange= Data.Civ2_SubRange; 643 NbCentres=Data.Civ2_NbCentres; 644 Coord_tps=Data.Civ2_Coord_tps; 645 U_tps=Data.Civ2_U_tps; 646 V_tps=Data.Civ2_V_tps; 647 CivStage=Data.CivStage;%store the current CivStage 648 Civ1_Dt=Data.Civ2_Dt; 598 if iview_A==2 && isfield (par_civ2,'CheckCiv3') && strcmp(par_civ2.CheckCiv3,'iterate(civ3)') %get the guess from patch2% Civ1 data read in a netcdf file 599 [DataIn,~,~,errormsg]=nc2struct(filecell{1,ifield}); 600 if ~isempty(errormsg) 601 disp(errormsg) 602 return 603 end 604 SubRange= DataIn.Civ2_SubRange; 605 NbCentres=DataIn.Civ2_NbCentres; 606 Coord_tps=DataIn.Civ2_Coord_tps; 607 U_tps=DataIn.Civ2_U_tps; 608 V_tps=DataIn.Civ2_V_tps; 609 %CivStage=DataIn.CivStage;%store the current CivStage 610 Civ1_Dt=DataIn.Civ2_Dt; 649 611 Data=[];%reinitialise the result structure Data 650 612 Data.ListGlobalAttribute={'Conventions','Program','CivStage'}; 651 613 Data.Conventions='uvmat/civdata';% states the conventions used for the description of field variables and attributes 652 614 Data.Program='civ_series'; 653 Data.CivStage=CivStage+1;%update the current civStage after reinitialisation of Data615 % Data.CivStage=CivStage+1;%update the current civStage after reinitialisation of Data 654 616 Data.ListVarName={}; 655 617 Data.VarDimName={}; … … 661 623 V_tps=Data.Civ1_V_tps; 662 624 Civ1_Dt=Data.Civ1_Dt; 663 Data.CivStage=4;664 end 665 % else666 % SubRange= par_civ2.Civ1_SubRange;667 % NbCentres=par_civ2.Civ1_NbCentres;668 % Coord_tps=par_civ2.Civ1_Coord_tps;669 % U_tps=par_civ2.Civ1_U_tps;670 % V_tps=par_civ2.Civ1_V_tps;671 % Civ1_Dt=par_civ2.Civ1_Dt;672 % Civ2_Dt=par_civ2.Civ1_Dt;673 % Data.ListVarName={};674 % Data.VarDimName={};675 % end676 Shiftx=zeros(size(par_civ2.Grid,1),1);% shift expected from civ1 data625 % Data.CivStage=4; 626 end 627 Data.CivStage=4; 628 % SubRange= par_civ2.Civ1_SubRange; 629 % NbCentres=par_civ2.Civ1_NbCentres; 630 % Coord_tps=par_civ2.Civ1_Coord_tps; 631 % U_tps=par_civ2.Civ1_U_tps; 632 % V_tps=par_civ2.Civ1_V_tps; 633 % Civ1_Dt=par_civ2.Civ1_Dt; 634 % Civ2_Dt=par_civ2.Civ1_Dt; 635 % Data.ListVarName={}; 636 % Data.VarDimName={}; 637 % end 638 Shiftx=zeros(size(par_civ2.Grid,1),1);% initialise the shift expected from civ1 data 677 639 Shifty=zeros(size(par_civ2.Grid,1),1); 678 640 nbval=zeros(size(par_civ2.Grid,1),1);% nbre of interpolated values at each grid point (from the different patch subdomains) … … 713 675 Shiftx(nbval>0)=Shiftx(nbval>0)./nbval(nbval>0); 714 676 Shifty(nbval>0)=Shifty(nbval>0)./nbval(nbval>0); 715 677 716 678 % introduce mask 717 679 if par_civ2.CheckMask && ~isempty(par_civ2.Mask) … … 753 715 end 754 716 end 755 756 if CheckInputFile % else Dt given by par_civ2 757 if strcmp(Param.ActionInput.ListCompareMode,'displacement') 758 Civ1_Dt=1; 759 Civ2_Dt=1; 760 else 761 Civ2_Dt=Time(i2_civ2+1,j2_civ2+1)-Time(i1_civ2+1,j1_civ2+1); 762 end 717 718 719 if strcmp(Param.ActionInput.ListCompareMode,'displacement') 720 Civ1_Dt=1; 721 Civ2_Dt=1; 722 else 723 Civ2_Dt=Time(i2_civ2+1,j2_civ2+1)-Time(i1_civ2+1,j1_civ2+1); 763 724 end 764 725 par_civ2.SearchBoxShift=zeros(size(par_civ2.Grid)); 765 par_civ2.SearchBoxShift(:,1)=(Civ2_Dt/Civ1_Dt)*Shiftx; 726 par_civ2.SearchBoxShift(:,1)=(Civ2_Dt/Civ1_Dt)*Shiftx;%rescale the shift in case of Dt different for Civ1 and Civ2 766 727 par_civ2.SearchBoxShift(:,2)=(Civ2_Dt/Civ1_Dt)*Shifty; 767 % shift the grid points by half the expected shift to provide the correlation box position in image A 768 %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]; 769 728 770 729 if par_civ2.CheckDeformation 771 730 par_civ2.DUDX(nbval>0)=DUDX(nbval>0)./nbval(nbval>0); … … 774 733 par_civ2.DVDY(nbval>0)=DVDY(nbval>0)./nbval(nbval>0); 775 734 end 776 735 777 736 % calculate velocity data (y and v in image indices, reverse to y component) 778 737 779 738 [Data.Civ2_X,Data.Civ2_Y,Data.Civ2_U,Data.Civ2_V,Data.Civ2_C,Data.Civ2_FF,~, errormsg] = civ (par_civ2); 780 739 781 740 list_param=(fieldnames(Param.ActionInput.Civ2))'; 782 741 list_param(strcmp('TestCiv2',list_param))=[];% remove the parameter TestCiv2 from the list … … 799 758 end 800 759 Data.ListGlobalAttribute=[Data.ListGlobalAttribute Civ2_param]; 801 760 802 761 nbvar=numel(Data.ListVarName); 803 762 % define the Civ2 variable (if Civ2 data are not replaced from previous calculation) … … 817 776 if exist('ncfile','var') 818 777 CivFile=ncfile; 819 [Data, tild,tild,errormsg]=nc2struct(CivFile);%read civ1 and detect_false1 data in the existing netcdf file778 [Data,~,~,errormsg]=nc2struct(CivFile);%read civ1 and detect_false1 data in the existing netcdf file 820 779 if ~isempty(errormsg) 821 780 disp_uvmat('ERROR',errormsg,checkrun) … … 824 783 end 825 784 end 826 785 827 786 %% Fix2 828 if isfield (Param.ActionInput,'Fix2')787 if Param.ActionInput.CheckFix2 && isfield (Param.ActionInput,'Fix2')% if Fix2 computation is requested 829 788 disp('detect_false2 started') 830 789 list_param=fieldnames(Param.ActionInput.Fix2)'; … … 840 799 841 800 %% Patch2 842 if isfield (Param.ActionInput,'Patch2') 801 if Param.ActionInput.CheckPatch2 && isfield (Param.ActionInput,'Patch2')% if Patch2 computation is requested 802 843 803 disp('patch2 started') 844 804 tstart_patch2=tic; … … 869 829 ind_good=1:numel(Data.Civ2_X); 870 830 end 871 if isempty(ind_good)872 disp_uvmat('ERROR','all vectors of civ2 are bad, check input parameters' ,checkrun)873 return874 end875 831 if isempty(ind_good) 832 disp_uvmat('ERROR','all vectors of civ2 are bad, check input parameters' ,checkrun) 833 return 834 end 835 876 836 [Data.Civ2_SubRange,Data.Civ2_NbCentres,Data.Civ2_Coord_tps,Data.Civ2_U_tps,Data.Civ2_V_tps,tild,Ures,Vres,tild,FFres]=... 877 837 filter_tps([Data.Civ2_X(ind_good) Data.Civ2_Y(ind_good)],Data.Civ2_U(ind_good),Data.Civ2_V(ind_good),[],Data.Patch2_SubDomainSize,Data.Patch2_FieldSmooth,Data.Patch2_MaxDiff); … … 884 844 end 885 845 886 %% write result in a netcdf file if requested887 if CheckOutputFile888 errormsg=struct2nc(ncfile_out,Data);889 if isempty(errormsg)890 disp([ncfile_out ' written'])891 else892 disp(errormsg)893 end894 time_total=toc(tstart);895 disp(['ellapsed time ' num2str(time_total/60,2) ' minutes'])896 disp(['time civ1 ' num2str(time_civ1,2) ' s'])897 disp(['time patch1 ' num2str(time_patch1,2) ' s'])898 disp(['time civ2 ' num2str(time_civ2,2) ' s'])899 disp(['time patch2 ' num2str(time_patch2,2) ' s'])900 if exist('time_input','var')901 disp(['time image reading ' num2str(time_input,2) ' s'])902 disp(['time other ' num2str((time_total-time_input-time_civ1-time_patch1-time_civ2-time_patch2),2) ' s'])903 end904 end 905 end 846 %% write result in a netcdf file 847 errormsg=struct2nc(ncfile_out,Data); 848 if isempty(errormsg) 849 disp([ncfile_out ' written']) 850 else 851 disp(errormsg) 852 end 853 time_total=toc(tstart); 854 disp(['ellapsed time ' num2str(time_total/60,2) ' minutes']) 855 disp(['time civ1 ' num2str(time_civ1,2) ' s']) 856 disp(['time patch1 ' num2str(time_patch1,2) ' s']) 857 disp(['time civ2 ' num2str(time_civ2,2) ' s']) 858 disp(['time patch2 ' num2str(time_patch2,2) ' s']) 859 if exist('time_input','var') 860 disp(['time image reading ' num2str(time_input,2) ' s']) 861 disp(['time other ' num2str((time_total-time_input-time_civ1-time_patch1-time_civ2-time_patch2),2) ' s']) 862 end 863 end 864 865 906 866 907 867 %------------------------------------------------------------------------ … … 967 927 end 968 928 929 %------------------------------------------------------------------------ 930 % --- set the flag for false vectors 969 931 function FF=detect_false(Param,C,U,V,FFIn) 970 932 FF=FFIn;%default, good vectors -
trunk/src/uvmat.m
r1168 r1169 2898 2898 %case of view mask selection 2899 2899 if isequal(get(handles.CheckMask,'Value'),1) 2900 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); 2901 % if isempty(regexp(RootPath,'^http://')) 2902 % fileinput=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% build the input file name (first line) 2903 % else 2904 % fileinput=[RootPath '/' SubDir '/' RootFile FileIndex FileExt];% 2905 % end 2906 % FileInfo=get_file_info(fileinput); 2907 2908 % MaskSubDir=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' 2909 % MaskPath=fullfile(RootPath,[MaskSubDir '.mask']); 2910 mdetect=0; 2911 % if exist(MaskPath,'dir') 2912 % ListStruct=dir(MaskPath);%look for a mask file 2913 % ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray 2914 % check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files 2915 % ListFiles=ListCells(1,:);%list of file and dri names 2916 % ListFiles=ListFiles(~check_dir);%list of file names (excluding dir) 2917 % if ~isempty(ListFiles) 2918 % for ifile=1:numel(ListFiles) 2919 % [tild,tild,MaskExt]=fileparts(ListFiles{1}); 2920 % [tild,tild,MaskFile{ifile},i1_series,i2_series,j1_series,j2_series,MaskNomType,MaskFileInfo]=find_file_series(MaskPath,ListFiles{ifile},0); 2921 % MaskFileType=MaskFileInfo.FileType; 2922 % if strcmp(MaskFileType,'image') && isempty(i2_series) && isempty(j2_series) 2923 % mdetect=1; 2924 % end 2925 % if ~strcmp(MaskFile{ifile},MaskFile{1}) 2926 % mdetect=0;% cancel detection test in case of multiple masks, use the brower for selection 2927 % break 2928 % end 2929 % end 2930 % end 2931 % RootPath=MaskPath; 2932 % end 2933 filemask= uigetfile_uvmat('pick a mask image file:',RootPath,'image'); 2900 [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles); 2901 if isempty(regexp(RootPath,'^http://')) 2902 fileinput=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% build the input file name (first line) 2903 else 2904 fileinput=[RootPath '/' SubDir '/' RootFile FileIndex FileExt];% 2905 end 2906 FileInfo=get_file_info(fileinput); 2907 if isfield(FileInfo,'MaskFile')&& exist(FileInfo.MaskFile,'file') 2908 filemask=FileInfo.MaskFile; 2909 else 2910 % MaskSubDir=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' 2911 % MaskPath=fullfile(RootPath,[MaskSubDir '.mask']); 2912 % mdetect=0; 2913 % if exist(MaskPath,'dir') 2914 % ListStruct=dir(MaskPath);%look for a mask file 2915 % ListCells=struct2cell(ListStruct);% transform dir struct to a cell arrray 2916 % check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files 2917 % ListFiles=ListCells(1,:);%list of file and dri names 2918 % ListFiles=ListFiles(~check_dir);%list of file names (excluding dir) 2919 % if ~isempty(ListFiles) 2920 % for ifile=1:numel(ListFiles) 2921 % [tild,tild,MaskExt]=fileparts(ListFiles{1}); 2922 % [tild,tild,MaskFile{ifile},i1_series,i2_series,j1_series,j2_series,MaskNomType,MaskFileInfo]=find_file_series(MaskPath,ListFiles{ifile},0); 2923 % MaskFileType=MaskFileInfo.FileType; 2924 % if strcmp(MaskFileType,'image') && isempty(i2_series) && isempty(j2_series) 2925 % mdetect=1; 2926 % end 2927 % if ~strcmp(MaskFile{ifile},MaskFile{1}) 2928 % mdetect=0;% cancel detection test in case of multiple masks, use the brower for selection 2929 % break 2930 % end 2931 % end 2932 % end 2933 % RootPath=MaskPath; 2934 % end 2935 filemask= uigetfile_uvmat('pick a mask image file:',RootPath,'image'); 2936 end 2934 2937 if ~isempty(filemask) 2935 2938 [MaskPath,FileName,FileExt]=fileparts(filemask); … … 2949 2952 errormsg=update_mask(handles); 2950 2953 if ~isempty(errormsg) 2951 msgbox_uvmat(['ERROR','error in displaying mask, ' errormsg]);2954 msgbox_uvmat(['ERROR','error in displaying mask, ' errormsg]); 2952 2955 end 2953 2956 testmask=1; … … 2956 2959 MaskData=get(handles.CheckMask,'UserData'); 2957 2960 if isfield(MaskData,'maskhandle') && ishandle(MaskData.maskhandle) 2958 delete(MaskData.maskhandle) 2961 % delete(MaskData.maskhandle) 2962 set(MaskData.maskhandle,'Visible','off') 2959 2963 end 2960 2964 set(handles.CheckMask,'UserData',[]) … … 3037 3041 if ~isempty(hmask) 3038 3042 set(hmask,'CData',imflag) 3039 set(hmask,'AlphaData',flagmask*0. 6)3043 set(hmask,'AlphaData',flagmask*0.3) 3040 3044 set(hmask,'XData',MaskField.Coord_x); 3041 3045 set(hmask,'YData',MaskField.Coord_y); … … 3044 3048 axes(handles.PlotAxes) 3045 3049 hold on 3046 MaskInfo.maskhandle=image(MaskField.Coord_x,MaskField.Coord_y,imflag,'Tag','mask','HitTest','off','AlphaData',0. 6*ones(size(flagmask)));3050 MaskInfo.maskhandle=image(MaskField.Coord_x,MaskField.Coord_y,imflag,'Tag','mask','HitTest','off','AlphaData',0.3*ones(size(flagmask))); 3047 3051 set(handles.CheckMask,'UserData',MaskInfo) 3048 3052 end
Note: See TracChangeset
for help on using the changeset viewer.
