Changeset 758 for trunk/src/series/civ_series.m
 Timestamp:
 Apr 29, 2014, 10:11:11 AM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/series/civ_series.m
r736 r758 63 63 Data.OutputSubDirMode='last'; %select the last subDir in the input table as root of the output subdir name (option 'all'/'first'/'last', 'all' by default) 64 64 Data.OutputFileMode='NbInput_i';% one output file expected per value of i index (used for waitbar) 65 % check the existence of the first file in the series 66 first_j=[]; 67 if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end 68 last_j=[]; 69 if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end 70 PairString=''; 71 if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end 72 [i1,i2,j1,j2] = get_file_index(Param.IndexRange.first_i,first_j,PairString); 73 FirstFileName=fullfile_uvmat(Param.InputTable{1,1},Param.InputTable{1,2},Param.InputTable{1,3},... 74 Param.InputTable{1,5},Param.InputTable{1,4},i1,i2,j1,j2); 75 if ~exist(FirstFileName,'file') 76 msgbox_uvmat('WARNING',['the first input file ' FirstFileName ' does not exist']) 77 else 78 FileType=get_file_type(FirstFileName); 79 if isempty(find(strcmp(FileType,{'civdata','image','multimage','mmreader','video'})));% =1 for images 80 msgbox_uvmat('ERROR',['bad input file type for ' mfilename ': an image or civdata file is needed']) 81 end 82 end 65 % check the existence of the first file in the series: suppressed 66 % first_j=[]; 67 % if isfield(Param.IndexRange,'first_j'); first_j=Param.IndexRange.first_j; end 68 % last_j=[]; 69 % if isfield(Param.IndexRange,'last_j'); last_j=Param.IndexRange.last_j; end 70 % PairString=''; 71 % if isfield(Param.IndexRange,'PairString'); PairString=Param.IndexRange.PairString; end 83 72 return 84 73 end … … 99 88 100 89 %% input files and indexing 101 NbField=1;90 % NbField=1; 102 91 MaxIndex_i=Param.IndexRange.MaxIndex_i; 103 92 MinIndex_i=Param.IndexRange.MinIndex_i; … … 108 97 end 109 98 if isfield(Param,'InputTable') 110 [filecell,i_series,tild,j_series]=get_file_series(Param); 111 if ~exist(filecell{1,1},'file') 112 disp_uvmat('ERROR',' the first input file does not exist',checkrun) 113 return 114 else 115 FileType=get_file_type(filecell{1,1}); 116 iview_nc=0;% series index (iview) for an input nc file (for civ2 or patch2) 117 iview_A=0;% series index (iview) for the first image series 118 iview_B=0;% series index (iview) for the second image series (only non zero for option 'shift' ) 119 switch FileType 120 case 'civdata';% =1 for images 121 iview_nc=1; 122 if size(filecell,1)>=2 123 iview_A=2;iview_B=2; 124 if size(filecell,1)>=3 125 iview_B=3; 126 end 127 end 128 case {'image','multimage','mmreader','video'} 129 iview_A=1; 130 if size(filecell,1)>=2 131 iview_B=2; 132 end 133 end 99 [tild,i_series,tild,j_series]=get_file_series(Param); 100 % iview_nc=0;% series index (iview) for an input nc file (for civ2 or patch2) 101 iview_A=0;% series index (iview) for the first image series 102 iview_B=0;% series index (iview) for the second image series (only non zero for option 'shift' comparing two image series ) 103 if Param.ActionInput.CheckCiv1 104 iview_A=1;% usual PIV, the image series is on the first line of the table 105 elseif Param.ActionInput.CheckCiv2 % civ2 is performed without Civ1, a netcdf file series is needed in the first table line 106 iview_A=2;% the second line is used for the input images of Civ2 107 end 108 if strcmp(Param.ActionInput.ListCompareMode,'shift') 109 iview_B=iview_A+1; % the second image series is on the next line of the tinput table 134 110 end 135 111 if iview_A~=0 136 [FileType_A,FileInfo_A,VideoObject_A]=get_file_type(filecell{1,1}); 137 if isempty(strcmp(FileType_A,{'multimage','mmreader','video'})) 138 displ(['ERROR: the file line ' num2str(iview_A) ' must be an image']) 139 end 140 RootPath_A=Param.InputTable{1,1}; 141 RootFile_A=Param.InputTable{1,3}; 142 SubDir_A=Param.InputTable{1,2}; 143 NomType_A=Param.InputTable{1,4}; 144 FileExt_A=Param.InputTable{1,5}; 145 end 146 if iview_B==0 147 FileType_B=FileType_A; 148 VideoObject_B=VideoObject_A; 149 RootPath_B=RootPath_A; 150 RootFile_B=RootFile_A; 151 SubDir_B=SubDir_A; 152 NomType_B=NomType_A; 153 FileExt_B=FileExt_A; 154 PairCiv2=''; 155 switch Param.ActionInput.ListCompareMode 156 case 'PIV' 157 PairCiv1=Param.ActionInput.PairIndices.ListPairCiv1; 158 if isfield(Param.ActionInput.PairIndices,'ListPairCiv2') 159 PairCiv2=Param.ActionInput.PairIndices.ListPairCiv2; 160 end 161 [i1_series_Civ1,i2_series_Civ1,j1_series_Civ1,j2_series_Civ1,check_bounds,NomTypeNc]=... 162 find_pair_indices(PairCiv1,i_series{1},j_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j); 163 if ~isempty(PairCiv2) 164 [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds_Civ2]=... 165 find_pair_indices(PairCiv2,i_series{1},j_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j); 166 check_bounds=check_bounds  check_bounds_Civ2; 167 end 168 i1_series_Civ1=i1_series_Civ1(~check_bounds); 169 i2_series_Civ1=i2_series_Civ1(~check_bounds); 170 j1_series_Civ1=j1_series_Civ1(~check_bounds); 171 j2_series_Civ1=j2_series_Civ1(~check_bounds); 172 case 'displacement' 173 i1_series_Civ1=Param.ActionInput.OriginIndex*ones(size(i_series{1})); 174 i2_series_Civ1=i_series{1};i2_series_Civ2=i_series{1}; 175 j1_series_Civ1=ones(size(i_series{1}));% first j index is 1 176 if isempty(j_series{1}) 177 j2_series_Civ1=ones(size(i_series{1})); 178 else 179 j2_series_Civ1=j_series{1}; 180 end 181 i1_series_Civ2=i1_series_Civ1; 182 j1_series_Civ2=j1_series_Civ1; 183 j2_series_Civ2=j2_series_Civ1; 184 NomTypeNc=NomType; 185 end 186 if ~isempty(PairCiv2) 187 i1_series_Civ2=i1_series_Civ2(~check_bounds); 188 i2_series_Civ2=i2_series_Civ2(~check_bounds); 189 j1_series_Civ2=j1_series_Civ2(~check_bounds); 190 j2_series_Civ2=j2_series_Civ2(~check_bounds); 112 RootPath_A=Param.InputTable{iview_A,1}; 113 RootFile_A=Param.InputTable{iview_A,3}; 114 SubDir_A=Param.InputTable{iview_A,2}; 115 NomType_A=Param.InputTable{iview_A,4}; 116 FileExt_A=Param.InputTable{iview_A,5}; 117 if iview_B==0 118 iview_B=iview_A;% the second image series is the same as the first 119 end 120 RootPath_B=Param.InputTable{iview_B,1}; 121 RootFile_B=Param.InputTable{iview_B,3}; 122 SubDir_B=Param.InputTable{iview_B,2}; 123 NomType_B=Param.InputTable{iview_B,4}; 124 FileExt_B=Param.InputTable{iview_B,5}; 125 end 126 127 PairCiv2=''; 128 switch Param.ActionInput.ListCompareMode 129 case 'PIV' 130 PairCiv1=Param.ActionInput.PairIndices.ListPairCiv1; 131 if isfield(Param.ActionInput.PairIndices,'ListPairCiv2') 132 PairCiv2=Param.ActionInput.PairIndices.ListPairCiv2; 133 end 134 [i1_series_Civ1,i2_series_Civ1,j1_series_Civ1,j2_series_Civ1,check_bounds,NomTypeNc]=... 135 find_pair_indices(PairCiv1,i_series{1},j_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j); 136 if ~isempty(PairCiv2) 137 [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds_Civ2]=... 138 find_pair_indices(PairCiv2,i_series{1},j_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j); 139 check_bounds=check_bounds  check_bounds_Civ2; 140 end 141 i1_series_Civ1=i1_series_Civ1(~check_bounds); 142 i2_series_Civ1=i2_series_Civ1(~check_bounds); 143 j1_series_Civ1=j1_series_Civ1(~check_bounds); 144 j2_series_Civ1=j2_series_Civ1(~check_bounds); 145 case 'displacement' 146 i1_series_Civ1=Param.ActionInput.OriginIndex*ones(size(i_series{1})); 147 i2_series_Civ1=i_series{1};i2_series_Civ2=i_series{1}; 148 j1_series_Civ1=ones(size(i_series{1}));% first j index is 1 191 149 if isempty(j_series{1}) 192 FrameIndex_A_Civ2=i1_series_Civ2; 193 FrameIndex_B_Civ2=i2_series_Civ2; 150 j2_series_Civ1=ones(size(i_series{1})); 194 151 else 195 FrameIndex_A_Civ2=j1_series_Civ2; 196 FrameIndex_B_Civ2=j2_series_Civ2; 197 end 198 end 199 else 200 [FileType_B,FileInfo,VideoObject_B]=get_file_type(filecell{2,1}); 201 if ~ismember(FileType_B,{'image','multimage','mmreader','video'}) 202 disp_uvmat('ERROR',['the file line ' num2str(iview_B) ' must be an image'],checkrun) 203 end 204 i1_series_Civ1=i_series{1};i1_series_Civ2=i_series{1}; 205 i2_series_Civ1=i_series{1};i2_series_Civ2=i_series{1}; 206 if isempty(j_series{1}) 207 j1_series_Civ1=ones(size(i_series{1})); 208 j2_series_Civ1=ones(size(i_series{1})); 209 else 210 j1_series_Civ1=j_series{1}; 211 j2_series_Civ1=j_series{1}; 212 end 213 j1_series_Civ2=j1_series_Civ1; 214 j2_series_Civ2=j2_series_Civ1; 215 NomTypeNc=NomType_A; 216 RootPath_B=Param.InputTable{2,1}; 217 RootFile_B=Param.InputTable{2,3}; 218 SubDir_B=Param.InputTable{2,2}; 219 NomType_B=Param.InputTable{2,4}; 220 FileExt_B=Param.InputTable{2,5}; 152 j2_series_Civ1=j_series{1}; 153 end 154 i1_series_Civ2=i1_series_Civ1; 155 j1_series_Civ2=j1_series_Civ1; 156 j2_series_Civ2=j2_series_Civ1; 157 NomTypeNc=NomType; 158 case 'shift' 159 i1_series_Civ1=i_series{1};i1_series_Civ2=i_series{1}; 160 i2_series_Civ1=i_series{1};i2_series_Civ2=i_series{1}; 161 if isempty(j_series{1}) 162 j1_series_Civ1=ones(size(i_series{1})); 163 j2_series_Civ1=ones(size(i_series{1})); 164 else 165 j1_series_Civ1=j_series{1}; 166 j2_series_Civ1=j_series{1}; 167 end 168 j1_series_Civ2=j1_series_Civ1; 169 j2_series_Civ2=j2_series_Civ1; 170 NomTypeNc=NomType_A; 221 171 end 222 172 if isempty(j_series{1}) … … 227 177 FrameIndex_B_Civ1=j2_series_Civ1; 228 178 end 229 end 230 NbField=numel(i1_series_Civ1); 179 if ~isempty(PairCiv2) 180 i1_series_Civ2=i1_series_Civ2(~check_bounds); 181 i2_series_Civ2=i2_series_Civ2(~check_bounds); 182 j1_series_Civ2=j1_series_Civ2(~check_bounds); 183 j2_series_Civ2=j2_series_Civ2(~check_bounds); 184 if isempty(j_series{1}) 185 FrameIndex_A_Civ2=i1_series_Civ2; 186 FrameIndex_B_Civ2=i2_series_Civ2; 187 else 188 FrameIndex_A_Civ2=j1_series_Civ2; 189 FrameIndex_B_Civ2=j2_series_Civ2; 190 end 191 end 192 if isempty(i1_series_Civ1)(~isempty(PairCiv2) && isempty(i1_series_Civ2)) 193 disp_uvmat('ERROR','no image pair fo civ in the input file index range',checkrun) 194 return 195 end 196 end 197 198 %% check the first image pair 199 try 200 if Param.ActionInput.CheckCiv1% Civ1 is performed 201 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(1),[],j1_series_Civ1(1)); 202 if ~exist(ImageName_A,'file') 203 disp_uvmat('ERROR',['first input image ' ImageName_A ' does not exist'],checkrun) 204 return 205 end 206 [FileType_A,FileInfo_A,VideoObject_A]=get_file_type(ImageName_A); 207 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(1)); 208 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(1),[],j2_series_Civ1(1)); 209 if ~exist(ImageName_B,'file') 210 disp_uvmat('ERROR',['first input image ' ImageName_B ' does not exist'],checkrun) 211 return 212 end 213 [FileType_B,FileInfo_B,VideoObject_B]=get_file_type(ImageName_B); 214 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(1)); 215 NbField=numel(i1_series_Civ1); 216 elseif Param.ActionInput.CheckCiv2 % Civ2 is performed without Civ1 217 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ2(1),[],j1_series_Civ2(1)); 218 if ~exist(ImageName_A,'file') 219 disp_uvmat('ERROR',['first input image ' ImageName_A ' does not exist'],checkrun) 220 return 221 end 222 [FileType_A,FileInfo_A,VideoObject_A]=get_file_type(ImageName_A); 223 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ2(1)); 224 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ2(1),[],j2_series_Civ2(1)); 225 if ~exist(ImageName_B,'file') 226 disp_uvmat('ERROR',['first input image ' ImageName_B ' does not exist'],checkrun) 227 return 228 end 229 [FileType_B,FileInfo_B,VideoObject_B]=get_file_type(ImageName_B); 230 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ2(1)); 231 NbField=numel(i1_series_Civ2); 232 end 233 catch ME 234 if ~isempty(ME.message) 235 disp_uvmat('ERROR', ['error reading input image: ' ME.message],checkrun) 236 return 237 end 238 end 239 231 240 232 241 %% Output directory … … 237 246 Data.Program='civ_series'; 238 247 Data.CivStage=0;%default 239 ListVarCiv1={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'}; %variables to read240 ListVarFix1={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F','Civ1_FF'};241 mask='';248 % ListVarCiv1={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F'}; %variables to read 249 % ListVarFix1={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_F','Civ1_FF'}; 250 % mask=''; 242 251 maskname='';%default 243 252 check_civx=0;%default 244 check_civ1=0;%default245 check_patch1=0;%default253 % check_civ1=0;%default 254 % check_patch1=0;%default 246 255 247 256 %% get timing from the ImaDoc file or input video … … 303 312 if isfield (Param.ActionInput,'Civ1') 304 313 par_civ1=Param.ActionInput.Civ1; 305 if isfield(par_civ1,'reverse_pair')% A REVOIR 306 if par_civ1.reverse_pair 307 if ischar(par_civ1.ImageB) 308 temp=par_civ1.ImageA; 309 par_civ1.ImageA=imread(par_civ1.ImageB); 310 end 311 if ischar(temp) 312 par_civ1.ImageB=imread(temp); 313 end 314 end 315 else 314 try 316 315 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(ifield),[],j1_series_Civ1(ifield)); 317 316 [par_civ1.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(ifield)); 318 317 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(ifield),[],j2_series_Civ1(ifield)); 319 318 [par_civ1.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(ifield)); 319 catch ME 320 if ~isempty(ME.message) 321 disp_uvmat('ERROR', ['error reading input image: ' ME.message],checkrun) 322 return 323 end 320 324 end 321 325 par_civ1.ImageWidth=FileInfo_A.Width;
Note: See TracChangeset
for help on using the changeset viewer.