 Timestamp:
 Jun 12, 2016, 5:09:47 PM (7 years ago)
 Location:
 trunk/src
 Files:

 4 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/series.m
r950 r951 990 990 Time=XmlData.Time; 991 991 TimeName='xml'; 992 if XmlData.Time(1,:)==XmlData.Time(2,:)% case starting with index 1993 sizDti=size(XmlData.Time,1)1;%size of the time vector explicitly defined in the xml file994 ind_start=1;995 else996 sizDti=size(XmlData.Time,1);% case starting with index 0997 ind_start=0;998 end999 % complement the input if the whole time series is not defined1000 if size(i1_series,3)>size(XmlData.Time,1)ind_start %only the first time interval is defined, extrapolate to the whole series1001 Dti_total=XmlData.Time(end)XmlData.Time(1);%total time interval covered by the time vector1002 missing_indices=sizDti+1+ind_start:size(i1_series,3)+1;% remaining set of frame indices for which time needs to be found1003 repeat_nbre=1+floor((missing_indicessizDtiind_start)/(sizDti1));% number of repetitions of Dti1004 time_indices=1+mod(missing_indicessizDti1,sizDti1);1005 for j=1:size(XmlData.Time,2)1006 Time(missing_indices,j)=XmlData.Time(time_indices,j)+repeat_nbre'*Dti_total;1007 end1008 % update the xml file with NbDti1009 t=xmltree(XmlFileName);1010 uid_NbDti=find(t,'ImaDoc/Camera/BurstTiming/NbDti')1011 if isempty(uid_NbDti)1012 uid_BurstTiming=find(t,'ImaDoc/Camera/BurstTiming')1013 [t,uid_NbDti]=add(t,uid_BurstTiming,'element','NbDti');1014 end1015 [t,uid_NbDti]=add(t,uid_NbDti,'chardata',num2str(repeat_nbre(end)1));1016 save(t,XmlFileName)1017 end992 % if XmlData.Time(1,:)==XmlData.Time(2,:)% case starting with index 1 993 % sizDti=size(XmlData.Time,1)1;%size of the time vector explicitly defined in the xml file 994 % ind_start=1; 995 % else 996 % sizDti=size(XmlData.Time,1);% case starting with index 0 997 % ind_start=0; 998 % end 999 % % complement the input if the whole time series is not defined 1000 % if size(i1_series,3)>size(XmlData.Time,1)ind_start %only the first time interval is defined, extrapolate to the whole series 1001 % Dti_total=XmlData.Time(end)XmlData.Time(1);%total time interval covered by the time vector 1002 % missing_indices=sizDti+1+ind_start:size(i1_series,3)+1;% remaining set of frame indices for which time needs to be found 1003 % repeat_nbre=1+floor((missing_indicessizDtiind_start)/(sizDti1));% number of repetitions of Dti 1004 % time_indices=1+mod(missing_indicessizDti1,sizDti1); 1005 % for j=1:size(XmlData.Time,2) 1006 % Time(missing_indices,j)=XmlData.Time(time_indices,j)+repeat_nbre'*Dti_total; 1007 % end 1008 % % update the xml file with NbDti 1009 % t=xmltree(XmlFileName); 1010 % uid_NbDti=find(t,'ImaDoc/Camera/BurstTiming/NbDti') 1011 % if isempty(uid_NbDti) 1012 % uid_BurstTiming=find(t,'ImaDoc/Camera/BurstTiming') 1013 % [t,uid_NbDti]=add(t,uid_BurstTiming,'element','NbDti'); 1014 % end 1015 % [t,uid_NbDti]=add(t,uid_NbDti,'chardata',num2str(repeat_nbre(end)1)); 1016 % save(t,XmlFileName) 1017 % end 1018 1018 end 1019 1019 if isfield(XmlData,'Camera') 
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_YN','apply image rescaling function levels.m after sub_background');186 ParamOut.ActionInput.CheckLevelTransform=strcmp(answer,'Yes');189 % answer=msgbox_uvmat('INPUT_YN','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=Aimresize(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=(AB);%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/2windowsize/2:1/2+windowsize/2;% 467 % %del=np/3; 468 % %fct=exp((ix/del).^2); 469 % fct2=cos(ix/(windowsize1)/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(:,endwindowsize+1:end)=C(:,endwindowsize+1)*ones(1,windowsize); 478 % C(1:windowsize,:)=ones(windowsize,1)*C(windowsize,:); 479 % C(endwindowsize+1:end,:)=ones(windowsize,1)*C(endwindowsize,:); 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(cc(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=(Ccmin)/(cmaxcmin)*256; 498 % C=uint8(C); 466 C=uint16(1000*tanh(A./(Coeff*Avalue))); 
trunk/src/uvmat.m
r950 r951 2039 2039 end 2040 2040 % complement the input if the whole time series is not defined 2041 if size(i1_series,3)>size(XmlDataRead.Time,1)ind_start %only the first time interval is defined, extrapolate to the whole series2042 Dti_total=XmlDataRead.Time(end)XmlDataRead.Time(1);%total time interval covered by the time vector2043 missing_indices=sizDti+1+ind_start:size(i1_series,3)+1;% remaining set of frame indices for which time needs to be found2044 repeat_nbre=1+floor((missing_indicessizDtiind_start)/(sizDti1));% number of repetitions of Dti2045 time_indices=1+mod(missing_indicessizDti1,sizDti1);2046 for j=1:size(XmlDataRead.Time,2)2047 XmlData.Time(missing_indices,j)=XmlDataRead.Time(time_indices,j)+repeat_nbre'*Dti_total;2048 end2049 % update the xml file with NbDti2050 t=xmltree(XmlFileName);2051 uid_NbDti=find(t,'ImaDoc/Camera/BurstTiming/NbDti')2052 if isempty(uid_NbDti)2053 uid_BurstTiming=find(t,'ImaDoc/Camera/BurstTiming')2054 [t,uid_NbDti]=add(t,uid_BurstTiming,'element','NbDti');2055 end2056 [t,uid_NbDti]=add(t,uid_NbDti,'chardata',num2str(repeat_nbre(end)1));2057 save(t,XmlFileName)2058 end2041 % if size(i1_series,3)>size(XmlDataRead.Time,1)ind_start %only the first time interval is defined, extrapolate to the whole series 2042 % Dti_total=XmlDataRead.Time(end)XmlDataRead.Time(1);%total time interval covered by the time vector 2043 % missing_indices=sizDti+1+ind_start:size(i1_series,3)+1;% remaining set of frame indices for which time needs to be found 2044 % repeat_nbre=1+floor((missing_indicessizDtiind_start)/(sizDti1));% number of repetitions of Dti 2045 % time_indices=1+mod(missing_indicessizDti1,sizDti1); 2046 % for j=1:size(XmlDataRead.Time,2) 2047 % XmlData.Time(missing_indices,j)=XmlDataRead.Time(time_indices,j)+repeat_nbre'*Dti_total; 2048 % end 2049 % % update the xml file with NbDti 2050 % t=xmltree(XmlFileName); 2051 % uid_NbDti=find(t,'ImaDoc/Camera/BurstTiming/NbDti') 2052 % if isempty(uid_NbDti) 2053 % uid_BurstTiming=find(t,'ImaDoc/Camera/BurstTiming') 2054 % [t,uid_NbDti]=add(t,uid_BurstTiming,'element','NbDti'); 2055 % end 2056 % [t,uid_NbDti]=add(t,uid_NbDti,'chardata',num2str(repeat_nbre(end)1)); 2057 % save(t,XmlFileName) 2058 % end 2059 2059 end 2060 2060 set(handles.view_xml,'BackgroundColor',[1 1 1])% paint back to white
Note: See TracChangeset
for help on using the changeset viewer.