Changeset 840 for trunk/src/series/extract_rdvision.m
- Timestamp:
- Dec 10, 2014, 11:11:09 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/extract_rdvision.m
r839 r840 78 78 check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files 79 79 ListDir=ListCells(1,find(check_dir & ~check_bad)); 80 InputTable=cell( numel(ListDir),5);81 InputTable(:,2)=ListDir';80 InputTable=cell(1,5); 81 % InputTable(:,2)=ListDir'; 82 82 isel=0; 83 83 for ilist=1:numel(ListDir) … … 91 91 isel=isel+1; 92 92 InputTable{isel,1}=RootPath; 93 InputTable{isel,2}=ListDir{ilist}; 93 94 RootFile=regexprep(ListCellSub{1,seq_index},'.seq$',''); 94 95 InputTable{isel,3}=RootFile; 95 end 96 InputTable{isel,4}='*'; 96 InputTable{isel,4}='*'; 97 97 InputTable{isel,5}='.seq'; 98 end 99 98 100 end 99 101 hseries=findobj(allchild(0),'Tag','series');% find the parent GUI 'series' … … 269 271 [success,message]=copyfile(filexml,[filexml '~']);%make backup 270 272 if success~=1 271 di ps(['errror in xml file backup: ' message]);273 displ(['errror in xml file backup: ' message]); 272 274 return 273 275 end … … 366 368 BitDepth=8*SeqData.bytesperpixel;%needed to write images (8 or 16 bits) 367 369 binrepertoire=fullfile(PathDir,SeqData.binrepertoire); 368 tic 369 OutputDir=fullfile(PathDir,SeqData.sequencename) 370 OutputDir=fullfile(PathDir,SeqData.sequencename); 370 371 if exist(OutputDir,'dir') 371 372 errormsg=[OutputDir ' already exist, delete it first']; … … 376 377 return%not able to create new image dir 377 378 end 379 fid=0; 378 380 for ii=1:SeqData.nb_frames 379 fname=fullfile(binrepertoire,sprintf('%s%.5d.bin',SeqData.binfile,SqbData(ii).file_idx)); 380 if ii==1 || ~strcmp(fname,fname_prev) % open the bin file if not in use 381 fid=fopen(fname,'rb'); 381 OutputFile=fullfile_uvmat(PathDir,SeqData.sequencename,'img','.png',NomTypeNew,i1,[],j1);% TODO: set NomTypeNew from SeqData.mode 382 if ~exist(OutputFile,'file') 383 fname=fullfile(binrepertoire,sprintf('%s%.5d.bin',SeqData.binfile,SqbData(ii).file_idx)); 384 if fid==0 || ~strcmp(fname,fname_prev) % open the bin file if not in use 385 if fid~=0 386 fclose(fid);%close the previous bin file 387 end 388 fid=fopen(fname,'rb'); 389 fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file 390 NbBinFile=NbBinFile+1;%counter of binary files (for checking purpose) 391 BinSize(NbBinFile)=0;% strat counter for new bin file 392 else 393 % 394 % fid=fopen(fname,'rb');% open the new bin file 395 % fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file 396 end 382 397 fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file 383 NbBinFile=NbBinFile+1;%counter of binary files (for checking purpose) 384 BinSize(NbBinFile)=0;% strat counter for new bin file 385 else 386 fclose(fid);%close the previous bin file 387 fid=fopen(fname,'rb');% open the new bin file 388 fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file 389 end 390 fname_prev=fname; 391 A=reshape(fread(fid,SeqData.width*SeqData.height,classname),SeqData.width,SeqData.height);%read the current image 392 A=A'; 393 BinSize(NbBinFile)=BinSize(NbBinFile)+SeqData.width*SeqData.height*SeqData.bytesperpixel*8; %record bits read 394 j1=[]; 395 if ~isequal(nbfield2,1) 396 j1=mod(ii-1,nbfield2)+1; 397 end 398 i1=floor((ii-1)/nbfield2)+1; 399 OutputFile=fullfile_uvmat(PathDir,SeqData.sequencename,'img','.png',NomTypeNew,i1,[],j1);% TODO: set NomTypeNew from SeqData.mode 400 try 401 imwrite(A,OutputFile,'BitDepth',BitDepth) % case of 16 bit images 402 disp([OutputFile ' written']); 403 [s,errormsg] = fileattrib(OutputFile,'-w','a'); %set images to read only '-w' for all users ('a') 404 if ~s 405 % disp_uvmat('ERROR',errormsg,checkrun); 398 fname_prev=fname; 399 A=reshape(fread(fid,SeqData.width*SeqData.height,classname),SeqData.width,SeqData.height);%read the current image 400 A=A'; 401 BinSize(NbBinFile)=BinSize(NbBinFile)+SeqData.width*SeqData.height*SeqData.bytesperpixel*8; %record bits read 402 j1=[]; 403 if ~isequal(nbfield2,1) 404 j1=mod(ii-1,nbfield2)+1; 405 end 406 i1=floor((ii-1)/nbfield2)+1; 407 408 try 409 imwrite(A,OutputFile,'BitDepth',BitDepth) % case of 16 bit images 410 disp([OutputFile ' written']); 411 % [s,errormsg] = fileattrib(OutputFile,'-w','a'); %set images to read only '-w' for all users ('a') 412 % if ~s 413 % % disp_uvmat('ERROR',errormsg,checkrun); 414 % return 415 % end 416 catch ME 417 errormsg=ME.message; 406 418 return 407 419 end 408 catch ME409 errormsg=ME.message;410 return411 420 end 412 421 end 413 422 fclose(fid) 414 toc 423 415 424 416 425
Note: See TracChangeset
for help on using the changeset viewer.