Changeset 951 for trunk/src/series
- Timestamp:
- Jun 12, 2016, 5:09:47 PM (9 years ago)
- Location:
- trunk/src/series
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/civ_input.m
r932 r951 97 97 FileType='image';%fdefault 98 98 FileInfo=[]; 99 if isfield(SeriesData,'FileType')&&isfield(SeriesData,'FileInfo') 99 if isfield(SeriesData,'FileType')&&isfield(SeriesData,'FileInfo')... 100 &&numel(SeriesData.FileType)>=1&&numel(SeriesData.FileInfo)>=1 100 101 FileType=SeriesData.FileType{1};%type of the first input file series 101 102 FileInfo=SeriesData.FileInfo{1};% info on the first input file series … … 214 215 CoordUnit='';%default 215 216 pxcm_search=1; 216 if isfield(SeriesData,'Time') && ~isempty(SeriesData.Time{1})217 if isfield(SeriesData,'Time') &&numel(SeriesData.Time')>=1 && ~isempty(SeriesData.Time{1}) 217 218 time=SeriesData.Time{1}; 218 219 end -
trunk/src/series/sub_background.m
r950 r951 150 150 end 151 151 152 prompt = {'volume scan mode (Yes/No)';'Number of images for the sliding background (MUST FIT IN COMPUTER MEMORY)';... 153 'the luminosity rank chosen to define the background (0.1=for dense particle seeding, 0.5 (median) for sparse particles'}; 152 prompt = {'volume scan mode (Yes/No)';... 153 'Number of images for the sliding background (MUST FIT IN COMPUTER MEMORY)';... 154 'the luminosity rank chosen to define the background (0.1=for dense particle seeding, 0.5 (median) for sparse particles';... 155 'set to 0 image levels below median(Yes/No)';... 156 'image rescaling coefficient(high values reduce the influence of bright particles), =0 for no rescaling' }; 154 157 dlg_title = 'get (slice by slice) a sliding background and substract to each image'; 155 num_lines= 3;156 def = { 'No';num2str(nbaver_init);'0.1' };158 num_lines= 5; 159 def = { 'No';num2str(nbaver_init);'0.1';'No';'2'}; 157 160 answer = inputdlg(prompt,dlg_title,num_lines,def); 158 161 if isempty(answer) … … 181 184 ParamOut.ActionInput.SlidingSequenceLength=nbaver_ima; 182 185 ParamOut.ActionInput.BrightnessRankThreshold=str2double(answer{3}); 183 186 ParamOut.ActionInput.CheckSubmedian=strcmp(answer{4},'Yes'); 187 ParamOut.ActionInput.SaturationCoeff=str2double(answer{5}); 184 188 % apply the image rescaling function 'level' (avoid the blinking effects of bright particles) 185 answer=msgbox_uvmat('INPUT_Y-N','apply image rescaling function levels.m after sub_background');186 ParamOut.ActionInput.CheckLevelTransform=strcmp(answer,'Yes');189 % answer=msgbox_uvmat('INPUT_Y-N','apply image rescaling function levels.m after sub_background'); 190 % ParamOut.ActionInput.CheckLevelTransform=strcmp(answer,'Yes'); 187 191 return 188 192 end … … 233 237 234 238 %% output file naming 235 FileExtOut='.png'; % write result as .png images for image inputs 236 if strcmp(lower(NomType{1}(end)),'a') 237 NomTypeOut=NomType{1};%case of letter appendix 239 FileExtOut='.png'; % write result as .png images for image inputsFileInfo.FileType='image' 240 if strcmp(FileInfo{1}.FileType,'image') 241 NomTypeOut=NomType{1}; 242 % if strcmp(lower(NomType{1}(end)),'a') 243 % NomTypeOut=NomType{1};%case of letter appendix 238 244 elseif isempty(j1_series{1}) 239 245 NomTypeOut='_1'; … … 338 344 339 345 %write result file 340 if Param.ActionInput.CheckLevelTransform341 C=levels(Acor );346 if ~isequal(Param.ActionInput.SaturationCoeff,0) 347 C=levels(Acor,Param.ActionInput.CheckSubmedian,Param.ActionInput.SaturationCoeff); 342 348 imwrite(C,newname,'BitDepth',16); % save the new image 343 349 else … … 391 397 newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1); 392 398 %write result file 393 if Param.ActionInput.CheckLevelTransform394 C=levels(Acor );399 if ~isequal(Param.ActionInput.SaturationCoeff,0) 400 C=levels(Acor,Param.ActionInput.CheckSubmedian,Param.ActionInput.SaturationCoeff); 395 401 imwrite(C,newname,'BitDepth',16); % save the new image 396 402 else … … 419 425 newname=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},FileExtOut,NomTypeOut,i1_series{1}(ifile),[],j1); 420 426 %write result file 421 if Param.ActionInput.CheckLevelTransform422 C=levels(Acor );427 if ~isequal(Param.ActionInput.SaturationCoeff,0) 428 C=levels(Acor,Param.ActionInput.CheckSubmedian,Param.ActionInput.SaturationCoeff); 423 429 imwrite(C,newname,'BitDepth',16); % save the new image 424 430 else … … 435 441 end 436 442 437 function C=levels(A )443 function C=levels(A,CheckSubmedian,Coeff) 438 444 439 445 nblock_y=100;%2*Param.TransformInput.BlockSize; … … 446 452 %Amin=A.*Aflagmin;%values of A at local minima 447 453 % local background: find all the local minima in image subblocks 448 fctblock= inline('median(x(:))'); 449 Backg=blkproc(A,[nblock_y nblock_x],fctblock);% take the median in blocks 454 if CheckSubmedian 455 fctblock= inline('median(x(:))'); 456 Backg=blkproc(A,[nblock_y nblock_x],fctblock);% take the median in blocks 457 %B=imresize(Backg,size(A),'bilinear');% interpolate to the initial size image 458 A=A-imresize(Backg,size(A),'bilinear');% substract background interpolated to the initial size image 459 end 450 460 fctblock= inline('mean(x(:))'); 451 B=imresize(Backg,size(A),'bilinear');% interpolate to the initial size image452 A=(A-B);%substract background453 461 AMean=blkproc(A,[nblock_y nblock_x],fctblock);% take the mean in blocks 454 462 fctblock= inline('var(x(:))'); 455 463 AVar=blkproc(A,[nblock_y nblock_x],fctblock);% take the mean in blocks 456 Avalue=AVar./AMean % typical value of particle luminosity464 Avalue=AVar./AMean;% typical value of particle luminosity 457 465 Avalue=imresize(Avalue,size(A),'bilinear');% interpolate to the initial size image 458 C=uint16(1000*tanh(A./(2*Avalue))); 459 %Bmin=blkproc(Aflagmin,[nblock_y nblock_x],sumblock);% find the number of minima in blocks 460 %Backg=Backg./Bmin; % find the average of minima in blocks 461 % function C=levels(A) 462 % %whos A; 463 % B=double(A(:,:,1)); 464 % windowsize=round(min(size(B,1),size(B,2))/20); 465 % windowsize=floor(windowsize/2)*2+1; 466 % ix=1/2-windowsize/2:-1/2+windowsize/2;% 467 % %del=np/3; 468 % %fct=exp(-(ix/del).^2); 469 % fct2=cos(ix/(windowsize-1)/2*pi/2); 470 % %Mfiltre=(ones(5,5)/5^2); 471 % %Mfiltre=fct2'; 472 % Mfiltre=fct2'*fct2; 473 % Mfiltre=Mfiltre/(sum(sum(Mfiltre))); 474 % 475 % C=filter2(Mfiltre,B); 476 % C(:,1:windowsize)=C(:,windowsize)*ones(1,windowsize); 477 % C(:,end-windowsize+1:end)=C(:,end-windowsize+1)*ones(1,windowsize); 478 % C(1:windowsize,:)=ones(windowsize,1)*C(windowsize,:); 479 % C(end-windowsize+1:end,:)=ones(windowsize,1)*C(end-windowsize,:); 480 % C=tanh(B./(2*C)); 481 % [n,c]=hist(reshape(C,1,[]),100); 482 % % figure;plot(c,n); 483 % 484 % [m,i]=max(n); 485 % c_max=c(i); 486 % [dummy,index]=sort(abs(c-c(i))); 487 % n=n(index); 488 % c=c(index); 489 % i_select = find(cumsum(n)<0.95*sum(n)); 490 % if isempty(i_select) 491 % i_select = 1:length(c); 492 % end 493 % c_select=c(i_select); 494 % n_select=n(i_select); 495 % cmin=min(c_select); 496 % cmax=max(c_select); 497 % C=(C-cmin)/(cmax-cmin)*256; 498 % C=uint8(C); 466 C=uint16(1000*tanh(A./(Coeff*Avalue)));
Note: See TracChangeset
for help on using the changeset viewer.