Changeset 1144 for trunk/src/series/civ_series.m
- Timestamp:
- May 13, 2024, 9:49:09 PM (5 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/civ_series.m
r1143 r1144 249 249 Data.Program='civ_series'; 250 250 Data.CivStage=0;%default 251 check_civx=0;%default252 251 253 252 %% get timing from the ImaDoc file or input video … … 332 331 if strcmp(Param.ActionInput.ListCompareMode,'PIV') 333 332 ncfile_out=fullfile_uvmat(OutputPath,OutputDir,RootFile_A,'.nc',NomTypeNc,i1_civ2,i2_civ2,j1_civ2,j2_civ2); 334 % ncfile_out=fullfile_uvmat(RootPath_A,OutputDir,RootFile_A,'.nc',NomTypeNc,i1_civ2,i2_civ2,j1_civ2,j2_civ2);335 333 else % displacement 336 334 ncfile_out=fullfile_uvmat(OutputPath,OutputDir,RootFile_A,'.nc',NomTypeNc,i2_civ2,[],j2_civ2); … … 448 446 end 449 447 % set the list of variables 450 Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_ F','Civ1_C'};% cell array containing the names of the fields to record448 Data.ListVarName={'Civ1_X','Civ1_Y','Civ1_U','Civ1_V','Civ1_C','Civ1_FF'};% cell array containing the names of the fields to record 451 449 Data.VarDimName={'nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1','nb_vec_1'}; 452 450 Data.VarAttribute{1}.Role='coord_x'; … … 454 452 Data.VarAttribute{3}.Role='vector_x'; 455 453 Data.VarAttribute{4}.Role='vector_y'; 456 Data.VarAttribute{5}.Role='warnflag'; 454 Data.VarAttribute{5}.Role='ancillary'; 455 Data.VarAttribute{6}.Role='errorflag'; 457 456 % case of mask 458 457 if par_civ1.CheckMask&&~isempty(par_civ1.Mask) … … 487 486 Data.ListVarName=[Data.ListVarName 'Civ1_Z']; 488 487 Data.Civ1_X=[];Data.Civ1_Y=[];Data.Civ1_Z=[]; 489 Data.Civ1_U=[];Data.Civ1_V=[];Data.Civ1_C=[]; Data.Civ1_F=[];488 Data.Civ1_U=[];Data.Civ1_V=[];Data.Civ1_C=[]; 490 489 for ivol=1:NbSlice 491 490 % caluclate velocity data (y and v in indices, reverse to y component) … … 501 500 Data.Civ1_V=[Data.Civ1_V reshape(-vtable,[],1)]; 502 501 Data.Civ1_C=[Data.Civ1_C reshape(ctable,[],1)]; 503 Data.Civ1_F =[Data.Civ1_Creshape(F,[],1)];502 Data.Civ1_FF=[Data.Civ1_FF reshape(F,[],1)]; 504 503 end 505 504 else %usual PIV … … 516 515 Data.Civ1_V=reshape(-vtable,[],1); 517 516 Data.Civ1_C=reshape(ctable,[],1); 518 Data.Civ1_F =reshape(F,[],1);517 Data.Civ1_FF=reshape(F,[],1); 519 518 time_civ1=toc(tstart_civ1); 520 519 end … … 557 556 end 558 557 Data.ListGlobalAttribute=[Data.ListGlobalAttribute Fix1_param]; 559 Data.ListVarName=[Data.ListVarName {'Civ1_FF'}]; 560 Data.VarDimName=[Data.VarDimName {'nb_vec_1'}]; 561 nbvar=length(Data.ListVarName); 562 Data.VarAttribute{nbvar}.Role='errorflag'; 563 Data.Civ1_FF=int8(detect_false(Param.ActionInput.Fix1,Data.Civ1_F,Data.Civ1_C,Data.Civ1_U,Data.Civ1_V)); 558 Data.Civ1_FF=uint8(detect_false(Param.ActionInput.Fix1,Data.Civ1_C,Data.Civ1_U,Data.Civ1_V,Data.Civ1_FF)); 564 559 Data.CivStage=2; 565 560 end … … 568 563 disp('patch1 started') 569 564 tstart_patch1=tic; 570 if check_civx 571 errormsg='Civ Matlab input needed for patch'; 572 disp_uvmat('ERROR',errormsg,checkrun) 573 return 574 end 575 565 576 566 % record the processing parameters of Patch1 as global attributes in the result nc file 577 567 list_param=fieldnames(Param.ActionInput.Patch1)'; … … 612 602 Data.Civ1_U_smooth(ind_good)=Ures;% take the interpolated (smoothed) velocity values for good vectors, keep civ1 data for the other 613 603 Data.Civ1_V_smooth(ind_good)=Vres; 614 Data.Civ1_FF(ind_good)= int8(FFres);604 Data.Civ1_FF(ind_good)=uint8(FFres); 615 605 time_patch1=toc(tstart_patch1); 616 606 disp('patch1 performed') … … 802 792 % define the Civ2 variable (if Civ2 data are not replaced from previous calculation) 803 793 if isempty(find(strcmp('Civ2_X',Data.ListVarName),1)) 804 Data.ListVarName=[Data.ListVarName {'Civ2_X','Civ2_Y','Civ2_U','Civ2_V','Civ2_ F','Civ2_C'}];% cell array containing the names of the fields to record794 Data.ListVarName=[Data.ListVarName {'Civ2_X','Civ2_Y','Civ2_U','Civ2_V','Civ2_C','Civ2_FF'}];% cell array containing the names of the fields to record 805 795 Data.VarDimName=[Data.VarDimName {'nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2','nb_vec_2'}]; 806 796 Data.VarAttribute{nbvar+1}.Role='coord_x'; … … 808 798 Data.VarAttribute{nbvar+3}.Role='vector_x'; 809 799 Data.VarAttribute{nbvar+4}.Role='vector_y'; 810 Data.VarAttribute{nbvar+5}.Role='warnflag'; 800 Data.VarAttribute{nbvar+5}.Role='ancillary'; 801 Data.VarAttribute{nbvar+6}.Role='errorflag'; 811 802 end 812 803 Data.Civ2_X=reshape(xtable,[],1); … … 815 806 Data.Civ2_V=reshape(-vtable,[],1); 816 807 Data.Civ2_C=reshape(ctable,[],1); 817 Data.Civ2_F =reshape(F,[],1);808 Data.Civ2_FF=reshape(F,[],1); 818 809 disp('civ2 performed') 819 810 time_civ2=toc(tstart_civ2); … … 847 838 Data.(Fix2_param{ilist})=Param.ActionInput.Fix2.(list_param{ilist}); 848 839 end 849 Data.ListGlobalAttribute=[Data.ListGlobalAttribute Fix2_param]; 850 if check_civx 851 if ~isfield(Data,'fix2') 852 Data.ListGlobalAttribute=[Data.ListGlobalAttribute 'fix2']; 853 Data.fix2=1; 854 Data.ListVarName=[Data.ListVarName {'vec2_FixFlag'}]; 855 Data.VarDimName=[Data.VarDimName {'nb_vectors2'}]; 856 end 857 Data.vec_FixFlag=detect_false(Param.Fix2,Data.vec2_F,Data.vec2_C,Data.vec2_U,Data.vec2_V); 858 else 859 Data.ListVarName=[Data.ListVarName {'Civ2_FF'}]; 860 Data.VarDimName=[Data.VarDimName {'nb_vec_2'}]; 861 nbvar=length(Data.ListVarName); 862 Data.VarAttribute{nbvar}.Role='errorflag'; 863 Data.Civ2_FF=double(detect_false(Param.ActionInput.Fix2,Data.Civ2_F,Data.Civ2_C,Data.Civ2_U,Data.Civ2_V)); 864 Data.CivStage=Data.CivStage+1; 865 end 840 Data.ListGlobalAttribute=[Data.ListGlobalAttribute Fix2_param]; 841 Data.Civ2_FF=double(detect_false(Param.ActionInput.Fix2,Data.Civ2_C,Data.Civ2_U,Data.Civ2_V,Data.Civ2_FF)); 842 Data.CivStage=Data.CivStage+1; 866 843 end 867 844 … … 1082 1059 if sizemask > 1/2% eliminate point if more than half of the correlation box is masked 1083 1060 F(ivec)=3; % 1084 utable(ivec)= 0;1085 vtable(ivec)= 0;1061 utable(ivec)=NaN; 1062 vtable(ivec)=NaN; 1086 1063 else 1087 1064 image1_crop=image1_crop.*~mask1_crop;% put to zero the masked pixels (mask1_crop='true'=1) … … 1103 1080 end 1104 1081 if F(ivec)==3 1105 utable(ivec)= 0;1106 vtable(ivec)= 0;1082 utable(ivec)=NaN; 1083 vtable(ivec)=NaN; 1107 1084 else 1108 1085 %mask … … 1197 1174 peaky = peaky+ (f1-f2)/(2*f1-4*f0+2*f2); 1198 1175 else 1199 F= -2; % warning flag for vector truncated by the limited search box1176 F=1; % warning flag for vector truncated by the limited search box 1200 1177 end 1201 1178 peakx=x; … … 1206 1183 peakx = peakx+ (f1-f2)/(2*f1-4*f0+2*f2); 1207 1184 else 1208 F= -2; % warning flag for vector truncated by the limited search box1185 F=1; % warning flag for vector truncated by the limited search box 1209 1186 end 1210 1187 vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1]; … … 1215 1192 %------------------------------------------------------------------------ 1216 1193 % vector=[0 0]; %default 1217 F= -2;1194 F=1; 1218 1195 peaky=y; 1219 1196 peakx=x; … … 1258 1235 [npy,npx]=size(result_conv); 1259 1236 if x<4 || y<4 || npx-x<4 ||npy-y <4 1260 F= -2;1237 F=1; 1261 1238 vector=[x y]; 1262 1239 else … … 1292 1269 1293 1270 1294 function FF=detect_false(Param, F,C,U,V)1295 FF= zeros(size(F));%default1296 % FF= -2, for correlation max at edge1297 % FF= -1, for too small correlation1298 % FF= 1, for velocity outside bounds1299 % FF= 2 for exclusion by difference with the smoothed field1300 FF(F==-2)=-2; 1271 function FF=detect_false(Param,C,U,V,FFIn) 1272 FF=FFIn;%default, good vectors 1273 % FF=1, for correlation max at edge, not set in this function 1274 % FF=2, for too small correlation 1275 % FF=3, for velocity outside bounds 1276 % FF=4 for exclusion by difference with the smoothed field, not set in this function 1277 1301 1278 if isfield (Param,'MinCorr') 1302 FF(C<Param.MinCorr )=-1;1279 FF(C<Param.MinCorr & FFIn==0)=2; 1303 1280 end 1304 1281 if (isfield(Param,'MinVel')&&~isempty(Param.MinVel))||(isfield (Param,'MaxVel')&&~isempty(Param.MaxVel)) … … 1306 1283 if isfield (Param,'MinVel')&&~isempty(Param.MinVel) 1307 1284 U2Min=Param.MinVel*Param.MinVel; 1308 FF(Umod<U2Min )=1;1285 FF(Umod<U2Min & FFIn==0)=3; 1309 1286 end 1310 1287 if isfield (Param,'MaxVel')&&~isempty(Param.MaxVel) 1311 1288 U2Max=Param.MaxVel*Param.MaxVel; 1312 FF(Umod>U2Max)=1; 1313 end 1314 end 1315 1316 1317 %criterium on warn flags 1318 % FlagName={'CheckFmin2','CheckF2','CheckF3','CheckF4'}; 1319 % FlagVal=[-2 2 3 4]; 1320 % for iflag=1:numel(FlagName) 1321 % if isfield(Param,FlagName{iflag}) && Param.(FlagName{iflag}) 1322 % FF=(FF==1| F==FlagVal(iflag)); 1323 % end 1324 % end 1325 % %criterium on correlation values 1326 % if isfield (Param,'MinCorr') 1327 % FF=FF==1 | C<Param.MinCorr; 1328 % end 1329 % if (isfield(Param,'MinVel')&&~isempty(Param.MinVel))||(isfield (Param,'MaxVel')&&~isempty(Param.MaxVel)) 1330 % Umod= U.*U+V.*V; 1331 % if isfield (Param,'MinVel')&&~isempty(Param.MinVel) 1332 % FF=FF==1 | Umod<(Param.MinVel*Param.MinVel); 1333 % end 1334 % if isfield (Param,'MaxVel')&&~isempty(Param.MaxVel) 1335 % FF=FF==1 | Umod>(Param.MaxVel*Param.MaxVel); 1336 % end 1337 % end 1338 1289 FF(Umod>U2Max & FFIn==0)=3; 1290 end 1291 end 1339 1292 1340 1293 %------------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.