Changeset 950 for trunk/src/series
 Timestamp:
 Jun 11, 2016, 9:32:29 PM (8 years ago)
 Location:
 trunk/src/series
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/series/civ_series.m
r949 r950 283 283 if iview_A~=0 284 284 XmlFileName=find_imadoc(RootPath_A,SubDir_A,RootFile_A,FileExt_A); 285 time=[];285 Time=[]; 286 286 if ~isempty(XmlFileName) 287 287 XmlData=imadoc2struct(XmlFileName); 288 288 if isfield(XmlData,'Time') 289 time=XmlData.Time;289 Time=XmlData.Time; 290 290 TimeSource='xml'; 291 291 end … … 302 302 end 303 303 end 304 if isempty( time) && ~isempty(find(strcmp(FileType_A,{'mmreader','video'})))% case of video input305 time=zeros(FileInfo_A.NumberOfFrames+1,2);306 time(:,2)=(0:1/FileInfo_A.FrameRate:(FileInfo_A.NumberOfFrames)/FileInfo_A.FrameRate)';304 if isempty(Time) && ~isempty(find(strcmp(FileType_A,{'mmreader','video'})))% case of video input 305 Time=zeros(FileInfo_A.NumberOfFrames+1,2); 306 Time(:,2)=(0:1/FileInfo_A.FrameRate:(FileInfo_A.NumberOfFrames)/FileInfo_A.FrameRate)'; 307 307 TimeSource='video'; 308 308 ColorType='truecolor'; 309 309 end 310 if isempty( time)% time = index i +0.001 index j by default310 if isempty(Time)% Time = index i +0.001 index j by default 311 311 %MinIndex_i=min(i1_series_Civ1); 312 312 MaxIndex_i=max(i2_series_Civ1); 313 313 %MinIndex_j=min(j1_series_Civ1); 314 314 MaxIndex_j=max(j2_series_Civ1); 315 time=(1:MaxIndex_i)'*ones(1,MaxIndex_j);316 time=time+0.001*ones(MaxIndex_i,1)*(1:MaxIndex_j);317 time=[zeros(1,MaxIndex_j);time];% insert a first line of zeros318 time=[zeros(MaxIndex_i+1,1) time];% insert a first column of zeros315 Time=(1:MaxIndex_i)'*ones(1,MaxIndex_j); 316 Time=Time+0.001*ones(MaxIndex_i,1)*(1:MaxIndex_j); 317 Time=[zeros(1,MaxIndex_j);Time];% insert a first line of zeros 318 Time=[zeros(MaxIndex_i+1,1) Time];% insert a first column of zeros 319 319 end 320 320 … … 438 438 end 439 439 if strcmp(Param.ActionInput.ListCompareMode,'displacement') 440 Data.Civ1_Time= time(i2+1,j2+1);% the time is the time of the secodn image441 Data.Civ1_Dt=1;% time interval is 1, to yield displacement instead of velocity=displacement/Dt at reading440 Data.Civ1_Time=Time(i2+1,j2+1);% the Time is the Time of the secodn image 441 Data.Civ1_Dt=1;% Time interval is 1, to yield displacement instead of velocity=displacement/Dt at reading 442 442 else 443 Data.Civ1_Time=( time(i2+1,j2+1)+time(i1+1,j1+1))/2;% the time is the time at the middle of the image pair444 Data.Civ1_Dt= time(i2+1,j2+1)time(i1+1,j1+1);443 Data.Civ1_Time=(Time(i2+1,j2+1)+Time(i1+1,j1+1))/2;% the Time is the Time at the middle of the image pair 444 Data.Civ1_Dt=Time(i2+1,j2+1)Time(i1+1,j1+1); 445 445 end 446 446 for ilist=1:length(list_param) … … 736 736 Civ2_Dt=1; 737 737 else 738 Civ2_Dt= time(i2_civ2+1,j2_civ2+1)time(i1_civ2+1,j1_civ2+1);738 Civ2_Dt=Time(i2_civ2+1,j2_civ2+1)Time(i1_civ2+1,j1_civ2+1); 739 739 end 740 740 end … … 761 761 Data.Civ2_ImageB=ImageName_B; 762 762 if strcmp(Param.ActionInput.ListCompareMode,'displacement') 763 Data.Civ2_Time= time(i2_civ2+1,j2_civ2+1);% the time is the time of the secodn image764 Data.Civ2_Dt=1;% time interval is 1, to yield displacement instead of velocity=displacement/Dt at reading763 Data.Civ2_Time=Time(i2_civ2+1,j2_civ2+1);% the Time is the Time of the secodn image 764 Data.Civ2_Dt=1;% Time interval is 1, to yield displacement instead of velocity=displacement/Dt at reading 765 765 else 766 Data.Civ2_Time=( time(i2_civ2+1,j2_civ2+1)+time(i1_civ2+1,j1_civ2+1))/2;766 Data.Civ2_Time=(Time(i2_civ2+1,j2_civ2+1)+Time(i1_civ2+1,j1_civ2+1))/2; 767 767 Data.Civ2_Dt=Civ2_Dt; 768 768 end 
trunk/src/series/sub_background.m
r924 r950 340 340 if Param.ActionInput.CheckLevelTransform 341 341 C=levels(Acor); 342 imwrite(C,newname,'BitDepth', 8); % save the new image342 imwrite(C,newname,'BitDepth',16); % save the new image 343 343 else 344 344 if isequal(FileInfo{1}.BitDepth,16) … … 393 393 if Param.ActionInput.CheckLevelTransform 394 394 C=levels(Acor); 395 imwrite(C,newname,'BitDepth', 8); % save the new image395 imwrite(C,newname,'BitDepth',16); % save the new image 396 396 else 397 397 if isequal(FileInfo{1}.BitDepth,16) … … 421 421 if Param.ActionInput.CheckLevelTransform 422 422 C=levels(Acor); 423 imwrite(C,newname,'BitDepth', 8); % save the new image423 imwrite(C,newname,'BitDepth',16); % save the new image 424 424 else 425 425 if isequal(FileInfo{1}.BitDepth,16) … … 435 435 end 436 436 437 438 437 function C=levels(A) 439 %whos A; 440 B=double(A(:,:,1)); 441 windowsize=round(min(size(B,1),size(B,2))/20); 442 windowsize=floor(windowsize/2)*2+1; 443 ix=1/2windowsize/2:1/2+windowsize/2;% 444 %del=np/3; 445 %fct=exp((ix/del).^2); 446 fct2=cos(ix/(windowsize1)/2*pi/2); 447 %Mfiltre=(ones(5,5)/5^2); 448 %Mfiltre=fct2'; 449 Mfiltre=fct2'*fct2; 450 Mfiltre=Mfiltre/(sum(sum(Mfiltre))); 451 452 C=filter2(Mfiltre,B); 453 C(:,1:windowsize)=C(:,windowsize)*ones(1,windowsize); 454 C(:,endwindowsize+1:end)=C(:,endwindowsize+1)*ones(1,windowsize); 455 C(1:windowsize,:)=ones(windowsize,1)*C(windowsize,:); 456 C(endwindowsize+1:end,:)=ones(windowsize,1)*C(endwindowsize,:); 457 C=tanh(B./(2*C)); 458 [n,c]=hist(reshape(C,1,[]),100); 459 % figure;plot(c,n); 460 461 [m,i]=max(n); 462 c_max=c(i); 463 [dummy,index]=sort(abs(cc(i))); 464 n=n(index); 465 c=c(index); 466 i_select = find(cumsum(n)<0.95*sum(n)); 467 if isempty(i_select) 468 i_select = 1:length(c); 469 end 470 c_select=c(i_select); 471 n_select=n(i_select); 472 cmin=min(c_select); 473 cmax=max(c_select); 474 C=(Ccmin)/(cmaxcmin)*256; 475 C=uint8(C); 438 439 nblock_y=100;%2*Param.TransformInput.BlockSize; 440 nblock_x=100;%2*Param.TransformInput.BlockSize; 441 [npy,npx]=size(A); 442 [X,Y]=meshgrid(1:npx,1:npy); 443 444 %Backg=zeros(size(A)); 445 %Aflagmin=sparse(imregionalmin(A));%Amin=1 for local image minima 446 %Amin=A.*Aflagmin;%values of A at local minima 447 % 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 450 fctblock= inline('mean(x(:))'); 451 B=imresize(Backg,size(A),'bilinear');% interpolate to the initial size image 452 A=(AB);%substract background 453 AMean=blkproc(A,[nblock_y nblock_x],fctblock);% take the mean in blocks 454 fctblock= inline('var(x(:))'); 455 AVar=blkproc(A,[nblock_y nblock_x],fctblock);% take the mean in blocks 456 Avalue=AVar./AMean% typical value of particle luminosity 457 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);
Note: See TracChangeset
for help on using the changeset viewer.