Changeset 494 for trunk/src/civ.m
- Timestamp:
- Jul 19, 2012, 11:50:39 AM (12 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.