- Timestamp:
- Jul 19, 2012, 11:50:39 AM (12 years ago)
- Location:
- trunk/src
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r493 r494 24 24 %TODO: search range 25 25 26 % Last Modified by GUIDE v2.5 1 3-Jul-2012 15:11:0026 % Last Modified by GUIDE v2.5 18-Jul-2012 23:20:12 27 27 % Begin initialization code - DO NOT EDIT 28 28 gui_Singleton = 1; … … 297 297 set(handles.RootPath,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 298 298 RootPath=get(handles.RootPath,'String'); 299 Sub dirImages=get(handles.SubdirImages,'String');299 SubDirImages=get(handles.SubDirImages,'String'); 300 300 RootFile=get(handles.RootFile,'String'); 301 301 ref_i=str2num(get(handles.ref_i,'String')); … … 303 303 NomType=get(handles.NomType,'String'); 304 304 ImaExt=get(handles.ImaExt,'String'); 305 fileinput=fullfile_uvmat(RootPath,Sub dirImages,RootFile,ImaExt,NomType,ref_i,[],ref_j);305 fileinput=fullfile_uvmat(RootPath,SubDirImages,RootFile,ImaExt,NomType,ref_i,[],ref_j); 306 306 errormsg=display_file_name(handles,fileinput); 307 307 if ~isempty(errormsg) … … 344 344 if strcmp(ExtInput,'.nc') 345 345 NomTypeNc=NomTypeInput; 346 if isempty(regexp(NomTypeInput,'[ab|AB|-]' ))346 if isempty(regexp(NomTypeInput,'[ab|AB|-]', 'once')) 347 347 set(handles.ListCompareMode,'Value',2) %mode displacement advised if the nomencalture does not involve index pairs 348 348 % [RootPath,SubDir]=fileparts(RootPath); … … 435 435 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 436 436 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists 437 [RootPath,Sub dirImages,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,MovieObject]=find_file_series(FilePath,[FileName ImaExt]);437 [RootPath,SubDirImages,RootFile,i1_series,tild,j1_series,tild,NomTypeIma,FileType,MovieObject]=find_file_series(FilePath,[FileName ImaExt]); 438 438 switch FileType 439 439 case {'image','multimage','video','mmreader'} … … 443 443 end 444 444 set(handles.RootPath,'String',RootPath) 445 set(handles.Sub dirImages,'String',SubdirImages)445 set(handles.SubDirImages,'String',SubDirImages) 446 446 set(handles.RootFile,'String',RootFile) 447 447 if strcmp(ExtInput,'.nc') 448 SubDirCiv=regexprep(SubDir,['^' Sub dirImages],'');%suppress the root SuddirImages;448 SubDirCiv=regexprep(SubDir,['^' SubDirImages],'');%suppress the root SuddirImages; 449 449 else 450 450 SubDirCiv= '.civ'; … … 460 460 MaxIndex_i=max(i1_series(i1_series>0)); 461 461 MaxIndex_j=max(j1_series(j1_series>0)); 462 463 %% fill reference indices from the input file indices464 num_ref_i=str2num(get(handles.ref_i,'String'));465 num_ref_j=str2num(get(handles.ref_j,'String'));466 % for movies don't modify except if the current ref is outside index bounds467 if strcmp(ExtInput,'.nc')|| ~(strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader') && num_ref_i<=MaxIndex_i && num_ref_j<=MaxIndex_j)468 num_ref_i=i1;%default ref index469 if ~isempty(i2)470 num_ref_i=floor((num_ref_i+i2)/2);471 end472 num_ref_j=j1;473 if ~isempty(j2)474 num_ref_j=floor((num_ref_j+j2)/2);475 end476 end477 462 478 463 %% look for an image documentation file … … 524 509 end 525 510 if isempty(time) && (strcmp(FileType,'video') || strcmp(FileType,'mmreader')) 526 511 set(handles.ListPairMode,'Value',1); 527 512 dt=1/get(MovieObject,'FrameRate');%time interval between successive frames 528 513 if strcmp(NomTypeIma,'*') … … 533 518 set(handles.ListPairMode,'String',[{'series(Dj)'};{'series(Di)'}]) 534 519 MaxIndex_i=max(i1_series(i1_series>0)); 535 MaxIndex_j=get(MovieObject,'NumberOfFrames'); 520 MaxIndex_j=get(MovieObject,'NumberOfFrames'); 536 521 time=ones(MaxIndex_i,1)*(dt*(0:MaxIndex_j-1));%list of image times 537 522 enable_j(handles,'on') 538 end 523 end 539 524 TimeUnit='s'; 540 525 set(handles.ImaDoc,'BackgroundColor',[1 1 1])% set display box back to whiter … … 544 529 %show the reference image edit box if relevant (not needed for movies or in the absence of time information 545 530 if numel(time)>=2 % if there are at least two time values to define dt 546 MaxIndex_i=min(size(time,1),MaxIndex_i); 531 MaxIndex_i=min(size(time,1),MaxIndex_i);%possibly adjust the max index according to time data 547 532 MaxIndex_j=min(size(time,2),MaxIndex_j); 548 533 time=[zeros(size(time,1),1) time]; %insert a vertical line of zeros (to deal with zero file indices) … … 563 548 set(handles.ImaExt,'String',ImaExt) 564 549 set(handles.NomType,'String',NomTypeIma) 565 set(handles.ref_i,'String',num2str(num_ref_i)) 566 set(handles.ref_j,'String',num2str(num_ref_j)) 550 551 %% set the reference indices from the input file indices 552 num_ref_i=str2num(get(handles.ref_i,'String')); 553 num_ref_j=str2num(get(handles.ref_j,'String')); 554 % for movies don't modify except if the current ref is outside index bounds 555 %if strcmp(ExtInput,'.nc')|| ~(strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader') && num_ref_i<=MaxIndex_i && num_ref_j<=MaxIndex_j) 556 if ~isempty(i1)% if i1 has been selected by the input 557 num_ref_i=i1;%default ref index 558 if ~isempty(i2) 559 num_ref_i=floor((num_ref_i+i2)/2); 560 end 561 if ~isempty(j1) 562 num_ref_j=j1; 563 if ~isempty(j2) 564 num_ref_j=floor((num_ref_j+j2)/2); 565 end 566 end 567 end 568 if num_ref_i>MaxIndex_i||num_ref_i<MinIndex_i 569 num_ref_i=round((MinIndex_i+MaxIndex_i)/2); 570 end 571 if ~isempty(num_ref_j)&&~isempty(MaxIndex_j)&& ~isempty(MinIndex_j) 572 if (num_ref_j>MaxIndex_j||num_ref_j<MinIndex_j) 573 num_ref_j=round((MinIndex_j+MaxIndex_j)/2); 574 end 575 end 576 if isempty(num_ref_j) 577 num_ref_j=1; 578 end 567 579 568 580 %% update i and j index range if a nc file has been opened or pb withmin max image indices: … … 570 582 first_i=str2num(get(handles.first_i,'String')); 571 583 last_i=str2num(get(handles.last_i,'String')); 572 if isempty(first_i) || isempty(last_i)||isempty(MinIndex_i)||isempty(MaxIndex_i) 573 set(handles.first_i,'String',num2str(num_ref_i)); 574 set(handles.last_i,'String',num2str(num_ref_i));% 575 end 576 if ind_opening~=0 || isempty(first_i) || isempty(last_i)|| first_i<MinIndex_i || last_i>MaxIndex_i 577 set(handles.first_i,'String',num2str(num_ref_i)); 578 set(handles.last_i,'String',num2str(num_ref_i));% 584 if isempty(first_i) || isempty(last_i)||isempty(MinIndex_i)||isempty(MaxIndex_i)||ind_opening~=0 || isempty(first_i) || isempty(last_i)|| first_i<MinIndex_i || last_i>MaxIndex_i 585 first_i=num_ref_i; 586 last_i=num_ref_i; 587 set(handles.first_i,'String',num2str(first_i)); 588 set(handles.last_i,'String',num2str(last_i));% 579 589 end 580 590 581 591 %j index range 582 592 first_j=str2num(get(handles.first_j,'String')); 583 last_j=str2num(get(handles.last_i,'String')); 584 if isempty(first_j) || isempty(last_j)||isempty(MinIndex_j)||isempty(MaxIndex_j) 585 set(handles.first_j,'String',num2str(num_ref_j)); 586 set(handles.last_j,'String',num2str(num_ref_j));% 587 elseif ind_opening~=0 || first_j<MinIndex_j || last_j>MaxIndex_j 588 set(handles.first_j,'String',num2str(num_ref_j)); 589 set(handles.last_j,'String',num2str(num_ref_j));% 590 end 593 last_j=str2num(get(handles.last_j,'String')); 594 if isempty(first_j) || isempty(last_j)||isempty(MinIndex_j)||isempty(MaxIndex_j)||ind_opening~=0 || first_j<MinIndex_j || last_j>MaxIndex_j 595 first_j=num_ref_j; 596 last_j=num_ref_j; 597 set(handles.first_j,'String',num2str(first_j)); 598 set(handles.last_j,'String',num2str(last_j));% 599 end 600 if num_ref_i>last_i || num_ref_i<first_i 601 num_ref_i=round((first_i+last_i)/2); 602 end 603 if num_ref_j>last_j || num_ref_j<first_j 604 num_ref_j=round((first_j+last_j)/2); 605 end 606 set(handles.ref_i,'String',num2str(num_ref_i)) 607 set(handles.ref_j,'String',num2str(num_ref_j)) 591 608 592 609 %% set the civ options depending on the input file content when a nc file has been opened … … 1119 1136 for bin_name=binary_list %loop on the list of binaries 1120 1137 if isfield(Param.xml,bin_name{1})% bin_name{1} =current name in the list 1138 if ~isunix 1139 Param.xml.(bin_name{1})=[regexprep(Param.xml.(bin_name{1}),'/','\') '.exe']; 1140 end 1121 1141 if exist(Param.xml.(bin_name{1}),'file') 1122 1142 [path,name,ext]=fileparts(Param.xml.(bin_name{1})); … … 1146 1166 end 1147 1167 end 1148 display('files OK, processing...')1149 1168 1150 1169 %% set the list of files and check them … … 1160 1179 end 1161 1180 set(handles.civ,'UserData',filecell);%store for futur use of status callback 1162 1181 display('files OK, processing...') 1163 1182 1164 1183 %% create subfolders for log, cmx, nml, xml, bat … … 1171 1190 end 1172 1191 1173 1174 1192 %% get information on input images or movies 1175 1193 nbfield=numel(i1_civ1); … … 1191 1209 checkframe=strcmp(TimeUnit,'frame'); 1192 1210 batch_file_list=[];%should be renamed file_list, can be used for xml or bash files 1193 1211 NomTypeIma=get(handles.NomType,'String'); 1194 1212 for ifile=1:nbfield 1195 1213 for j=1:nbslice … … 1220 1238 Param.Civ1.ImageWidth=ImageInfoA_civ1.Width; 1221 1239 Param.Civ1.ImageHeight=ImageInfoA_civ1.Height; 1222 Param.Civ1.FrameIndexA=i1_civ1(ifile); 1223 Param.Civ1.FrameIndexB=i2_civ1(ifile); 1240 if strcmp(NomTypeIma,'*') 1241 Param.Civ1.FrameIndexA=i1_civ1(ifile); 1242 Param.Civ1.FrameIndexB=i2_civ1(ifile); 1243 else% case of movies indexed with i, the frame index is then in j 1244 Param.Civ1.FrameIndexA=j1_civ1(j); 1245 Param.Civ1.FrameIndexB=j2_civ1(j); 1246 end 1224 1247 % read mask )parameters 1225 1248 if Param.Civ1.CheckMask % the lines below should be changed with the new gui … … 1294 1317 Param.Civ2.ImageWidth=ImageInfoA_civ2.Width; 1295 1318 Param.Civ2.ImageHeight=ImageInfoA_civ2.Height; 1296 Param.Civ2.FrameIndexA=i1_civ2(ifile); 1297 Param.Civ2.FrameIndexB=i2_civ2(ifile); 1319 if strcmp(NomTypeIma,'*') 1320 Param.Civ2.FrameIndexA=i1_civ2(ifile,j); 1321 Param.Civ2.FrameIndexB=i2_civ2(ifile,j); 1322 else% case of movies indexed with i, the frame index is then in j 1323 Param.Civ2.FrameIndexA=j1_civ2(ifile,j); 1324 Param.Civ2.FrameIndexB=j2_civ2(ifile,j); 1325 end 1298 1326 end 1299 1327 … … 1680 1708 %% get the root name and check dir 1681 1709 RootPath=get(handles.RootPath,'String'); 1682 Sub dirImages=get(handles.SubdirImages,'String');1710 SubDirImages=get(handles.SubDirImages,'String'); 1683 1711 RootFile=get(handles.RootFile,'String'); 1684 filecell.filebase=fullfile(RootPath,Sub dirImages,RootFile);1712 filecell.filebase=fullfile(RootPath,SubDirImages,RootFile); 1685 1713 if isempty(filecell.filebase) 1686 1714 errormsg='please open an image with the upper menu option Open/Browse...'; … … 1703 1731 % subdir_civ2=[ '.' subdir_civ2]; 1704 1732 if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir 1705 subdir_civ1=[Sub dirImages '.' subdir_civ1];1706 subdir_civ2=[Sub dirImages '.' subdir_civ2];1733 subdir_civ1=[SubDirImages '.' subdir_civ1]; 1734 subdir_civ2=[SubDirImages '.' subdir_civ2]; 1707 1735 1708 1736 %% choose root names depending on ListCompareMode =displacement, shift, PIV or stereo PIV … … 1978 2006 for ifile=1:nbfield 1979 2007 for j=1:nbslice 1980 filename=fullfile_uvmat(RootPath,Sub dirImages,RootFile_ima1,ext_ima,NomType_ima1,i1_civ1(ifile),[],j1_civ1(j));2008 filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,ext_ima,NomType_ima1,i1_civ1(ifile),[],j1_civ1(j)); 1981 2009 idetect(j)=exist(filename,'file')==2; 1982 2010 filecell.ima1.civ1(ifile,j)={filename}; %first image 1983 filename=fullfile_uvmat(RootPath,Sub dirImages,RootFile_ima2,ext_ima,NomType_ima2,i2_civ1(ifile),[],j2_civ1(j));2011 filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,ext_ima,NomType_ima2,i2_civ1(ifile),[],j2_civ1(j)); 1984 2012 idetect_1(j)=exist(filename,'file')==2; 1985 2013 filecell.ima2.civ1(ifile,j)={filename};%second image … … 2196 2224 for ifile=1:nbfield 2197 2225 for j=1:nbslice 2198 filename=fullfile_uvmat(RootPath, [],RootFile_ima1,ext_ima,NomType_ima1,i1_civ2(ifile),[],j1_civ2(j));2226 filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,ext_ima,NomType_ima1,i1_civ2(ifile),[],j1_civ2(j)); 2199 2227 idetect_2(j)=exist(filename,'file')==2; 2200 2228 filecell.ima1.civ2(ifile,j)={filename};%first image … … 2214 2242 for ifile=1:nbfield 2215 2243 for j=1:nbslice 2216 filename=fullfile_uvmat(RootPath, [],RootFile_ima2,ext_ima,NomType_ima2,i2_civ2(ifile),[],j2_civ2(j));2244 filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,ext_ima,NomType_ima2,i2_civ2(ifile),[],j2_civ2(j)); 2217 2245 idetect_3(j)=exist(filename,'file')==2; 2218 2246 filecell.ima2.civ2(ifile,j)={filename};%first image … … 2271 2299 end 2272 2300 end 2273 set(handles.SubdirCiv1,'String',regexprep(subdir_civ1,['^' Sub dirImages],''));%suppress the root SuddirImages;);%update the edit box2274 set(handles.SubdirCiv2,'String',regexprep(subdir_civ2,['^' Sub dirImages],''));%update the edit box2301 set(handles.SubdirCiv1,'String',regexprep(subdir_civ1,['^' SubDirImages],''));%suppress the root SuddirImages;);%update the edit box 2302 set(handles.SubdirCiv2,'String',regexprep(subdir_civ2,['^' SubDirImages],''));%update the edit box 2275 2303 2276 2304 % For CivX COPY IMAGES TO THE FORMAT .png IF NEEDED 2277 2305 if strcmp(CivMode,'CivX') 2278 if isequal(NomType_ima1,'*')%case of movie files 2279 NomType_imanew1='_i'; 2280 else 2281 NomType_imanew1=NomType_ima1; 2282 end 2283 if isequal(NomType_ima2,'*')%case of movie files 2284 NomType_imanew2='_i'; 2285 else 2286 NomType_imanew2=NomType_ima2; 2287 end 2306 NomType_imanew1=NomType_ima1; 2307 NomType_imanew2=NomType_ima2; 2288 2308 if ~isequal(ext_ima,'.png') 2289 %%type of image file 2290 type_ima1='none';%default 2291 movieobject1=[];%default 2292 if strcmpi(ext_ima,'.avi') 2293 if ~isempty(which('mmreader'))% if the mmreader function is found (recent version of matlab) 2294 type_ima1='movie'; 2295 movieobject1=mmreader([filecell.filebase ext_ima]); 2296 else 2297 type_ima1='avi'; 2298 end 2299 elseif ischar(ext_ima) && ~isempty(ext_ima(2:end)) 2300 form=imformats(ext_ima(2:end)); 2301 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab 2302 if isequal(NomType_ima1,'*'); 2303 type_ima1='multimage';%image series in a single image file 2309 if checkbox(1) %if civ1 is performed 2310 [FileType,FileInfo,MovieObject]=get_file_type(filecell.ima1.civ1{1}); 2311 check_j=0; 2312 if strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader')||strcmp(FileType,'multimage') 2313 if max(j1_civ1)>1 2314 check_j=1; 2315 NomType_imanew1='_1_1'; 2304 2316 else 2305 type_ima1='image';2317 NomType_imanew1='_1'; 2306 2318 end 2307 2319 end 2308 end2309 type_ima2='none';%default2310 movieobject2=[];2311 if strcmpi(ext_ima,'.avi')2312 if ~isempty(which('mmreader'))% if the mmreader function is found (recent version of matlab)2313 type_ima2='movie';2314 movieobject2=mmreader([filecell.filebase ext_ima]);2315 else2316 type_ima2='avi';2317 end2318 elseif ischar(ext_ima) && ~isempty(ext_ima(2:end))2319 form=imformats(ext_ima(2:end));2320 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab2321 if isequal(NomType_ima1,'*');2322 type_ima2='multimage';%image series in a single image file2323 else2324 type_ima2='image';2325 end2326 end2327 end2328 if checkbox(1) %if civ1 is performed2329 2320 h = waitbar(0,'copy images to the .png format for civ1');% display a wait bar 2330 2321 for ifile=1:nbfield 2331 2322 waitbar(ifile/nbfield); 2332 2323 for j=1:nbslice 2333 filename=fullfile_uvmat(RootPath, [],RootFile_ima1,'.png',NomType_imanew1,i1_civ1(ifile),[],j1_civ1(j));2324 filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,'.png',NomType_imanew1,i1_civ1(ifile),[],j1_civ1(j)); 2334 2325 if ~exist(filename,'file') 2335 A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,i1_civ1(ifile),movieobject1); 2336 imwrite(A,filename,'BitDepth',16); 2326 if check_j 2327 A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j1_civ1(j)); 2328 else 2329 A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i1_civ1(ifile)); 2330 end 2331 imwrite(uint16(sum(A,3)),filename,'BitDepth',16); 2337 2332 end 2338 2333 filecell.ima1.civ1(ifile,j)={filename}; 2339 filename=fullfile_uvmat(RootPath, [],RootFile_ima2,'.png',NomType_imanew2,i2_civ1(ifile),[],j2_civ1(j));2334 filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,'.png',NomType_imanew1,i2_civ1(ifile),[],j2_civ1(j)); 2340 2335 if ~exist(filename,'file') 2341 A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,i2_civ1(ifile),movieobject2); 2342 imwrite(A,filename,'BitDepth',16); 2336 if check_j 2337 A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j2_civ1(j)); 2338 else 2339 A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i2_civ1(ifile)); 2340 end 2341 imwrite(uint16(sum(A,3)),filename,'BitDepth',16); 2343 2342 end 2344 2343 filecell.ima2.civ1(ifile,j)={filename}; … … 2348 2347 end 2349 2348 if checkbox(4) %if civ2 is performed 2349 [FileType,FileInfo,MovieObject]=get_file_type(filecell.ima1.civ2{1}); 2350 check_j=0; 2351 if strcmp(FileType,'mmreader')||strcmp(FileType,'VideoReader')||strcmp(FileType,'multimage') 2352 if max(j1_civ2)>1 2353 check_j=1; 2354 NomType_imanew1='_1_1'; 2355 else 2356 NomType_imanew1='_1'; 2357 end 2358 end 2350 2359 h = waitbar(0,'copy images to the .png format for civ2');% display a wait bar 2351 2360 for ifile=1:nbfield 2352 2361 waitbar(ifile/nbfield); 2353 2362 for j=1:nbslice 2354 filename=fullfile_uvmat(RootPath, [],RootFile_ima1,'.png',NomType_imanew1,i1_civ2(ifile),[],j1_civ2(j));2363 filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima1,'.png',NomType_imanew1,i1_civ2(ifile),[],j1_civ2(j)); 2355 2364 if ~exist(filename,'file') 2356 A=read_image(cell2mat(filecell.ima1.civ2(ifile,j)),type_ima2,i1_civ2(ifile)); 2357 imwrite(A,filename,'BitDepth',16); 2365 if check_j 2366 A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j1_civ2(j)); 2367 else 2368 A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i1_civ2(ifile)); 2369 end 2370 imwrite(uint16(sum(A,3)),filename,'BitDepth',16); 2358 2371 end 2359 2372 filecell.ima1.civ2(ifile,j)={filename}; 2360 filename=fullfile_uvmat(RootPath, [],RootFile_ima2,'.png',NomType_imanew2,i2_civ2(ifile),[],j2_civ2(j));2373 filename=fullfile_uvmat(RootPath,SubDirImages,RootFile_ima2,'.png',NomType_imanew2,i2_civ2(ifile),[],j2_civ2(j)); 2361 2374 if ~exist(filename,'file') 2362 A=read_image(cell2mat(filecell.ima2.civ2(ifile,j)),type_ima2,i2_civ2(ifile)); 2363 imwrite(A,filename,'BitDepth',16); 2375 if check_j 2376 A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,j1_civ2(j)); 2377 else 2378 A=read_image(filecell.ima1.civ1{ifile,j},FileType,MovieObject,i1_civ2(ifile)); 2379 end 2380 imwrite(uint16(sum(A,3)),filename,'BitDepth',16); 2364 2381 end 2365 2382 filecell.ima2.civ2(ifile,j)={filename}; … … 2373 2390 %------------------------------------------------------------------------ 2374 2391 % --- determine the list of index pairs of processing file 2375 function [ num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2]=...2392 function [i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2]=... 2376 2393 find_pair_indices(handles,ref_i,ref_j,mode) 2377 2394 %------------------------------------------------------------------------ … … 2394 2411 if isequal (mode,'series(Di)') 2395 2412 lastfield=str2double(get(handles.nb_field,'String')); 2396 num1_civ1=ref_i-floor(index_civ1/2)*ones(size(ref_i));% set of first image numbers2397 num2_civ1=ref_i+ceil(index_civ1/2)*ones(size(ref_i));2398 num_a_civ1=ref_j;2399 num_b_civ1=ref_j;2400 num1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i));2401 num2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i));2402 num_a_civ2=ref_j;2403 num_b_civ2=ref_j;2413 i1_civ1=ref_i-floor(index_civ1/2)*ones(size(ref_i));% set of first image numbers 2414 i2_civ1=ref_i+ceil(index_civ1/2)*ones(size(ref_i)); 2415 j1_civ1=ref_j; 2416 j2_civ1=ref_j; 2417 i1_civ2=ref_i-floor(index_civ2/2)*ones(size(ref_i)); 2418 i2_civ2=ref_i+ceil(index_civ2/2)*ones(size(ref_i)); 2419 j1_civ2=ref_j; 2420 j2_civ2=ref_j; 2404 2421 2405 2422 % adjust the first and last field number 2406 2423 lastfield=str2double(get(handles.nb_field,'String')); 2407 2424 if isnan(lastfield) 2408 indsel=find(( num1_civ1 >= 1)&(num1_civ2 >= 1));2425 indsel=find((i1_civ1 >= 1)&(i1_civ2 >= 1)); 2409 2426 else 2410 indsel=find(( num2_civ1 <= lastfield)&(num2_civ2 <= lastfield)&(num1_civ1 >= 1)&(num1_civ2 >= 1));2427 indsel=find((i2_civ1 <= lastfield)&(i2_civ2 <= lastfield)&(i1_civ1 >= 1)&(i1_civ2 >= 1)); 2411 2428 end 2412 2429 if length(indsel)>=1 … … 2416 2433 set(handles.last_i,'String',num2str(ref_i(lastind))) 2417 2434 ref_i=ref_i(indsel); 2418 num1_civ1=num1_civ1(indsel);2419 num1_civ2=num1_civ2(indsel);2420 num2_civ1=num2_civ1(indsel);2421 num2_civ2=num2_civ2(indsel);2435 i1_civ1=i1_civ1(indsel); 2436 i1_civ2=i1_civ2(indsel); 2437 i2_civ1=i2_civ1(indsel); 2438 i2_civ2=i2_civ2(indsel); 2422 2439 end 2423 2440 elseif isequal (mode,'series(Dj)') 2424 2441 lastfield_j=str2double(get(handles.nb_field2,'String')); 2425 num1_civ1=ref_i;% set of first image numbers2426 num2_civ1=ref_i;2427 num_a_civ1=ref_j-floor(index_civ1/2)*ones(size(ref_j));2428 num_b_civ1=ref_j+ceil(index_civ1/2)*ones(size(ref_j));2429 num1_civ2=ref_i;2430 num2_civ2=ref_i;2431 num_a_civ2=ref_j-floor(index_civ2/2)*ones(size(ref_j));2432 num_b_civ2=ref_j+ceil(index_civ2/2)*ones(size(ref_j));2442 i1_civ1=ref_i;% set of first image numbers 2443 i2_civ1=ref_i; 2444 j1_civ1=ref_j-floor(index_civ1/2)*ones(size(ref_j)); 2445 j2_civ1=ref_j+ceil(index_civ1/2)*ones(size(ref_j)); 2446 i1_civ2=ref_i; 2447 i2_civ2=ref_i; 2448 j1_civ2=ref_j-floor(index_civ2/2)*ones(size(ref_j)); 2449 j2_civ2=ref_j+ceil(index_civ2/2)*ones(size(ref_j)); 2433 2450 % adjust the first and last field number 2434 2451 if isnan(lastfield_j) 2435 indsel=find(( num_a_civ1 >= 1)&(num_a_civ2 >= 1));2452 indsel=find((j1_civ1 >= 1)&(j1_civ2 >= 1)); 2436 2453 else 2437 indsel=find(( num_b_civ1 <= lastfield_j)&(num_b_civ2 <= lastfield_j)&(num_a_civ1 >= 1)&(num_a_civ2 >= 1));2454 indsel=find((j2_civ1 <= lastfield_j)&(j2_civ2 <= lastfield_j)&(j1_civ1 >= 1)&(j1_civ2 >= 1)); 2438 2455 end 2439 2456 if length(indsel)>=1 … … 2443 2460 set(handles.last_j,'String',num2str(ref_j(lastind))) 2444 2461 ref_j=ref_j(indsel); 2445 num_a_civ1=num_a_civ1(indsel);2446 num_b_civ1=num_b_civ1(indsel);2447 num_a_civ2=num_a_civ2(indsel);2448 num_b_civ2=num_b_civ2(indsel);2462 j1_civ1=j1_civ1(indsel); 2463 j2_civ1=j2_civ1(indsel); 2464 j1_civ2=j1_civ2(indsel); 2465 j2_civ2=j2_civ2(indsel); 2449 2466 end 2450 2467 elseif isequal(mode,'pair j1-j2') %case of bursts (png_old or png_2D) 2451 2468 displ_num=get(handles.ListPairCiv1,'UserData'); 2452 num1_civ1=ref_i;2453 num2_civ1=ref_i;2454 num_a_civ1=displ_num(1,index_civ1);2455 num_b_civ1=displ_num(2,index_civ1);2456 num1_civ2=ref_i;2457 num2_civ2=ref_i;2458 num_a_civ2=displ_num(1,index_civ2);2459 num_b_civ2=displ_num(2,index_civ2);2469 i1_civ1=ref_i; 2470 i2_civ1=ref_i; 2471 j1_civ1=displ_num(1,index_civ1); 2472 j2_civ1=displ_num(2,index_civ1); 2473 i1_civ2=ref_i; 2474 i2_civ2=ref_i; 2475 j1_civ2=displ_num(1,index_civ2); 2476 j2_civ2=displ_num(2,index_civ2); 2460 2477 elseif isequal(mode,'displacement') 2461 num1_civ1=ref_i;2462 num2_civ1=ref_i;2463 num_a_civ1=ref_j;2464 num_b_civ1=ref_j;2465 num1_civ2=ref_i;2466 num2_civ2=ref_i;2467 num_a_civ2=ref_j;2468 num_b_civ2=ref_j;2478 i1_civ1=ref_i; 2479 i2_civ1=ref_i; 2480 j1_civ1=ref_j; 2481 j2_civ1=ref_j; 2482 i1_civ2=ref_i; 2483 i2_civ2=ref_i; 2484 j1_civ2=ref_j; 2485 j2_civ2=ref_j; 2469 2486 end 2470 2487 … … 2676 2693 index_pair=get(handles.ListPairCiv1,'Value'); 2677 2694 displ_num=get(handles.ListPairCiv1,'UserData'); 2678 % num_a=displ_num(1,index_pair);2679 % num_b=displ_num(2,index_pair);2680 2695 list_pair2=get(handles.ListPairCiv2,'String');%get the menu of image pairs 2681 2696 if index_pair<=length(list_pair2) … … 2816 2831 2817 2832 %% reads .nc subdirectoy and image numbers from the interface 2818 SubDirImages=get(handles.Sub dirImages,'String');2833 SubDirImages=get(handles.SubDirImages,'String'); 2819 2834 subdir_civ1=[SubDirImages get(handles.SubdirCiv1,'String')];%subdirectory subdir_civ1 for the netcdf data 2820 2835 subdir_civ2=[SubDirImages get(handles.SubdirCiv2,'String')];%subdirectory subdir_civ2 for the netcdf data 2821 2836 ref_i=str2double(get(handles.ref_i,'String')); 2837 ref_j=[]; 2822 2838 if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2') 2823 2839 ref_j=0; 2824 else 2840 elseif strcmp(get(handles.ref_j,'Visible'),'on') 2825 2841 ref_j=str2double(get(handles.ref_j,'String')); 2826 if isnan(ref_j) 2827 ref_j=1; 2828 end2842 end 2843 if isempty(ref_j) 2844 ref_j=1; 2829 2845 end 2830 2846 time=get(handles.ImaDoc,'UserData');%get the set of times … … 2875 2891 testpair=1; 2876 2892 else 2877 if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')2878 errormsg=['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1];2879 else2893 % if isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)') 2894 % errormsg=['no civ1 file available for the selected reference index j=' num2str(ref_j) ' and subdirectory ' subdir_civ1]; 2895 % else 2880 2896 errormsg=['no civ1 file available for the selected reference indices (i,j)= ' num2str(ref_i) ', ' num2str(ref_j) ' and subdirectory ' subdir_civ1]; 2881 end2897 % end 2882 2898 set(handles.ListPairCiv1,'String',{''}); 2883 2899 %COMPLETER CAS STEREO … … 3561 3577 ' -m ' nx_patch ' -n ' ny_patch ' -ro ' rho_patch ' -nopt ' subdomain_patch ' -c1 ' xmlA ' -c2 ' xmlB ' -xy x -Nfy 1024 > ' namelog ' 2>&1']; % redirect standard output to the log file 3562 3578 3563 % ------------------------------------------------------------------------3564 % --read images and convert them to the uint16 format used for PIV3565 function A=read_image(filename,type_ima,num,movieobject)3566 % ------------------------------------------------------------------------3567 % num is the view number needed for an avi movie3568 switch type_ima3569 case 'movie'3570 A=read(movieobject,num);3571 case 'avi'3572 mov=aviread(filename,num);3573 A=frame2im(mov(1));3574 case 'multimage'3575 A=imread(filename,num);3576 case 'image'3577 A=imread(filename);3578 end3579 siz=size(A);3580 if length(siz)==3;%color images3581 A=sum(double(A),3);3582 A=uint16(A);3583 end3579 % %------------------------------------------------------------------------ 3580 % %--read images and convert them to the uint16 format used for PIV 3581 % function A=read_image(filename,type_ima,num,movieobject) 3582 % %------------------------------------------------------------------------ 3583 % %num is the view number needed for an avi movie 3584 % switch type_ima 3585 % case 'movie' 3586 % A=read(movieobject,num); 3587 % case 'avi' 3588 % mov=aviread(filename,num); 3589 % A=frame2im(mov(1)); 3590 % case 'multimage' 3591 % A=imread(filename,num); 3592 % case 'image' 3593 % A=imread(filename); 3594 % end 3595 % siz=size(A); 3596 % if length(siz)==3;%color images 3597 % A=sum(double(A),3); 3598 % A=uint16(A); 3599 % end 3584 3600 3585 3601 … … 3859 3875 RootPath=get(handles.RootPath,'String'); 3860 3876 RootFile=get(handles.RootFile,'String'); 3877 SubDirImages=get(handles.SubDirImages,'String'); 3861 3878 ref_i=str2num(get(handles.ref_i,'String')); 3862 3879 ref_j=str2num(get(handles.ref_j,'String')); 3863 3880 NomType=get(handles.NomType,'String'); 3864 3881 ImaExt=get(handles.ImaExt,'String'); 3865 fileinput=fullfile_uvmat(RootPath, '',RootFile,ImaExt,NomType,ref_i,[],ref_j);3882 fileinput=fullfile_uvmat(RootPath,SubDirImages,RootFile,ImaExt,NomType,ref_i,[],ref_j); 3866 3883 errormsg=display_file_name(handles,fileinput); 3867 3884 if ~isempty(errormsg) … … 3957 3974 function RootFile_Callback(hObject, eventdata, handles) 3958 3975 3959 function Sub dirImages_Callback(hObject, eventdata, handles)3976 function SubDirImages_Callback(hObject, eventdata, handles) 3960 3977 3961 3978 … … 4147 4164 else %Windows system 4148 4165 filename=regexprep(filename,'\\','\\\\'); 4149 cmd=['copy /Y ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\0_CMX\\\\$2.civ1.cmx" ') regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.c iv1.cmx" \n')...4166 cmd=['copy /Y ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\0_CMX\\\\$2.civ1.cmx" ') regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" \n')... 4150 4167 '"' regexprep(Param.xml.Civ1Bin,'\\','\\\\') '" -f ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" > ')... 4151 4168 regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\0_LOG\\\\$2.civ1.log" \n')... % redirect standard output to the log file … … 4253 4270 'rm ' regexprep(filename,'(.+)/(.+$)','$1/$2.cmx \n')];%rename .cmx as .checkciv2.cmx, the result file is named [filename '.nc'] by CIVx 4254 4271 else 4272 filename=regexprep(Param.OutputFile,'.nc',''); 4255 4273 filename=regexprep(filename,'\\','\\\\'); 4256 4274 cmd=[cmd 'copy /Y ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\0_CMX\\\\$2.civ2.cmx" ') regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" \n')... 4257 '"' regexprep(Param.xml.Civ2Bin,'\\','\\\\') '" -f "' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" > ')...4275 '"' regexprep(Param.xml.Civ2Bin,'\\','\\\\') '" -f ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" > ')... 4258 4276 regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\0_LOG\\\\$2.civ2.log" \n')... % redirect standard output to the log file 4259 'del ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" \n')]; 4260 end 4277 'del ' regexprep(filename,'(.+)\\\\(.+$)','"$1\\\\$2.cmx" \n')]; 4278 end 4279 4261 4280 case 'CivAll' 4262 4281 CivAllCmd=[CivAllCmd ' civ2 ']; … … 4441 4460 4442 4461 4443 4444 4445 4462 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4446 4463 % USELESS FUNCTIONS BELOW HERE, TO CLEAN 4447 4464 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 4448 4449 4450 4451 4452 4465 4453 4466 %------------------------------------------------------------------------ … … 4546 4559 4547 4560 4548 4549 4561 function nb_field2_Callback(hObject, eventdata, handles) 4550 % hObject handle to nb_field2 (see GCBO)4551 % eventdata reserved - to be defined in a future version of MATLAB4552 % handles structure with handles and user data (see GUIDATA)4553 4554 % Hints: get(hObject,'String') returns contents of nb_field2 as text4555 % str2double(get(hObject,'String')) returns contents of nb_field2 as a double4556 4557 4562 4558 4563 4559 4564 function last_j_Callback(hObject, eventdata, handles) 4560 % hObject handle to last_j (see GCBO)4561 % eventdata reserved - to be defined in a future version of MATLAB4562 % handles structure with handles and user data (see GUIDATA)4563 4564 % Hints: get(hObject,'String') returns contents of last_j as text4565 % str2double(get(hObject,'String')) returns contents of last_j as a double4566 4567 4565 4568 4566 4569 4567 function last_i_Callback(hObject, eventdata, handles) 4570 % hObject handle to last_i (see GCBO) 4571 % eventdata reserved - to be defined in a future version of MATLAB 4572 % handles structure with handles and user data (see GUIDATA) 4573 4574 % Hints: get(hObject,'String') returns contents of last_i as text 4575 % str2double(get(hObject,'String')) returns contents of last_i as a double 4568 -
trunk/src/civ_matlab.m
r493 r494 88 88 %% Civ1 89 89 if isfield (Param,'Civ1') 90 % check_civ1=1;% test for further use of civ1 results91 % %% prepare images92 93 90 par_civ1=Param.Civ1; 94 if isfield(par_civ1,'reverse_pair') 91 if isfield(par_civ1,'reverse_pair')% A REVOIR 95 92 if par_civ1.reverse_pair 96 93 if ischar(par_civ1.ImageB) … … 103 100 end 104 101 else 105 if isfield(par_civ1,'ImageA')%&&... 106 % (ischar(par_civ1.ImageA)||strcmp(class(par_civ1.ImageA),'VideoReader')||strcmp(class(par_civ1.ImageA),'mmreader')) % case with no image: only the PIV grid is calculated 102 if isfield(Param.Civ1,'ImageA')%&&... 107 103 Param.Civ1.ImageA=regexprep(Param.Civ1.ImageA,'''','\'); 108 [par_civ1.ImageA,ParamOut] = read_image(Param.Civ1.ImageA,par_civ1.FileTypeA,par_civ1.ImageA,par_civ1.FrameIndexA); 109 % if ~isempty(errormsg) 110 % errormsg=['error in civ_matlab/read_field:' errormsg]; 111 % return 112 % end 113 %par_civ1.ImageA=Field.A;%= image matrix A in the first input field 114 end 115 if isfield(par_civ1,'ImageB')%&& ... 116 % (ischar(par_civ1.ImageB)||strcmp(class(par_civ1.ImageB),'VideoReader')||strcmp(class(par_civ1.ImageB),'mmreader')) 104 [par_civ1.ImageA,VideoObject] = read_image(Param.Civ1.ImageA,par_civ1.FileTypeA,[],par_civ1.FrameIndexA); 105 end 106 if isfield(Param.Civ1,'ImageB')%&& ... 117 107 Param.Civ1.ImageB=regexprep(Param.Civ1.ImageB,'''','\'); 118 [par_civ1.ImageB,ParamOut] = read_image(Param.Civ1.ImageB,par_civ1.FileTypeB,par_civ1.ImageB,par_civ1.FrameIndexB); 119 % if ~isempty(errormsg) 120 % errormsg=['error in civ_matlab/read_field:' errormsg]; 121 % return 122 % end 123 % par_civ1.ImageB=Field.A;%= image matrix A in the second input field 108 if strcmp(Param.Civ1.ImageA,Param.Civ1.ImageB)% use the same movie object 109 [par_civ1.ImageB,VideoObject] = read_image(Param.Civ1.ImageB,par_civ1.FileTypeB,VideoObject,par_civ1.FrameIndexB); 110 else 111 [par_civ1.ImageB,VideoObject] = read_image(Param.Civ1.ImageB,par_civ1.FileTypeB,par_civ1.ImageB,par_civ1.FrameIndexB); 112 end 124 113 end 125 114 end … … 239 228 [Data.Civ1_SubRange,Data.Civ1_NbSites,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=... 240 229 filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomain,Data.Patch1_Rho,Data.Patch1_Threshold); 241 fill=zeros(3,2,size(Data.Civ1_SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)242 Data.Civ1_Coord_tps=cat(1,Data.Civ1_Coord_tps,fill);230 % fill=zeros(3,2,size(Data.Civ1_SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage) 231 % Data.Civ1_Coord_tps=cat(1,Data.Civ1_Coord_tps,fill); 243 232 Data.Civ1_U_smooth(ind_good)=Ures; 244 233 Data.Civ1_V_smooth(ind_good)=Vres; … … 250 239 if isfield (Param,'Civ2') 251 240 par_civ2=Param.Civ2; 252 if ~isfield (Param,'Civ1') || ~strcmp(Param.Civ1.ImageA,par_civ2.ImageA) 253 %read first image if not already done for civ1 254 [Field,ParamOut,errormsg] = read_field(Param.Civ2.ImageA,par_civ2.FileTypeA,par_civ2.ImageA,par_civ2.FrameIndexA); 255 if ~isempty(errormsg) 256 errormsg=['error in civ_matlab/read_field:' errormsg]; 257 return 258 end 259 par_civ2.ImageA=Field.A; 260 else 261 par_civ2.ImageA=par_civ1.ImageA; 262 end 263 if ~isfield (Param,'Civ1') || ~strcmp(Param.Civ1.ImageB,par_civ2.ImageB) 264 %read first image if not already done for civ1 265 [Field,ParamOut,errormsg] = read_field(Param.Civ2.ImageB,par_civ2.FileTypeB,par_civ2.ImageB,par_civ2.FrameIndexB); 266 if ~isempty(errormsg) 267 errormsg=['error in civ_matlab/read_field:' errormsg]; 268 return 269 end 270 par_civ2.ImageB=Field.A; 271 else 272 par_civ2.ImageB=par_civ1.ImageB; 241 par_civ2.ImageA=[]; 242 par_civ2.ImageB=[]; 243 if isfield(Param.Civ2,'ImageA') && isfield(Param.Civ2,'ImageB') 244 Param.Civ2.ImageA=regexprep(Param.Civ2.ImageA,'''','\'); 245 Param.Civ2.ImageB=regexprep(Param.Civ2.ImageB,'''','\'); 246 if isfield (Param,'Civ1') 247 Param.Civ2.ImageA=regexprep(Param.Civ2.ImageA,'''','\'); 248 if strcmp(Param.Civ1.ImageA,Param.Civ2.ImageA) 249 if isequal(Param.Civ1.FrameIndexA,Param.Civ2.FrameIndexA) 250 par_civ2.ImageA=par_civ1.ImageA; 251 else % read another frame of the same movie object 252 par_civ2.ImageA = read_image(Param.Civ2.ImageA,Param.Civ2.FileTypeA,VideoObject,Param.Civ2.FrameIndexA); 253 end 254 end 255 Param.Civ2.ImageB=regexprep(Param.Civ2.ImageB,'''','\'); 256 if strcmp(Param.Civ1.ImageB,Param.Civ2.ImageB) 257 if isequal(Param.Civ1.FrameIndexB,Param.Civ2.FrameIndexB) 258 par_civ2.ImageB=par_civ1.ImageB; 259 else % read another frame of the same movie object 260 par_civ2.ImageB = read_image(Param.Civ2.ImageB,Param.Civ2.FileTypeB,VideoObject,Param.Civ2.FrameIndexB); 261 end 262 end 263 end 264 if isempty(par_civ2.ImageA) && isfield(Param.Civ2,'ImageA') 265 [par_civ2.ImageA,VideoObject] = read_image(Param.Civ2.ImageA,Param.Civ2.FileTypeA,[],Param.Civ2.FrameIndexA); 266 end 267 if isempty(par_civ2.ImageB)&& isfield(Param.Civ2,'ImageB') 268 if strcmp(Param.Civ2.ImageA,Param.Civ2.ImageB) 269 par_civ2.ImageB = read_image(Param.Civ2.ImageB,Param.Civ2.FileTypeB,VideoObject,Param.Civ2.FrameIndexB); 270 else 271 par_civ2.ImageB = read_image(Param.Civ2.ImageB,Param.Civ2.FileTypeB,[],Param.Civ2.FrameIndexB); 272 end 273 end 273 274 end 274 275 ibx2=ceil(par_civ2.CorrBoxSize(1)/2); … … 423 424 [Data.Civ2_SubRange,Data.Civ2_NbSites,Data.Civ2_Coord_tps,Data.Civ2_U_tps,Data.Civ2_V_tps,tild,Ures, Vres,tild,FFres]=... 424 425 filter_tps([Data.Civ2_X(ind_good) Data.Civ2_Y(ind_good)],Data.Civ2_U(ind_good),Data.Civ2_V(ind_good),[],Data.Patch2_SubDomain,Data.Patch2_Rho,Data.Patch2_Threshold); 425 fill=zeros(3,2,size(Data.Civ2_SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)426 Data.Civ2_Coord_tps=cat(1,Data.Civ2_Coord_tps,fill);426 % fill=zeros(3,2,size(Data.Civ2_SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage) 427 % Data.Civ2_Coord_tps=cat(1,Data.Civ2_Coord_tps,fill); 427 428 Data.Civ2_U_smooth(ind_good)=Ures; 428 429 Data.Civ2_V_smooth(ind_good)=Vres; … … 434 435 if exist('ncfile','var') 435 436 errormsg=struct2nc(ncfile,Data); 437 if isempty(errormsg) 438 disp([ncfile ' written']) 439 else 440 disp(errormsg) 441 end 436 442 end 437 443 -
trunk/src/filter_tps.m
r476 r494 10 10 % Coord_tps(NbSites,NbCoord,NbSubdomain): positions of the tps centres 11 11 % U_tps,V_tps: weight of the tps for each subdomain 12 % to get the interpolated field values, use the function calc_field.m 12 13 % 13 14 % INPUT: … … 123 124 U_smooth=U_smooth./nb_select; 124 125 V_smooth=V_smooth./nb_select; 126 fill=zeros(NbCoord+1,NbCoord,size(SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage) 127 Coord_tps=cat(1,Coord_tps,fill); 128 -
trunk/src/find_field_indices.m
r491 r494 258 258 CellVarType{icell}.nbsites_tps=VarType.nbsites_tps(ilist); 259 259 CellVarType{icell}.subrange_tps=VarType.subrange_tps(ilist); 260 if isfield(Data,'ListDimName') 261 dim_index=find(strcmp(tps_dimnames{2},Data.ListDimName)); 262 NbDim(icell)=Data.DimValue(dim_index); 263 else 260 264 NbDim(icell)=size(Data.(Data.ListVarName{VarType.coord_tps(ilist)}),2); 265 end 261 266 end 262 267 end -
trunk/src/find_file_series.m
r485 r494 216 216 else 217 217 [tild,ifile_min]=min(ref_ij(ind_select)); 218 [tild,tild,tild,tild,tild,tild,tild,tild,NomType]=fileparts_uvmat(dirpair(i file_min).name);% update the representation of indices (number of 0 before the number)218 [tild,tild,tild,tild,tild,tild,tild,tild,NomType]=fileparts_uvmat(dirpair(ind_select(ifile_min)).name);% update the representation of indices (number of 0 before the number) 219 219 NomType=regexprep(NomType,['^' NomTypePref],''); 220 220 end … … 238 238 NomType='*'; 239 239 else 240 j1_series=(1:FileInfo.NumberOfFrames)'; 240 i1_series=i1_series(:,2)*ones(1,FileInfo.NumberOfFrames); 241 i1_series=[i1_series(:,1) i1_series]; 242 j1_series=ones(size(i1_series,1),1)*(0:FileInfo.NumberOfFrames); 241 243 % include the first index in the root name 242 244 r=regexp(NomType,'^(?<tiretnum>_?\d+)','names');%look for a number or _1 at the beginning of NomType -
trunk/src/geometry_calib.m
r444 r494 91 91 %set the position of the interface 92 92 if exist('pos','var')&& length(pos)>=4 93 % %pos_gui=get(hObject,'Position');94 % pos_gui(1)=pos(1);95 % pos_gui(2)=pos(2);96 93 set(hObject,'Position',pos); 97 94 end … … 99 96 %set menu of calibration options 100 97 set(handles.calib_type,'String',{'rescale';'linear';'3D_linear';'3D_quadr';'3D_extrinsic'}) 101 % inputxml='';102 98 if exist('inputfile','var')&& ~isempty(inputfile) 103 99 struct.XmlInputFile=inputfile; 104 % [Pathsub,RootFile,field_count,str2,str_a,str_b,ext]=name2display(inputfile); 105 [RootPath,~,RootFile,~,~,~,~,FileExt]=fileparts_uvmat(inputfile); 100 [RootPath,SubDir,RootFile,tild,tild,tild,tild,FileExt]=fileparts_uvmat(inputfile); 106 101 if ~strcmp(FileExt,'.xml') 107 inputfile=[fullfile(RootPath,RootFile) '.xml'];%xml file corresponding to the input file 102 inputfile=fullfile(RootPath,[SubDir '.xml']);%xml file corresponding to the input file 103 if ~exist(inputfile,'file')% case of civ files , removes the extension for subdir 104 inputfile=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']); 105 if ~exist(inputfile,'file') 106 inputfile=[fullfile(RootPath,SubDir,RootFile) '.xml'];%old convention 107 if ~exist(inputfile,'file') 108 inputfile=''; 109 end 110 end 111 end 108 112 end 109 113 set(handles.ListCoord,'String',{'......'}) 110 114 if exist(inputfile,'file') 111 Heading=loadfile(handles,inputfile);% load the point coordi antes existing in the xml file115 Heading=loadfile(handles,inputfile);% load the point coordinates existing in the xml file 112 116 if isfield(Heading,'Campaign')&& ischar(Heading.Campaign) 113 117 struct.Campaign=Heading.Campaign; … … 190 194 GeometryCalib.ErrorRms(2)=sqrt(mean((Ypoints-y_ima).*(Ypoints-y_ima))); 191 195 [GeometryCalib.ErrorMax(2),index(2)]=max(abs(Ypoints-y_ima)); 192 [ ~,ind_dim]=max(GeometryCalib.ErrorMax);196 [tild,ind_dim]=max(GeometryCalib.ErrorMax); 193 197 index=index(ind_dim); 194 198 %set the Z position of the reference plane used for calibration … … 1257 1261 set(handles.ListCoord,'String',Tabchar) 1258 1262 1259 1260 % %------------------------------------------------------------------------1261 % % --- Executes on button press in rotation.1262 % function rotation_Callback(hObject, eventdata, handles)1263 % %------------------------------------------------------------------------1264 % angle_rot=(pi/180)*str2num(get(handles.Phi,'String'));1265 % Coord_cell=get(handles.ListCoord,'String');1266 % data=read_geometry_calib(Coord_cell);1267 % data.Coord(:,1)=cos(angle_rot)*data.Coord(:,1)+sin(angle_rot)*data.Coord(:,2);1268 % data.Coord(:,1)=-sin(angle_rot)*data.Coord(:,1)+cos(angle_rot)*data.Coord(:,2);1269 % set(handles.XObject,'String',num2str(data.Coord(:,1),4));1270 % set(handles.YObject,'String',num2str(data.Coord(:,2),4));1271 1272 1273 %------------------------------------------------------------------------1274 % image transform from px to phys1275 %INPUT:1276 %Zindex: index of plane1277 % function [A_out,Rangx,Rangy]=phys_Ima(A,Calib,ZIndex)1278 % %------------------------------------------------------------------------1279 % xcorner=[];1280 % ycorner=[];1281 % npx=[];1282 % npy=[];1283 % siz=size(A)1284 % npx=[npx siz(2)];1285 % npy=[npy siz(1)]1286 % xima=[0.5 siz(2)-0.5 0.5 siz(2)-0.5];%image coordinates of corners1287 % yima=[0.5 0.5 siz(1)-0.5 siz(1)-0.5];1288 % [xcorner,ycorner]=phys_XYZ(Calib,xima,yima,ZIndex);%corresponding physical coordinates1289 % Rangx(1)=min(xcorner);1290 % Rangx(2)=max(xcorner);1291 % Rangy(2)=min(ycorner);1292 % Rangy(1)=max(ycorner);1293 % test_multi=(max(npx)~=min(npx)) | (max(npy)~=min(npy));1294 % npx=max(npx);1295 % npy=max(npy);1296 % x=linspace(Rangx(1),Rangx(2),npx);1297 % y=linspace(Rangy(1),Rangy(2),npy);1298 % [X,Y]=meshgrid(x,y);%grid in physical coordiantes1299 % vec_B=[];1300 %1301 % zphys=0; %default1302 % if isfield(Calib,'SliceCoord') %.Z= index of plane1303 % SliceCoord=Calib.SliceCoord(ZIndex,:);1304 % zphys=SliceCoord(3); %to generalize for non-parallel planes1305 % end1306 % [XIMA,YIMA]=px_XYZ(Calib,X,Y,zphys);%corresponding image indices for each point in the real space grid1307 % XIMA=reshape(round(XIMA),1,npx*npy);%indices reorganized in 'line'1308 % YIMA=reshape(round(YIMA),1,npx*npy);1309 % flagin=XIMA>=1 & XIMA<=npx & YIMA >=1 & YIMA<=npy;%flagin=1 inside the original image1310 % testuint8=isa(A,'uint8');1311 % testuint16=isa(A,'uint16');1312 % if numel(siz)==2 %(B/W images)1313 % vec_A=reshape(A,1,npx*npy);%put the original image in line1314 % ind_in=find(flagin);1315 % ind_out=find(~flagin);1316 % ICOMB=((XIMA-1)*npy+(npy+1-YIMA));1317 % ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A1318 % vec_B(ind_in)=vec_A(ICOMB);1319 % vec_B(ind_out)=zeros(size(ind_out));1320 % A_out=reshape(vec_B,npy,npx);%new image in real coordinates1321 % elseif numel(siz)==31322 % for icolor=1:siz(3)1323 % vec_A=reshape(A{icell}(:,:,icolor),1,npx*npy);%put the original image in line1324 % ind_in=find(flagin);1325 % ind_out=find(~flagin);1326 % ICOMB=((XIMA-1)*npy+(npy+1-YIMA));1327 % ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A1328 % vec_B(ind_in)=vec_A(ICOMB);1329 % vec_B(ind_out)=zeros(size(ind_out));1330 % A_out(:,:,icolor)=reshape(vec_B,npy,npx);%new image in real coordinates1331 % end1332 % end1333 % if testuint81334 % A_out=uint8(A_out);1335 % end1336 % if testuint161337 % A_out=uint16(A_out);1338 % end1339 1340 %------------------------------------------------------------------------1341 % pointwise transform from px to phys1342 %INPUT:1343 %Z: index of plane1344 % function [Xphys,Yphys,Zphys]=phys_XYZ(Calib,X,Y,Z)1345 % %------------------------------------------------------------------------1346 % if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'SliceCoord')&length(Calib.SliceCoord)>=Z1347 % Zindex=Z;1348 % Zphys=Calib.SliceCoord(Zindex,3);%GENERALISER AUX CAS AVEC ANGLE1349 % else1350 % Zphys=0;1351 % end1352 % if ~exist('X','var')||~exist('Y','var')1353 % Xphys=[];1354 % Yphys=[];%default1355 % return1356 % end1357 % Xphys=X;%default1358 % Yphys=Y;1359 % %image transform1360 % if isfield(Calib,'R')1361 % R=(Calib.R)';1362 % Dx=R(5)*R(7)-R(4)*R(8);1363 % Dy=R(1)*R(8)-R(2)*R(7);1364 % D0=Calib.f*(R(2)*R(4)-R(1)*R(5));1365 % Z11=R(6)*R(8)-R(5)*R(9);1366 % Z12=R(2)*R(9)-R(3)*R(8);1367 % Z21=R(4)*R(9)-R(6)*R(7);1368 % Z22=R(3)*R(7)-R(1)*R(9);1369 % Zx0=R(3)*R(5)-R(2)*R(6);1370 % Zy0=R(1)*R(6)-R(3)*R(4);1371 % A11=R(8)*Calib.Ty-R(5)*Calib.Tz+Z11*Zphys;1372 % A12=R(2)*Calib.Tz-R(8)*Calib.Tx+Z12*Zphys;1373 % A21=-R(7)*Calib.Ty+R(4)*Calib.Tz+Z21*Zphys;1374 % A22=-R(1)*Calib.Tz+R(7)*Calib.Tx+Z11*Zphys;1375 % X0=Calib.f*(R(5)*Calib.Tx-R(2)*Calib.Ty+Zx0*Zphys);1376 % Y0=Calib.f*(-R(4)*Calib.Tx+R(1)*Calib.Ty+Zy0*Zphys);1377 % %px to camera:1378 % Xd=(Calib.dpx/Calib.sx)*(X-Calib.Cx); % sensor coordinates1379 % Yd=Calib.dpy*(Y-Calib.Cy);1380 % dist_fact=1+Calib.kappa1*(Xd.*Xd+Yd.*Yd); %distortion factor1381 % Xu=dist_fact.*Xd;%undistorted sensor coordinates1382 % Yu=dist_fact.*Yd;1383 % denom=Dx*Xu+Dy*Yu+D0;1384 % % denom2=denom.*denom;1385 % Xphys=(A11.*Xu+A12.*Yu+X0)./denom;%world coordinates1386 % Yphys=(A21.*Xu+A22.*Yu+Y0)./denom;1387 % end1388 1389 1390 1263 % -------------------------------------------------------------------- 1391 1264 function MenuImportPoints_Callback(hObject, eventdata, handles) -
trunk/src/get_field.m
r436 r494 110 110 if exist('filename','var') && ischar(filename) %transfer input file name in slave mode 111 111 set(handles.inputfile,'String',filename)% prefill the input file name 112 Field=nc2struct(filename,[]);% reads the whole field112 Field=nc2struct(filename,[]);% reads the field structure, without variables 113 113 if isfield(Field,'Txt') 114 114 msgbox_uvmat('ERROR',Field.Txt) 115 115 else 116 116 set(handles.get_field,'UserData',Field); 117 Field_input( eventdata,handles,Field);117 Field_input(handles,Field); 118 118 end 119 119 else %master mode … … 177 177 else 178 178 set(handles.get_field,'UserData',Field); 179 Field_input( eventdata,handles,Field);179 Field_input(handles,Field); 180 180 end 181 181 huvmat=findobj(allchild(0),'tag','uvmat'); … … 186 186 %------------------------------------------------------------------------ 187 187 % --- update the display when a new field is introduced. 188 function Field_input( eventdata,handles,Field)188 function Field_input(handles,Field) 189 189 %------------------------------------------------------------------------ 190 190 if isfield(Field,'ListDimName')&&~isempty(Field.ListDimName) … … 282 282 end 283 283 end 284 check_1Dplot_Callback(handles.check_1Dplot, eventdata, handles)285 check_scalar_Callback(handles.check_scalar, eventdata, handles)286 check_vector_Callback(handles.check_vector, eventdata, handles)284 check_1Dplot_Callback(handles.check_1Dplot, [], handles) 285 check_scalar_Callback(handles.check_scalar, [], handles) 286 check_vector_Callback(handles.check_vector, [], handles) 287 287 end 288 288 %scalar_Callback(handles.get_field, eventdata, handles) -
trunk/src/proj_field.m
r492 r494 1238 1238 ProjData.VarAttribute{ivar_new+1+nbcoord}.Role='errorflag'; 1239 1239 end 1240 % case 'filter'%interpolate data on a regular grid 1241 % errormsg='tps required for filter option' 1242 1240 1243 end 1241 1244 … … 2076 2079 eval(['ProjData.' AXName '=[Xbound(1) Xbound(2)];']) %record the new (projected ) x coordinates 2077 2080 end 2078 else % case with rotation and/or interpolation2081 elseif isfield(FieldData,'A') %TO GENERALISE % case with rotation and/or interpolation 2079 2082 if NbDim==2 %2D case 2080 2083 [X,Y]=meshgrid(coord_x_proj,coord_y_proj);%grid in the new coordinates … … 2104 2107 if test_filter 2105 2108 Aclass=class(FieldData.A); 2106 eval(['ProjData.' VarName '=filter2(Mfilter,FieldData.' VarName ',''valid'');'])2109 ProjData.(VarName)=filter2(Mfilter,FieldData.(VarName),'valid'); 2107 2110 if ~isequal(Aclass,'double') 2108 eval(['ProjData.' VarName '=' Aclass '(FieldData.' VarName ');'])%revert to integer values2111 ProjData.(VarName)=Aclass(FieldData.(VarName));%revert to integer values 2109 2112 end 2110 2113 end -
trunk/src/read_civdata.m
r492 r494 81 81 end 82 82 switch VelTypeOut 83 case{'civ1','civ-filter1','filter1'} 83 case{'civ1','filter1'} 84 if isfield(Field,'Patch1_SubDomain') 85 Field.SubDomain=Field.Patch1_SubDomain; 86 Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'SubDomain'}]; 87 end 84 88 Field.Dt=Field.Civ1_Dt; 85 case{'civ2','civ-filter2','filter2'} 89 Field.Time=Field.Civ1_Time; 90 case{'civ2','filter2'} 91 if isfield(Field,'Patch2_SubDomain') 92 Field.SubDomain=Field.Patch2_SubDomain; 93 Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'SubDomain'}]; 94 end 86 95 Field.Dt=Field.Civ2_Dt; 96 Field.Time=Field.Civ2_Time; 87 97 end 88 Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'Dt' }];98 Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'Dt','Time'}]; 89 99 var_ind=find(vardetect); 90 100 for ivar=1:numel(var_ind) … … 93 103 Field.VarAttribute{ivar}.Mesh=0.1;%typical mesh for histograms O.1 pixel 94 104 end 95 96 105 Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'NbCoord','NbDim','TimeUnit','CoordUnit'}]; 97 106 % %% update list of global attributes -
trunk/src/series.m
r490 r494 1776 1776 set(handles.TransformName,'Enable','on') 1777 1777 set(handles.FieldTransform,'Visible','on') 1778 TransformName_Callback([],[], handles) 1778 1779 end 1779 1780 case 'ProjObject' %hidden by default … … 2048 2049 %check the current ActionPath to the selected function 2049 2050 if ~isempty(list_transform{ind_coord}) 2050 func=functions(list_transform{ind_coord});2051 set(handles.TransformPath,'String',fileparts(func.file)); %show the path to the senlected function2052 else 2053 set(handles.TransformPath,'String',''); %show the path to the senlected function2051 func=functions(list_transform{ind_coord}); 2052 set(handles.TransformPath,'String',fileparts(func.file)); %show the path to the senlected function 2053 else 2054 set(handles.TransformPath,'String',''); %show the path to the senlected function 2054 2055 end 2055 2056 -
trunk/src/series/aver_stat.m
r478 r494 227 227 end 228 228 229 % field calculation (vort, div...) 229 %% check whether tps is needed, then calculate tps coefficients if needed 230 check_tps=0; 231 if ischar(Param.InputFields.FieldName) 232 Param.InputFields.FieldName={Param.InputFields.FieldName}; 233 end 234 for ilist=1:numel(Param.InputFields.FieldName) 235 switch Param.InputFields.FieldName{ilist} 236 case {'vort','div','strain'} 237 check_tps=1; 238 end 239 end 240 if strcmp(Param.ProjObject.ProjMode,'filter') 241 check_tps=1; 242 end 243 if check_tps 244 SubDomain=1500; %default, estimated nbre of vectors in a subdomain used for tps 245 if isfield(Data{iview},'SubDomain') 246 SubDomain=Data{iview}.SubDomain;% 247 end 248 [Data{iview}.SubRange,Data{iview}.NbSites,Data{iview}.Coord_tps,Data{iview}.U_tps,Data{iview}.V_tps,tild,U_smooth,V_smooth,W_smooth,FF] =... 249 filter_tps([Data{iview}.X(Data{iview}.FF==0) Data{iview}.Y(Data{iview}.FF==0)],Data{iview}.U(Data{iview}.FF==0),Data{iview}.V(Data{iview}.FF==0),[],SubDomain,0); 250 nbvar=numel(Data{iview}.ListVarName); 251 Data{iview}.ListVarName=[Data{iview}.ListVarName {'SubRange','NbSites','Coord_tps','U_tps','V_tps'}]; 252 Data{iview}.VarDimName=[Data{iview}.VarDimName {{'nb_coord','nb_bounds','nb_subdomain'},{'nb_subdomain'},... 253 {'nb_tps','nb_coord','nb_subdomain'},{'nb_tps','nb_subdomain'},{'nb_tps','nb_subdomain'}}]; 254 Data{iview}.VarAttribute{nbvar+3}.Role='coord_tps'; 255 Data{iview}.VarAttribute{nbvar+4}.Role='vector_x'; 256 Data{iview}.VarAttribute{nbvar+5}.Role='vector_y'; 257 if isfield(Data{iview},'ListDimName')%cleaning 258 Data{iview}=rmfield(Data{iview},'ListDimName'); 259 end 260 if isfield(Data{iview},'DimValue')%cleaning 261 Data{iview}=rmfield(Data{iview},'DimValue'); 262 end 263 end 264 265 % field calculation (vort, div...) 230 266 if strcmp(FileType{1},'civx')||strcmp(FileType{1},'civdata') 231 Data{1}=calc_field(InputFields{1}.FieldName,Data{1});%calculate field (vort..) 232 end 233 267 if isfield(Data{1},'Coord_tps') 268 Data{1}.FieldList=Param.InputFields.FieldName; 269 else 270 Data{1}=calc_field(Param.InputFields.FieldName,Data{1});%calculate field (vort..) 271 end 272 end 273 234 274 % field substration (for two input file series) 235 275 if length(Data)==2 236 if strcmp(FileType{2},'civx')||strcmp(FileType{2},'civ') 237 Data{2}=calc_field(InputFields{2}.FieldName,Data{2});%calculate field (vort..) 276 if strcmp(FileType{2},'civx')||strcmp(FileType{2},'civdata') 277 if isfield(Data{2},'Coord_tps') 278 Data{2}.FieldList=Param.InputFields.FieldName; 279 else 280 Data{2}=calc_field(Param.InputFields.FieldName,Data{2});%calculate field (vort..) 281 end 238 282 end 239 283 [Field,errormsg]=sub_field(Data{1},Data{2}); %substract the two fields -
trunk/src/series/merge_proj.m
r478 r494 193 193 for iview=1:nbview 194 194 % reading input file(s) 195 filecell{iview,index} 195 196 [Data{iview},tild,errormsg] = read_field(filecell{iview,index},FileType{iview},Param.InputFields,frame_index{iview}(index)); 196 197 if ~isempty(errormsg) … … 207 208 Data{iview}.ZIndex=mod(i1_series{iview}(index)-1,NbSlice_calib{iview})+1;%Zindex for phys transform 208 209 end 210 209 211 %transform the input field (e.g; phys) if requested 210 212 if ~isempty(transform_fct) 211 213 Data{iview}=transform_fct(Data{iview},XmlData{iview}); %transform to phys if requested 212 214 end 213 % field calculation (vort, div...) 215 216 %% check whether tps is needed, then calculate tps coefficients if needed 217 check_tps=0; 218 if ischar(Param.InputFields.FieldName) 219 Param.InputFields.FieldName={Param.InputFields.FieldName}; 220 end 221 for ilist=1:numel(Param.InputFields.FieldName) 222 switch Param.InputFields.FieldName{ilist} 223 case {'vort','div','strain'} 224 check_tps=1; 225 end 226 end 227 if strcmp(Param.ProjObject.ProjMode,'filter') 228 check_tps=1; 229 end 230 if check_tps 231 SubDomain=1500; %default, estimated nbre of vectors in a subdomain used for tps 232 if isfield(Data{iview},'SubDomain') 233 SubDomain=Data{iview}.SubDomain;% 234 end 235 [Data{iview}.SubRange,Data{iview}.NbSites,Data{iview}.Coord_tps,Data{iview}.U_tps,Data{iview}.V_tps,tild,U_smooth,V_smooth,W_smooth,FF] =... 236 filter_tps([Data{iview}.X(Data{iview}.FF==0) Data{iview}.Y(Data{iview}.FF==0)],Data{iview}.U(Data{iview}.FF==0),Data{iview}.V(Data{iview}.FF==0),[],SubDomain,0); 237 nbvar=numel(Data{iview}.ListVarName); 238 Data{iview}.ListVarName=[Data{iview}.ListVarName {'SubRange','NbSites','Coord_tps','U_tps','V_tps'}]; 239 Data{iview}.VarDimName=[Data{iview}.VarDimName {{'nb_coord','nb_bounds','nb_subdomain'},{'nb_subdomain'},... 240 {'nb_tps','nb_coord','nb_subdomain'},{'nb_tps','nb_subdomain'},{'nb_tps','nb_subdomain'}}]; 241 Data{iview}.VarAttribute{nbvar+3}.Role='coord_tps'; 242 Data{iview}.VarAttribute{nbvar+4}.Role='vector_x'; 243 Data{iview}.VarAttribute{nbvar+5}.Role='vector_y'; 244 if isfield(Data{iview},'ListDimName')%cleaning 245 Data{iview}=rmfield(Data{iview},'ListDimName'); 246 end 247 if isfield(Data{iview},'DimValue')%cleaning 248 Data{iview}=rmfield(Data{iview},'DimValue'); 249 end 250 end 251 252 % field calculation (vort, div...) 214 253 if strcmp(FileType{iview},'civx')||strcmp(FileType{iview},'civdata') 215 Data{iview}=calc_field(Param.InputFields.FieldName,Data{iview});%calculate field (vort..) 254 if isfield(Data{iview},'Coord_tps') 255 Data{iview}.FieldList=Param.InputFields.FieldName; 256 else 257 Data{iview}=calc_field(Param.InputFields.FieldName,Data{iview});%calculate field (vort..) 258 end 216 259 end 217 260 -
trunk/src/sub_field.m
r428 r494 301 301 end 302 302 if ~testX_1% if the second field has structured coordinates 303 ilist_1=find(strcmp(AName_1,Field_1.ListVarName)); 304 DimCell_1=Field_1.VarDimName{ilist_1}; 305 if numel(DimCell_1)>2 306 DimCell={XName_1_1,YName_1_1, [{YName_1_1,XName_1_1} DimCell_1(3:end)]}; 307 else 303 308 DimCell={XName_1_1,YName_1_1, {YName_1_1,XName_1_1}}; 309 end 304 310 else 305 311 DimCell=[DimCell Field_1.VarDimName(ivar_C_1)]; -
trunk/src/transform_field/phys.m
r433 r494 159 159 DataOut.V=(YOut_2-YOut_1)/Dt; 160 160 end 161 if ~strcmp(Calib.CalibrationType,'rescale') && isfield(Data,'X_tps') && isfield(Data,'Y_tps') 162 [DataOut.X_tps,DataOut.Y_tps]=phys_XYZ(Calib,Data.X,Data.Y,ZIndex); 163 end 164 end 161 % if ~strcmp(Calib.CalibrationType,'rescale') && isfield(Data,'X_tps') && isfield(Data,'Y_tps') 162 % [DataOut.X_tps,DataOut.Y_tps]=phys_XYZ(Calib,Data.X,Data.Y,ZIndex); 163 % end 164 end 165 166 %% suppress tps 167 list_tps={'Coord_tps' 'U_tps' 'V_tps' 'SubRange' 'NbSites'}; 168 ind_remove=[]; 169 for ilist=1:numel(list_tps) 170 ind_tps=find(strcmp(list_tps{ilist},Data.ListVarName)); 171 if ~isempty(ind_tps) 172 ind_remove=[ind_remove ind_tps]; 173 DataOut=rmfield(DataOut,list_tps{ilist}); 174 end 175 end 176 DataOut.ListVarName(ind_remove)=[]; 177 DataOut.VarDimName(ind_remove)=[]; 178 DataOut.VarAttribute(ind_remove)=[]; 179 180 165 181 166 182 %% transform of spatial derivatives: TODO check the case with plane angles -
trunk/src/uvmat.m
r491 r494 859 859 XmlData.Time=[];%default 860 860 XmlData.GeometryCalib=[];%default 861 TimeUnit=[];%default 861 TimeUnit='';%default 862 Time=[]; 862 863 testima=0; %test for image input 863 864 imainfo=[]; … … 870 871 % nbfield_j=1; 871 872 TimeUnit='s'; 872 XmlData.Time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames-1)/imainfo.FrameRate)'; 873 if isempty(j1_series); %frame index along i 874 Time=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)'; 875 else 876 Time=ones(size(i1_series,1),1)*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate); 877 end 873 878 %nbfield=imainfo.NumberOfFrames; 874 879 set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec … … 945 950 end 946 951 end 952 end 953 if ~(isfield(XmlData,'Time')&& ~isempty(XmlData.Time)) 954 XmlData.Time=Time; %time set by video 947 955 end 948 956 … … 1063 1071 if index==2 1064 1072 if get(handles.scan_j,'Value') 1065 scan_option='j'; %keep the scan option for the second fi elseries1073 scan_option='j'; %keep the scan option for the second file series 1066 1074 end 1067 1075 if strcmp(get(handles.j1,'Visible'),'on') … … 1069 1077 end 1070 1078 end 1079 [ref_i,ref_j]=find(i1_series); 1071 1080 if ~isempty(j1_series) 1072 1081 state_j='on'; 1073 if isequal(nbfield,1) &&index==1 1074 scan_option='j'; %scan j index by default if nbfield=1 1075 end 1082 if index==1 1083 if isequal(ref_i,ref_i(1)*ones(size(ref_j)))% if ref_i is always equal to its first vzlue 1084 scan_option='j'; %scan j indext 1085 end 1086 end 1076 1087 end 1077 1088 if isequal(scan_option,'i') 1089 diff_ref_i=diff(ref_i,1); 1090 if isempty(diff_ref_i) 1091 diff_ref_i=1; 1092 end 1093 if isequal (diff_ref_i,diff_ref_i(1)*ones(size(diff_ref_i))) 1094 set(handles.increment_scan,'String',num2str(diff_ref_i(1))) 1095 end 1078 1096 set(handles.scan_i,'Value',1) 1079 1097 scan_i_Callback([],[], handles); 1080 1098 else 1099 diff_ref_j=diff(ref_j); 1100 if isempty(diff_ref_j) 1101 diff_ref_j=1; 1102 end 1103 if isequal (diff_ref_j,diff_ref_j(1)*ones(size(diff_ref_j))) 1104 set(handles.increment_scan,'String',num2str(diff_ref_j(1))) 1105 end 1081 1106 set(handles.scan_j,'Value',1) 1082 1107 scan_j_Callback([],[], handles); … … 1246 1271 option=get(handles.view_xml,'String'); 1247 1272 if isequal(option,'view .xml') 1248 FileXml=[FileBase '.xml']; 1273 FileXml=fullfile(RootPath,[SubDir '.xml']); 1274 if ~exist(FileXml,'file')% case of civ files , removes the extension for subdir 1275 FileXml=fullfile(RootPath,[regexprep(SubDir,'\..+$','') '.xml']); 1276 end 1249 1277 heditxml=editxml(FileXml); 1250 1278 end … … 1256 1284 %case of view mask selection 1257 1285 if isequal(get(handles.CheckMask,'Value'),1) 1258 % [FF,RootPath,FileBase]=read_file_boxes(handles);1259 1286 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles); 1260 1287 FileBase=fullfile(RootPath,RootFile); … … 1270 1297 maskname=maskfiles(ilist).name;% take the first mask file in the list 1271 1298 [tild,tild,tild,tild,tild,tild,tild,MaskExt,Mask_NomType{ilist}]=fileparts_uvmat(maskname); 1272 % [rr,ff,x1,x2,xa,xb,xext,Mask_NomType{ilist}]=name2display(maskname);1273 1299 [tild,Name]=fileparts(maskname); 1274 1300 Namedouble=double(Name); … … 1955 1981 end 1956 1982 NomType=get(handles.NomType,'String'); 1983 NomType_1=''; 1984 if strcmp(get(handles.NomType_1,'Visible'),'on') 1985 NomType_1=get(handles.NomType_1,'String'); 1986 end 1957 1987 % NomType=get(handles.FileIndex,'UserData'); 1958 1988 %update the z position index … … 2110 2140 ParamOut_1=UvData.ParamOut_1; 2111 2141 else 2142 if isstruct(ParamIn_1) 2112 2143 ParamIn_1.FieldName=FieldName_1; 2113 2144 ParamIn_1.VelType=VelType_1; 2114 2145 ParamIn_1.GUIName='get_field_1'; 2146 end 2115 2147 [Field{2},ParamOut_1,errormsg] = read_field(Name,UvData.FileType{2},ParamIn_1,frame_index_1); 2116 2148 if ~isempty(errormsg) … … 2174 2206 test_veltype_1=1; 2175 2207 set(handles.VelType_1,'Visible','on') 2176 % if ~get(handles.FixVelType,'Value') 2177 menu=set_veltype_display(ParamOut_1.CivStage); 2178 index_menu=strcmp(ParamOut_1.VelType,menu); 2179 set(handles.VelType_1,'Value',1+find(index_menu,1)) 2180 set(handles.VelType_1,'String',[{''};menu]) 2181 % end 2208 menu=set_veltype_display(ParamOut_1.CivStage); 2209 index_menu=strcmp(ParamOut_1.VelType,menu); 2210 set(handles.VelType_1,'Value',1+find(index_menu,1)) 2211 set(handles.VelType_1,'String',[{''};menu]) 2182 2212 end 2183 2213 % update the second field menu: the same quantity 2214 if isstruct(ParamOut_1) 2184 2215 set(handles.Fields_1,'String',[{''};ParamOut_1.FieldList]); %update the field menu 2185 2216 % display the Fields menu from the input file and pick the selected one: 2186 2217 field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList); 2187 2218 set(handles.Fields_1,'Value',find(field_index,1)+1) 2188 % % synchronise with the first menu if the first selection is not 'velocity' 2189 % if ~strcmp(ParamOut.FieldName,'velocity') 2190 % field_index=strcmp(ParamOut_1.FieldName,ParamOut_1.FieldList); 2191 % set(handles.Fields_1,'Value',field_index); %update the field menu 2192 % ParamOut_1.FieldName=ParamOut.FieldName; 2193 % set(handles.Fields_1,'String',ParamOut_1.FieldList) 2194 % end 2219 end 2220 2195 2221 end 2196 2222 if test_veltype||test_veltype_1 … … 2337 2363 Field{1}=transform(Field{1},XmlData); 2338 2364 end 2339 %% update tps in phys coordinates if needed 2340 if (strcmp(VelType,'filter1')||strcmp(VelType,'filter2'))&& strcmp(UvData.FileType{1},'civdata')&&isfield(Field{1},'U')&& isfield(Field{1},'V') 2341 Field{1}.X=Field{1}.X(Field{1}.FF==0); 2342 Field{1}.Y=Field{1}.Y(Field{1}.FF==0); 2343 Field{1}.U=Field{1}.U(Field{1}.FF==0); 2344 Field{1}.V=Field{1}.V(Field{1}.FF==0); 2345 [Field{1}.SubRange,Field{1}.NbSites,Field{1}.Coord_tps,Field{1}.U_tps,Field{1}.V_tps]=filter_tps([Field{1}.X Field{1}.Y],Field{1}.U,Field{1}.V,[],Field{1}.Patch1_SubDomain,0); 2346 end 2347 if numel(Field)==2 && ~test_keepdata_1 && isequal(UvData.FileType{2}(1:3),'civ') && ~isequal(ParamOut_1.FieldName,'get_field...')%&&~isempty(FieldName_1) 2348 %update tps in phys coordinates if needed 2349 if (strcmp(VelType_1,'filter1')||strcmp(VelType_1,'filter2'))&& strcmp(UvData.FileType{2},'civdata')&&isfield(Field{2},'U')&& isfield(Field{2},'V') 2350 Field{2}.X=Field{2}.X(Field{2}.FF==0); 2351 Field{2}.Y=Field{1}.Y(Field{2}.FF==0); 2352 Field{2}.U=Field{1}.U(Field{2}.FF==0); 2353 Field{2}.V=Field{1}.V(Field{2}.FF==0); 2354 [Field{2}.SubRange,Field{2}.NbSites,Field{2}.Coord_tps,Field{2}.U_tps,Field{2}.V_tps]=filter_tps([Field{2}.X Field{2}.Y],Field{2}.U,Field{2}.V,[],1500,0); 2365 2366 %% check whether tps is needed, then calculate tps coefficients if needed 2367 check_tps=0; 2368 if strcmp(UvData.FileType{1},'civdata')|| strcmp(UvData.FileType{1},'civx') 2369 switch ParamOut.FieldName 2370 case {'vort','div','strain'} 2371 check_tps=1; 2372 otherwise 2373 check_tps=0; 2374 if isfield(UvData,'Object') 2375 for iobj=1:numel(UvData.Object) 2376 UvData.Object{iobj} 2377 if isfield(UvData.Object{iobj},'ProjMode')&& strcmp(UvData.Object{iobj}.ProjMode,'filter') 2378 check_tps=1; 2379 break 2380 end 2381 end 2382 end 2383 end 2384 end 2385 if check_tps 2386 SubDomain=1500; %default, estimated nbre of vectors in a subdomain used for tps 2387 if isfield(Field{1},'SubDomain') 2388 SubDomain=Field{1}.SubDomain;% 2389 end 2390 [Field{1}.SubRange,Field{1}.NbSites,Field{1}.Coord_tps,Field{1}.U_tps,Field{1}.V_tps,tild,U_smooth,V_smooth,W_smooth,FF] =... 2391 filter_tps([Field{1}.X(Field{1}.FF==0) Field{1}.Y(Field{1}.FF==0)],Field{1}.U(Field{1}.FF==0),Field{1}.V(Field{1}.FF==0),[],SubDomain,0); 2392 nbvar=numel(Field{1}.ListVarName); 2393 Field{1}.ListVarName=[Field{1}.ListVarName {'SubRange','NbSites','Coord_tps','U_tps','V_tps'}]; 2394 Field{1}.VarDimName=[Field{1}.VarDimName {{'nb_coord','nb_bounds','nb_subdomain'},{'nb_subdomain'},... 2395 {'nb_tps','nb_coord','nb_subdomain'},{'nb_tps','nb_subdomain'},{'nb_tps','nb_subdomain'}}]; 2396 Field{1}.VarAttribute{nbvar+3}.Role='coord_tps'; 2397 Field{1}.VarAttribute{nbvar+4}.Role='vector_x'; 2398 Field{1}.VarAttribute{nbvar+5}.Role='vector_y'; 2399 if isfield(Field{1},'ListDimName')%cleaning 2400 Field{1}=rmfield(Field{1},'ListDimName'); 2401 end 2402 if isfield(Field{1},'DimValue')%cleaning 2403 Field{1}=rmfield(Field{1},'DimValue'); 2355 2404 end 2356 2405 end … … 3095 3144 [tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]); 3096 3145 if isequal(field,'image') 3097 SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' 3098 imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]); 3146 if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file 3147 imagename=UvData.Field.Civ2_ImageA; 3148 elseif isfield(UvData.Field,'Civ1_ImageA')% 3149 imagename=UvData.Field.Civ1_ImageA; 3150 else 3151 SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.' 3152 imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]); 3153 end 3099 3154 if ~exist(imagename,'file') 3100 3155 [FileName,PathName] = uigetfile( ... … … 3199 3254 end 3200 3255 case 'image' 3201 % guess the image name corresponding to the current netcdf name (no unique correspondance) 3202 SubDirBase=regexprep(SubDir_1,'\..*','');%take the root part of SubDir, before the first dot '.' 3203 imagename=fullfile_uvmat(RootPath_1,SubDirBase,RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1); 3256 % get the image name corresponding to the current netcdf name (no unique correspondance) 3257 if isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file 3258 imagename=UvData.Field.Civ2_ImageA; 3259 elseif isfield(UvData.Field,'Civ1_ImageA')% 3260 imagename=UvData.Field.Civ1_ImageA; 3261 else 3262 SubDirBase=regexprep(SubDir_1,'\..*','');%take the root part of SubDir, before the first dot '.' 3263 imagename=fullfile_uvmat(RootPath_1,SubDirBase,RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1); 3264 end 3204 3265 if ~exist(imagename,'file') % browse for images if it is not found 3205 3266 [FileName,PathName] = uigetfile( ...
Note: See TracChangeset
for help on using the changeset viewer.