Changeset 616
- Timestamp:
- Apr 24, 2013, 2:54:33 PM (12 years ago)
- Location:
- trunk/src/series
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/aver_stat.m
r609 r616 69 69 end 70 70 71 72 ParamOut=Param; %default output 71 %% define the directory for result file 73 72 OutputDir=[Param.OutputSubDir Param.OutputDirExt]; 74 73 -
trunk/src/series/check_data_files.m
r594 r616 99 99 [tild,FileInfo]=get_file_type(filecell{iview,1}); 100 100 Tabchar{1}=filecell{iview,1};%info.Filename; 101 Tabchar{2}= FileInfo.FileModDate;102 Tabchar{3}=[num2str(FileInfo.Frame sPerSecond) ' frames/s '];103 Tabchar{4}=FileInfo.ImageType;104 Tabchar{5}=[' compression' FileInfo.VideoCompression];105 Tabchar{6}=[ 'quality ' num2str(FileInfo.Quality)];101 Tabchar{2}=''; 102 Tabchar{3}=[num2str(FileInfo.FrameRate) ' frames/s ']; 103 % Tabchar{4}=''; 104 % Tabchar{5}=[' compression' FileInfo.VideoCompression]; 105 % Tabchar{6}=[ 'quality ' num2str(FileInfo.Quality)]; 106 106 else 107 107 Tabchar={}; -
trunk/src/series/sub_background.m
r605 r616 10 10 % Organization of image indices: 11 11 % The program is working on a series of images, 12 % The processing can be done over groups of nbfield2 consecutive files in slices (parameter NbSlice)13 12 % In the mode 'volume', nbfield2=1 (1 image at each level)and NbSlice (=nbfield_j) 14 13 % Else nbfield2=nbfield_j =nbre of images in a burst (j index) … … 315 314 316 315 %MAIN LOOP ON SLICES 317 for islice=1:NbSlice 318 %% select the series of image indices at the level islice 319 indselect=islice:NbSlice*step:nbfield;% select file indices of the slice 320 for ifield=1:step-1 321 indselect=[indselect;indselect(end,:)+1]; 322 end 323 324 %% read the first series of nbaver_ima images and sort by luminosity at each pixel 325 for ifield = 1:nbaver_ima 326 ifile=indselect(ifield); 327 filename=filecell{1,ifile}; 328 Aread=read_image(filename,FileType{1},MovieObject{1},frame_index{1}(ifile)); 329 if ndims(Aread)==3;%color images 330 Aread=sum(double(Aread),3);% take the sum of color components 331 end 332 Ak(:,:,ifield)=Aread; 333 end 334 Asort=sort(Ak,3);%sort the luminosity of images at each point 335 B=Asort(:,:,rank);%background image 336 display( 'first background image will be substracted') 337 nbfirst=(ceil(nbaver/2))*step; 338 for ifield=1:nbfirst 339 Acor=double(Ak(:,:,ifield))-double(B);%substract background to the current image 340 Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor 341 ifile=indselect(ifield); 342 if ~isempty(j1_series{1}) 343 j1=j1_series{1}(ifile); 344 end 345 newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1); 346 347 %write result file 348 if Param.ActionInput.CheckLevelTransform 349 C=levels(Acor); 316 % for islice=1:NbSlice 317 %% select the series of image indices 318 indselect=1:step:nbfield;% select file indices of the slice 319 for ifield=1:step-1 320 indselect=[indselect;indselect(end,:)+1]; 321 end 322 323 %% read the first series of nbaver_ima images and sort by luminosity at each pixel 324 for ifield = 1:nbaver_ima 325 ifile=indselect(ifield); 326 filename=filecell{1,ifile}; 327 Aread=read_image(filename,FileType{1},MovieObject{1},frame_index{1}(ifile)); 328 if ndims(Aread)==3;%color images 329 Aread=sum(double(Aread),3);% take the sum of color components 330 end 331 Ak(:,:,ifield)=Aread; 332 end 333 Asort=sort(Ak,3);%sort the luminosity of images at each point 334 B=Asort(:,:,rank);%background image 335 display( 'first background image will be substracted') 336 nbfirst=(ceil(nbaver/2))*step; 337 for ifield=1:nbfirst 338 Acor=double(Ak(:,:,ifield))-double(B);%substract background to the current image 339 Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor 340 ifile=indselect(ifield); 341 if ~isempty(j1_series{1}) 342 j1=j1_series{1}(ifile); 343 end 344 newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1); 345 346 %write result file 347 if Param.ActionInput.CheckLevelTransform 348 C=levels(Acor); 349 imwrite(C,newname,'BitDepth',8); % save the new image 350 else 351 if isequal(FileInfo{1}.BitDepth,16) 352 C=uint16(Acor); 353 imwrite(C,newname,'BitDepth',16); % save the new image 354 else 355 C=uint8(Acor); 350 356 imwrite(C,newname,'BitDepth',8); % save the new image 357 end 358 end 359 display([newname ' written']) 360 end 361 362 %% repeat the operation on a sliding series of images 363 display('sliding background image will be substracted') 364 if nbfield_i > nbaver_ima 365 for ifield = step*ceil(nbaver/2)+1:step:nbfield_i-step*floor(nbaver/2) 366 if checkrun 367 stopstate=get(Param.RUNHandle,'BusyAction'); 368 update_waitbar(Param.WaitbarHandle,ifield/nbfield_i) 351 369 else 352 if isequal(FileInfo{1}.BitDepth,16) 353 C=uint16(Acor); 354 imwrite(C,newname,'BitDepth',16); % save the new image 355 else 356 C=uint8(Acor); 357 imwrite(C,newname,'BitDepth',8); % save the new image 370 stopstate='queue'; 371 end 372 if isequal(stopstate,'queue')% enable STOP command 373 Ak(:,:,1:nbaver_ima-step)=Ak(:,:,1+step:nbaver_ima);% shift the current image series by one burst (step) 374 %incorporate next burst in the current image series 375 for iburst=1:step 376 ifile=indselect(ifield+step*floor(nbaver/2)+iburst-1); 377 filename=fullfile_uvmat(RootPath{1},SubDir{1},RootFile{1},FileExt{1},NomType{1},i1_series{1}(ifile),[],j1_series{1}(ifile)); 378 Aread=read_image(filename,FileType{1},MovieObject{1},i1_series{1}(ifile)); 379 if ndims(Aread)==3;%color images 380 Aread=sum(double(Aread),3);% take the sum of color components 381 end 382 Ak(:,:,nbaver_ima-step+iburst)=Aread; 358 383 end 359 end 360 display([newname ' written']) 361 end 362 363 %% repeat the operation on a sliding series of images 364 display('sliding background image will be substracted') 365 if nbfield_i > nbaver_ima 366 for ifield = step*ceil(nbaver/2)+1:step:nbfield_i-step*floor(nbaver/2) 367 if checkrun 368 stopstate=get(Param.RUNHandle,'BusyAction'); 369 update_waitbar(Param.WaitbarHandle,(ifield+(islice-1)*nbfield_i)/(nbfield_i*NbSlice)) 370 else 371 stopstate='queue'; 384 Asort=sort(Ak,3);%sort the new current image series by luminosity 385 B=Asort(:,:,rank);%current background image 386 for iburst=1:step 387 index=step*floor(nbaver/2)+iburst; 388 Acor=double(Ak(:,:,index))-double(B); 389 Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor 390 ifile=indselect(ifield+iburst-1); 391 if ~isempty(j1_series{1}) 392 j1=j1_series{1}(ifile); 393 end 394 newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1); 395 %write result file 396 if Param.ActionInput.CheckLevelTransform 397 C=levels(Acor); 398 imwrite(C,newname,'BitDepth',8); % save the new image 399 else 400 if isequal(FileInfo{1}.BitDepth,16) 401 C=uint16(Acor); 402 imwrite(C,newname,'BitDepth',16); % save the new image 403 else 404 C=uint8(Acor); 405 imwrite(C,newname,'BitDepth',8); % save the new image 406 end 407 end 408 display([newname ' written']) 409 372 410 end 373 if isequal(stopstate,'queue')% enable STOP command 374 Ak(:,:,1:nbaver_ima-step)=Ak(:,:,1+step:nbaver_ima);% shift the current image series by one burst (step) 375 %incorporate next burst in the current image series 376 for iburst=1:step 377 ifile=indselect(ifield+step*floor(nbaver/2)+iburst-1); 378 filename=fullfile_uvmat(RootPath{1},SubDir{1},RootFile{1},FileExt{1},NomType{1},i1_series{1}(ifile),[],j1_series{1}(ifile)); 379 Aread=read_image(filename,FileType{1},MovieObject{1},i1_series{1}(ifile)); 380 if ndims(Aread)==3;%color images 381 Aread=sum(double(Aread),3);% take the sum of color components 382 end 383 Ak(:,:,nbaver_ima-step+iburst)=Aread; 384 end 385 Asort=sort(Ak,3);%sort the new current image series by luminosity 386 B=Asort(:,:,rank);%current background image 387 for iburst=1:step 388 index=step*floor(nbaver/2)+iburst; 389 Acor=double(Ak(:,:,index))-double(B); 390 Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor 391 ifile=indselect(ifield+iburst-1); 392 if ~isempty(j1_series{1}) 393 j1=j1_series{1}(ifile); 394 end 395 newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1); 396 %write result file 397 if Param.ActionInput.CheckLevelTransform 398 C=levels(Acor); 399 imwrite(C,newname,'BitDepth',8); % save the new image 400 else 401 if isequal(FileInfo{1}.BitDepth,16) 402 C=uint16(Acor); 403 imwrite(C,newname,'BitDepth',16); % save the new image 404 else 405 C=uint8(Acor); 406 imwrite(C,newname,'BitDepth',8); % save the new image 407 end 408 end 409 display([newname ' written']) 410 411 end 412 else 413 return 414 end 415 end 416 end 417 418 %% substract the background from the last images 419 display('last background image will be substracted') 420 ifield=nbfield_i-(step*ceil(nbaver/2))+1:nbfield_i; 421 for ifield=nbfield_i-(step*floor(nbaver/2))+1:nbfield_i 422 index=ifield-nbfield_i+step*(2*floor(nbaver/2)+1); 423 Acor=double(Ak(:,:,index))-double(B); 424 Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor 425 ifile=indselect(ifield); 426 if ~isempty(j1_series{1}) 427 j1=j1_series{1}(ifile); 428 end 429 newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1); 430 431 %write result file 432 if Param.ActionInput.CheckLevelTransform 433 C=levels(Acor); 411 else 412 return 413 end 414 end 415 end 416 417 %% substract the background from the last images 418 display('last background image will be substracted') 419 ifield=nbfield_i-(step*ceil(nbaver/2))+1:nbfield_i; 420 for ifield=nbfield_i-(step*floor(nbaver/2))+1:nbfield_i 421 index=ifield-nbfield_i+step*(2*floor(nbaver/2)+1); 422 Acor=double(Ak(:,:,index))-double(B); 423 Acor=(Acor>0).*Acor; % put to 0 the negative elements in Acor 424 ifile=indselect(ifield); 425 if ~isempty(j1_series{1}) 426 j1=j1_series{1}(ifile); 427 end 428 newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1); 429 430 %write result file 431 if Param.ActionInput.CheckLevelTransform 432 C=levels(Acor); 433 imwrite(C,newname,'BitDepth',8); % save the new image 434 else 435 if isequal(FileInfo{1}.BitDepth,16) 436 C=uint16(Acor); 437 imwrite(C,newname,'BitDepth',16); % save the new image 438 else 439 C=uint8(Acor); 434 440 imwrite(C,newname,'BitDepth',8); % save the new image 435 else 436 if isequal(FileInfo{1}.BitDepth,16) 437 C=uint16(Acor); 438 imwrite(C,newname,'BitDepth',16); % save the new image 439 else 440 C=uint8(Acor); 441 imwrite(C,newname,'BitDepth',8); % save the new image 442 end 443 end 444 display([newname ' written']) 445 end 446 end 441 end 442 end 443 display([newname ' written']) 444 end 445 447 446 448 447
Note: See TracChangeset
for help on using the changeset viewer.