Changeset 1161
- Timestamp:
- Jul 19, 2024, 5:57:46 AM (5 months ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/filter_tps.m
r1154 r1161 15 15 % coord=[X Y]: matrix whose first column is the x coordinates of the initial data, the second column the y coordiantes 16 16 % U,V, possibly W: set of velocity components of the initial data 17 % SubdomainSize: estimated number of data points in each subdomain 17 % SubdomainSize: estimated number of data points in each subdomain, choose a number > 125 (must be >= 12 for convergence of tps after division by 4) 18 18 % FieldSmooth: smoothing parameter 19 % Threshold: max diff accepted between smoothed and initial data 19 % Threshold: max diff accepted between smoothed and initial data 20 20 21 21 … … 49 49 AspectRatio=Range(2)/Range(1); 50 50 NbSubDomain=NbVec/SubDomainSize;% estimated number of subdomains 51 NbSubDomainX=max(floor(sqrt(NbSubDomain/AspectRatio)),1);% estimated number of subdomains in x 51 NbSubDomainX=max(floor(sqrt(NbSubDomain/AspectRatio)),1);% estimated number of subdomains in x 52 52 NbSubDomainY=max(floor(sqrt(NbSubDomain*AspectRatio)),1);% estimated number of subdomains in y 53 53 NbSubDomain=NbSubDomainX*NbSubDomainY;% new estimated number of subdomains in a matrix shape partition in subdomains … … 78 78 FF=false(NbVec,1);%false flag=0 (false) by default 79 79 nb_select=zeros(NbVec,1); 80 check_empty= zeros(1,NbSubDomain);80 check_empty=false(1,NbSubDomain); 81 81 82 82 %% calculate tps coeff in each subdomain … … 84 84 SubRange(1,:,isub)=[CentreX(isub)-0.55*Siz(1) CentreX(isub)+0.55*Siz(1)];%bounds of subdomain #isub in x coordinate 85 85 SubRange(2,:,isub)=[CentreY(isub)-0.55*Siz(2) CentreY(isub)+0.55*Siz(2)];%bounds of subdomain #isub in y coordinate 86 ind_sel_previous=[];87 86 ind_sel=0;%initialize set of vector indices in the subdomain 88 %increase iteratively the subdomain if it contains less than SubDomainNbVec/4 source vectors 89 while numel(ind_sel)>numel(ind_sel_previous) 90 ind_sel_previous=ind_sel;% record the set of selected vector indices for next iteration 87 %increase iteratively the subdomain if it contains less than 88 %SubDomainNbVec/4 source vectors, until possibly cover the whole domain:check_partial_domain=false 89 check_partial_domain= true; 90 while check_partial_domain 91 %check_next=false;% test to go to next iteration with wider subdomain 92 ind_sel_previous=ind_sel;% record the set of selected vector indices for next iteration 91 93 ind_sel= find(~FF & Coord(:,1)>=SubRange(1,1,isub) & Coord(:,1)<=SubRange(1,2,isub) & Coord(:,2)>=SubRange(2,1,isub) & Coord(:,2)<=SubRange(2,2,isub));% indices of vectors in the subdomain #isub 92 %ind_sel= find( Coord(:,1)>=SubRange(1,1,isub) & Coord(:,1)<=SubRange(1,2,isub) & Coord(:,2)>=SubRange(2,1,isub) & Coord(:,2)<=SubRange(2,2,isub));% indices of vectors in the subdomain #isub 94 check_partial_domain=sum(SubRange(:,1,isub)> MinCoord' | SubRange(:,2,isub)< MaxCoord'); 95 % isub 96 % numel(ind_sel) 97 93 98 % if no vector in the subdomain #isub, skip the subdomain 94 99 if isempty(ind_sel) 95 check_empty(isub)=1; 96 break 97 % if too few selected vectors, increase the subrange for next iteration 98 elseif numel(ind_sel)<SubDomainSize/4 && ~isequal( ind_sel,ind_sel_previous) 99 SubRange(:,1,isub)=SubRange(:,1,isub)-Siz'/4; 100 SubRange(:,2,isub)=SubRange(:,2,isub)+Siz'/4; 101 % if subdomain includes enough vectors, perform tps interpolation 100 check_empty(isub)=true; 101 break 102 103 % if too few selected vectors, increase the subrange for next iteration by 50 % in each direction 104 elseif numel(ind_sel)<SubDomainSize/4 && ~isequal( ind_sel,ind_sel_previous)&& check_partial_domain 105 % SubRange(:,1,isub)=SubRange(:,1,isub)-Siz'/4; 106 % SubRange(:,2,isub)=SubRange(:,2,isub)+Siz'/4; 107 SubRange(:,1,isub)=1.25*SubRange(:,1,isub)-0.25*SubRange(:,2,isub); 108 SubRange(:,2,isub)=-0.25*SubRange(:,1,isub)+1.25*SubRange(:,2,isub); 109 110 % if subdomain includes enough vectors, perform tps interpolation 102 111 else 103 112 [U_smooth_sub,U_tps_sub]=tps_coeff(Coord(ind_sel,:),U(ind_sel),smoothing); … … 109 118 if exist('Threshold','var')&&~isempty(Threshold) 110 119 FF(ind_sel)=(NormDiff>Threshold);%put FF value to 1 to identify the criterium of elimmination 111 ind_ind_sel=find(~FF(ind_sel)); % select the indices of remaining vectors in the subset of ind_sel vectors 120 ind_ind_sel=find(~FF(ind_sel)); % select the indices of remaining vectors in the subset of ind_sel vectors 112 121 end 113 122 % if no value exceeds threshold, the result is recorded 123 114 124 if isequal(numel(ind_ind_sel),numel(ind_sel)) 115 125 x_width=(SubRange(1,2,isub)-SubRange(1,1,isub))/pi; … … 128 138 display(['tps done with ' num2str(numel(ind_sel)) ' vectors in subdomain # ' num2str(isub) ' among ' num2str(NbSubDomain)]) 129 139 break 130 % if too few selected vectors, increase the subrange for next iteration 131 elseif numel(ind_ind_sel)<SubDomainSize/4 && ~isequal( ind_sel,ind_sel_previous) 132 SubRange(:,1,isub)=SubRange(:,1,isub)-Siz'/4; 133 SubRange(:,2,isub)=SubRange(:,2,isub)+Siz'/4; 140 % if too few selected vectors, increase the subrange for next iteration by 50% in each direction 141 elseif numel(ind_ind_sel)<SubDomainSize/4 && ~isequal( ind_sel,ind_sel_previous)&& check_partial_domain 142 % SubRange(:,1,isub)=SubRange(:,1,isub)-Siz'/4; 143 % SubRange(:,2,isub)=SubRange(:,2,isub)+Siz'/4; 144 SubRange(:,1,isub)=1.25*SubRange(:,1,isub)-0.25*SubRange(:,2,isub); 145 SubRange(:,2,isub)=-0.25*SubRange(:,1,isub)+1.25*SubRange(:,2,isub); 134 146 % else interpolation-smoothing is done again with the selected vectors 135 147 else … … 153 165 end 154 166 end 167 % check_next=true;% go to next iteration with wider subdomain 168 end% end of while loop fo increasing subdomain size 169 if ~check_partial_domain && isub<NbSubDomain% if the while loop proceed to the end, the whole domain size has been covered 170 check_empty(isub+1:end)=true; 171 break %the whole domain has been already covered, no need for new subdomains 155 172 end 156 173 end -
trunk/src/get_file_info.m
r1157 r1161 170 170 end 171 171 elseif isfield(Data,'Conventions') && strcmp(Data.Conventions,'uvmat/civdata') 172 FileInfo.FileType='civdata'; % test for civx velocity fields 172 FileInfo.FileType='civdata'; % test for civ velocity fields 173 FileInfo.CivStage=Data.CivStage; 174 elseif isfield(Data,'Conventions') && strcmp(Data.Conventions,'uvmat/civdata_3D') 175 FileInfo.FileType='civdata_3D'; % test for 3D volume civ velocity fields 173 176 FileInfo.CivStage=Data.CivStage; 174 177 else -
trunk/src/proj_field.m
r1158 r1161 1723 1723 ProjData.coord_y=coord_y_proj; 1724 1724 ProjData.(VarName)=interp3(Coord{3},Coord{2},Coord{1},double(FieldData.(VarName)),XI_proj,YI_proj,ZI_proj,'*linear'); 1725 ProjData.(VarName)= nanmean(ProjData.(VarName),3);1725 ProjData.(VarName)=mean(ProjData.(VarName),3,'omitnan'); 1726 1726 ProjData.(VarName)=squeeze(ProjData.(VarName)); 1727 1727 end -
trunk/src/read_civdata.m
r1153 r1161 218 218 var={}; 219 219 switch vel_type 220 case{'civ1','civ2' ,'civ3'}221 varout={'X','Y','Z','U','V','W','C','F ','FF'};222 varin= {'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U','Civ1_V','Civ1_W','Civ1_C','Civ1_F ','Civ1_FF'};223 role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary',' warnflag','errorflag'};224 case{'filter1','filter2' ,'filter3'}225 varout={'X','Y','Z','U','V','W','C','F ','FF','Coord_tps','U_tps','V_tps','W_tps','SubRange','NbCentre','NbCentre','NbCentre'};226 varin={'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U_smooth','Civ1_V_smooth','Civ1_W','Civ1_C','Civ1_F ','Civ1_FF',...220 case{'civ1','civ2'} 221 varout={'X','Y','Z','U','V','W','C','FF'}; 222 varin= {'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U','Civ1_V','Civ1_W','Civ1_C','Civ1_FF'}; 223 role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','errorflag'}; 224 case{'filter1','filter2'} 225 varout={'X','Y','Z','U','V','W','C','FF','Coord_tps','U_tps','V_tps','W_tps','SubRange','NbCentre','NbCentre','NbCentre'}; 226 varin={'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U_smooth','Civ1_V_smooth','Civ1_W','Civ1_C','Civ1_FF',... 227 227 'Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps','Civ1_W_tps','Civ1_SubRange','Civ1_NbCentre','Civ1_NbCentres','Civ1_NbSites'}; 228 role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary',' warnflag','errorflag','coord_tps','vector_x_tps',...228 role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','errorflag','coord_tps','vector_x_tps',... 229 229 'vector_y_tps','vector_z_tps','ancillary','ancillary','ancillary','ancillary'}; 230 230 % rmq: NbCentres and NbSites obsolete replaced by NbCentre, kept for consistency with previous data … … 233 233 case {'civ2','filter2'} 234 234 varin=regexprep(varin,'1','2'); 235 case {'civ3','filter3'}236 varin=regexprep(varin,'1','3');235 % case {'civ3','filter3'} 236 % varin=regexprep(varin,'1','3'); 237 237 end 238 238 var=[varout;varin]; 239 239 if ~strcmp(ProjModeRequest,'interp_tps') 240 var=var(:,1: 9);%suppress tps if not needed240 var=var(:,1:8);%suppress tps if not needed 241 241 end 242 242 vel_type_out=vel_type; -
trunk/src/script_delete_PCO.m
r1160 r1161 54 54 DirPCORaw=dir(TifFolder); 55 55 DirPCORawCells=struct2cell(DirPCORaw); 56 CheckTif=regexp(DirPCOR AwCells(1,:),'.tif$');56 CheckTif=regexp(DirPCORawCells(1,:),'.tif$'); 57 57 IndexTif=find(~cellfun('isempty',CheckTif)); 58 ListTif=DirPCOR AwCells(1,IndexTif);58 ListTif=DirPCORawCells(1,IndexTif); 59 59 try 60 Info=imfinfo(fullfile(TifFolder,ListTif{1}));61 RecordLength=numel(Info);%Number of frames in fullfile(TifFolder,FileName)62 Info=imfinfo(fullfile(TifFolder,ListTif{end}));63 NumberOfFrames=numel(Info)+(numel(ListTif)-1)*RecordLength%Number of frames in fullfile(TifFolder,FileName)60 Info=imfinfo(fullfile(TifFolder,ListTif{1})); 61 RecordLength=numel(Info);%Number of frames in fullfile(TifFolder,FileName) 62 Info=imfinfo(fullfile(TifFolder,ListTif{end})); 63 NumberOfFrames=numel(Info)+(numel(ListTif)-1)*RecordLength%Number of frames in fullfile(TifFolder,FileName) 64 64 catch ME 65 65 disp(ME.message) … … 67 67 end 68 68 ind_png=find(strcmp([ListNamesSubSub{isubsub} '.png'],ListNamesSubSub)); %index of the .png folder corresponding to the raw PCO folder 69 PngFolder=fullfile(RootFolder,ListNames{ilist},ListNamesSub{isub},ListNamesSubSub{ind_png}) 70 if exist(PngFolder,'dir') 71 DirPng=dir(PngFolder); 72 if numel(DirPng)==NumberOfFrames+6 73 PngCells=struct2cell(DirPng(7:end)); 74 mm=cell2mat(PngCells(4,:));% check the sizes of extracted images 75 sizemax=max(mm) 76 sizemin=min(mm(3:end)) 77 disp(['max size(Mbytes)=' num2str(sizemax/1000000)]); 78 if min(mm(3:end))<0.9*sizemax 79 status=['WARNING' 'min size(Mbytes)=' num2str(sizemin/1000000)]; 69 if isempty(ind_png) 70 List2extract=[List2extract;TifFolder]; 71 else 72 PngFolder=fullfile(RootFolder,ListNames{ilist},ListNamesSub{isub},ListNamesSubSub{ind_png}) 73 if exist(PngFolder,'dir') 74 DirPng=dir(PngFolder); 75 if numel(DirPng)==NumberOfFrames+6 76 PngCells=struct2cell(DirPng(7:end)); 77 mm=cell2mat(PngCells(4,:));% check the sizes of extracted images 78 sizemax=max(mm) 79 sizemin=min(mm(3:end)) 80 disp(['max size(Mbytes)=' num2str(sizemax/1000000)]); 81 if min(mm(3:end))<0.9*sizemax 82 status=['WARNING' 'min size(Mbytes)=' num2str(sizemin/1000000)]; 83 List2check=[List2check;PngFolder]; 84 else 85 List2delete=[List2delete;TifFolder];% approve deletion of the source multitif files 86 end 87 else 88 status=['extraction not finished,' num2str(numel(DirPng)-6) ' images extracted']; 80 89 List2check=[List2check;PngFolder]; 81 else82 List2delete=[List2delete;PngFolder];% approve deletion of the source multitif files83 90 end 84 else85 status=['extraction not finished,' num2str(numel(DirPng)-6) ' images extracted'];86 List2check=[List2check;PngFolder];87 91 end 88 else89 List2extract=[List2extract;TifFolder];90 92 end 91 93 end … … 93 95 end 94 96 end 95 97 98 96 99 97 100 List2extract -
trunk/src/script_delete_rdvision.m
r1160 r1161 97 97 catch ME 98 98 disp(['error in ' filename_seq]) 99 disp(ME.message) 99 100 end 100 101 DirPng=dir(PngFolder); -
trunk/src/series.m
r1156 r1161 2615 2615 set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end 2616 2616 end 2617 num_first_i_Callback(hObject, eventdata, handles) 2618 num_first_j_Callback(hObject, eventdata, handles) 2617 2619 2618 2620 %% enable or desable j index visibility … … 2620 2622 enable_j(handles,'off') 2621 2623 else% show j index if relevant in the input series 2624 if isfield(SeriesData,'j1_series') 2622 2625 j1_series=SeriesData.j1_series; 2623 2626 for iview=1:size(j1_series,1) … … 2626 2629 break 2627 2630 end 2631 end 2628 2632 end 2629 2633 end -
trunk/src/series/civ_3D.m
r1160 r1161 314 314 return 315 315 end 316 %for z_index=2:floor((NbSlice-1)/par_civ1.Dz)% loop on slices316 % loop on slices 317 317 for z_index=2:floor((NbSlice-SearchRange_z)/par_civ1.Dz)% loop on slices 318 par_civ1.ImageA=circshift(par_civ1.ImageA,-par_civ1.Dz );%shift the indices in the image block upward by par_civ1.Dz319 par_civ1.ImageB=circshift(par_civ1.Image A,-par_civ1.Dz);318 par_civ1.ImageA=circshift(par_civ1.ImageA,-par_civ1.Dz,1);%shift the indices in the image block upward by par_civ1.Dz 319 par_civ1.ImageB=circshift(par_civ1.ImageB,-par_civ1.Dz,1); 320 320 for iz=1:par_civ1.Dz %read the new images at the end of the image block 321 j_image_index=j1_series_Civ1(z_index*par_civ1.Dz+SearchRange_z-par_civ1.Dz+iz ,1)321 j_image_index=j1_series_Civ1(z_index*par_civ1.Dz+SearchRange_z-par_civ1.Dz+iz+1,1) 322 322 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(1,ifield),[],j_image_index);% 323 323 A= read_image(ImageName_A,FileType_A); … … 330 330 [Data.Civ1_X(z_index,:,:),Data.Civ1_Y(z_index,:,:), Data.Civ1_U(z_index,:,:), Data.Civ1_V(z_index,:,:),Data.Civ1_W(z_index,:,:),... 331 331 Data.Civ1_C(z_index,:,:), Data.Civ1_FF(z_index,:,:), result_conv, errormsg] = civ3D (par_civ1); 332 333 332 if ~isempty(errormsg) 334 333 disp_uvmat('ERROR',errormsg,checkrun) … … 523 522 Data.CivStage=4; 524 523 end 525 % else 526 % SubRange= par_civ2.Civ1_SubRange; 527 % NbCentres=par_civ2.Civ1_NbCentres; 528 % Coord_tps=par_civ2.Civ1_Coord_tps; 529 % U_tps=par_civ2.Civ1_U_tps; 530 % V_tps=par_civ2.Civ1_V_tps; 531 % Civ1_Dt=par_civ2.Civ1_Dt; 532 % Civ2_Dt=par_civ2.Civ1_Dt; 533 % Data.ListVarName={}; 534 % Data.VarDimName={}; 535 % end 524 536 525 Shiftx=zeros(size(par_civ2.Grid,1),1);% shift expected from civ1 data 537 526 Shifty=zeros(size(par_civ2.Grid,1),1); 538 527 nbval=zeros(size(par_civ2.Grid,1),1);% nbre of interpolated values at each grid point (from the different patch subdomains) 539 if par_civ2.CheckDeformation 540 DUDX=zeros(size(par_civ2.Grid,1),1); 541 DUDY=zeros(size(par_civ2.Grid,1),1); 542 DVDX=zeros(size(par_civ2.Grid,1),1); 543 DVDY=zeros(size(par_civ2.Grid,1),1); 544 end 528 545 529 NbSubDomain=size(SubRange,3); 546 530 for isub=1:NbSubDomain% for each sub-domain of Patch1 … … 555 539 Shiftx(ind_sel)=Shiftx(ind_sel)+EM*U_tps(1:nbvec_sub+3,isub);%velocity shift estimated by tps from civ1 556 540 Shifty(ind_sel)=Shifty(ind_sel)+EM*V_tps(1:nbvec_sub+3,isub); 557 if par_civ2.CheckDeformation558 [EMDX,EMDY] = tps_eval_dxy(epoints,ctrs);%2D matrix of distances between extrapolation points epoints and spline centres (=site points) ctrs559 DUDX(ind_sel)=DUDX(ind_sel)+EMDX*U_tps(1:nbvec_sub+3,isub);560 DUDY(ind_sel)=DUDY(ind_sel)+EMDY*U_tps(1:nbvec_sub+3,isub);561 DVDX(ind_sel)=DVDX(ind_sel)+EMDX*V_tps(1:nbvec_sub+3,isub);562 DVDY(ind_sel)=DVDY(ind_sel)+EMDY*V_tps(1:nbvec_sub+3,isub);563 end564 541 end 565 542 end … … 924 901 correl_xy=conv2(subima2,flip(flip(subima1,2),1),'valid'); 925 902 result_conv(kz,:,:)=correl_xy; 926 max_xy(kz)=max(max(correl_xy)); 927 [yk(kz),xk(kz)]=find(correl_xy >=0.999*max_xy(kz),1);%find the indices of the maximum, use 0.999 to avoid rounding errors903 max_xy(kz)=max(max(correl_xy)); 904 [yk(kz),xk(kz)]=find(correl_xy==max_xy(kz),1);%find the indices of the maximum, use 0.999 to avoid rounding errors 928 905 end 929 906 [corrmax,dz]=max(max_xy); … … 990 967 FF=false; 991 968 peakz=z;peaky=y;peakx=x; 992 %if z < npz && z > 1 && y < npy && y > 1 && x < npx && x > 1993 %f0 = log(result_conv(z,y,x));994 %f1 = log(result_conv(z-1,y,x));995 %f2 = log(result_conv(z+1,y,x));996 %peakz = peakz+ (f1-f2)/(2*f1-4*f0+2*f2);997 % 998 %f1 = log(result_conv(z,y-1,x));999 %f2 = log(result_conv(z,y+1,x));1000 %peaky = peaky+ (f1-f2)/(2*f1-4*f0+2*f2);1001 % 1002 %f1 = log(result_conv(z,y,x-1));1003 %f2 = log(result_conv(z,y,x+1));1004 %peakx = peakx+ (f1-f2)/(2*f1-4*f0+2*f2);1005 %else1006 %FF=true;1007 %end969 if z < npz && z > 1 && y < npy && y > 1 && x < npx && x > 1 970 f0 = log(result_conv(z,y,x)); 971 f1 = log(result_conv(z-1,y,x)); 972 f2 = log(result_conv(z+1,y,x)); 973 peakz = peakz+ (f1-f2)/(2*f1-4*f0+2*f2); 974 975 f1 = log(result_conv(z,y-1,x)); 976 f2 = log(result_conv(z,y+1,x)); 977 peaky = peaky+ (f1-f2)/(2*f1-4*f0+2*f2); 978 979 f1 = log(result_conv(z,y,x-1)); 980 f2 = log(result_conv(z,y,x+1)); 981 peakx = peakx+ (f1-f2)/(2*f1-4*f0+2*f2); 982 else 983 FF=true; 984 end 1008 985 1009 986 vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1 peakz-floor(npz/2)-1]; -
trunk/src/series/civ_input.m
r1156 r1161 132 132 [~,~,~,~,~,~,~,~,NomTypeImaA]=fileparts_uvmat(Data.Civ1_ImageA); 133 133 % [~,~,~,~,~,~,~,~,NomTypeImaB]=fileparts_uvmat(Data.Civ1_ImageB); 134 else 134 elseif isfield(Data,'Civ2_ImageA') 135 135 series('display_file_name',hhseries,Data.Civ2_ImageA,'append');%append the image series to the input list 136 136 [~,~,~,~,~,~,~,~,NomTypeImaA]=fileparts_uvmat(Data.Civ2_ImageA); … … 415 415 %% Civ1 parameters 416 416 %Param.CheckCiv1=1; 417 Param.Civ1.CorrBoxSize=[ 25 251];418 Param.Civ1.SearchBoxSize=[ 55 555];417 Param.Civ1.CorrBoxSize=[31 31 1]; 418 Param.Civ1.SearchBoxSize=[61 61 5]; 419 419 Param.Civ1.SearchBoxShift=[0 0]; 420 420 Param.Civ1.CorrSmooth=1; … … 432 432 %% Patch1 parameters 433 433 %Param.CheckPatch1=1; 434 Param.Patch1.FieldSmooth=20 ;435 Param.Patch1.MaxDiff= 2;434 Param.Patch1.FieldSmooth=200; 435 Param.Patch1.MaxDiff=1.5; 436 436 Param.Patch1.SubDomainSize=125; 437 437 … … 452 452 453 453 %% Patch2 parameters 454 Param.Patch2.FieldSmooth= 5;455 Param.Patch2.MaxDiff=1 .5000;454 Param.Patch2.FieldSmooth=20; 455 Param.Patch2.MaxDiff=1; 456 456 Param.Patch2.SubDomainSize=250; 457 Param.Patch2.TestPatch2=0;458 457 459 458 fill_GUI(Param,handles.civ_input)% fill the elements of the GUI series with the input parameters … … 706 705 end 707 706 mode_value=get(handles.ListPairMode,'Value'); 708 if isempty(mode_value) 707 if isempty(mode_value)|| mode_value>numel(mode_list) 709 708 mode_value=1; 710 709 end … … 835 834 mode_list=get(handles.ListPairMode,'String'); 836 835 mode_value=get(handles.ListPairMode,'Value'); 837 if isempty(mode_value) 836 if isempty(mode_value)||mode_value>numel(mode_list) 838 837 mode_value=1; 839 838 end -
trunk/src/series/civ_series.m
r1160 r1161 1052 1052 par_civ.CorrSmooth=2;% use SUBPIX2DGAUSS (take into account more points near the max) 1053 1053 end 1054 1054 1055 1055 if par_civ.CorrSmooth~=0 % par_civ.CorrSmooth=0 implies no civ computation (just input image and grid points given) 1056 1056 for ivec=1:nbvec … … 1130 1130 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1131 1131 corrmax= max(max(result_conv)); 1132 result_conv=(result_conv/corrmax)*255; %normalize, peak=always 255 1132 1133 %result_conv=(result_conv/corrmax); %normalize, peak=always 255 1133 1134 %Find the correlation max, at 255 1134 [y,x] = find(result_conv== 255,1);1135 [y,x] = find(result_conv==corrmax,1); 1135 1136 subimage2_crop=image2_crop(y:y+2*iby2/mesh,x:x+2*ibx2/mesh);%subimage of image 2 corresponding to the optimum displacement of first image 1136 1137 sum_square=sum_square*sum(sum(subimage2_crop.*subimage2_crop));% product of variances of image 1 and 2 … … 1169 1170 end 1170 1171 end 1171 result_conv=result_conv*corrmax/(255*sum_square);% keep the last correlation matrix for output 1172 result_conv=result_conv*corrmax/sum_square;% keep the last (not normalised) correlation matrix for output 1173 1174 %------------------------------------------------------------------------ 1175 % --- Find the maximum of the correlation function with subpixel resolution 1176 % make a fit with a gaussian curve from the three correlation values across the max, along each direction. 1177 % OUPUT: 1178 % vector = optimum displacement vector with subpixel correction 1179 % FF =flag: =0 OK 1180 % =1 , max too close to the edge of the search box (1 pixel margin) 1181 % INPUT: 1182 % result_conv: 2D correlation fct 1183 % x,y: position of the maximum correlation at integer values 1184 1185 function [vector,FF] = SUBPIXGAUSS (result_conv,x,y) 1186 %------------------------------------------------------------------------ 1187 % vector=[0 0]; %default 1188 FF=true;% error flag for vector truncated by the limited search box 1189 [npy,npx]=size(result_conv); 1190 1191 peaky = y; peakx=x; 1192 if y < npy && y > 1 && x < npx-1 && x > 1 1193 FF=false; % no error by the limited search box 1194 max_conv=result_conv(y,x);% max correlation 1195 peak2noise= max(4,max_conv/std(reshape(result_conv,1,[])));% ratio of max conv to standard deviation of correlations (estiamtion of noise level), set to value 4 if it is too low 1196 result_conv=result_conv*peak2noise/max_conv;% renormalise the correlation with respect to the noise 1197 result_conv(result_conv<1)=1; %set to 1 correlation values smaller than 1 (=0 by discretisation, to avoid divergence in the log) 1198 1199 f0 = log(result_conv(y,x)); 1200 f1 = log(result_conv(y-1,x)); 1201 f2 = log(result_conv(y+1,x)); 1202 peaky = peaky+ (f1-f2)/(2*f1-4*f0+2*f2); 1203 f1 = log(result_conv(y,x-1)); 1204 f2 = log(result_conv(y,x+1)); 1205 peakx = peakx+ (f1-f2)/(2*f1-4*f0+2*f2); 1206 end 1207 1208 vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1]; 1172 1209 1173 1210 %------------------------------------------------------------------------ 1174 1211 % --- Find the maximum of the correlation function after interpolation 1175 % OUPUT: 1176 % vector = optimum displacement vector with subpixel correction 1177 % F =flag: =0 OK 1178 % =-2 , warning: max too close to the edge of the search box (1 pixel margin) 1179 % INPUT: 1180 % x,y: position of the maximum correlation at integer values 1181 1182 function [vector,F] = SUBPIXGAUSS (result_conv,x,y) 1212 function [vector,FF] = SUBPIX2DGAUSS (result_conv,x,y) 1183 1213 %------------------------------------------------------------------------ 1184 1214 % vector=[0 0]; %default 1185 F=0; 1186 [npy,npx]=size(result_conv); 1187 result_conv(result_conv<1)=1; %set to 1 correlation values smaller than 1 (=0 by discretisation, to avoid divergence in the log) 1188 %the following 8 lines are copyright (c) 1998, Uri Shavit, Roi Gurka, Alex Liberzon, Technion ??? Israel Institute of Technology 1189 %http://urapiv.wordpress.com 1190 peaky = y;peakx=x; 1191 % if y < npy && y > 1 && x < npx-1 && x > 1 1192 % f0 = log(result_conv(y,x)); 1193 % f1 = log(result_conv(y-1,x)); 1194 % f2 = log(result_conv(y+1,x)); 1195 % peaky = peaky+ (f1-f2)/(2*f1-4*f0+2*f2); 1196 % f1 = log(result_conv(y,x-1)); 1197 % f2 = log(result_conv(y,x+1)); 1198 % peakx = peakx+ (f1-f2)/(2*f1-4*f0+2*f2); 1199 % else 1200 % F=1; % warning flag for vector truncated by the limited search box 1201 % end 1202 1203 vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1]; 1204 1205 %------------------------------------------------------------------------ 1206 % --- Find the maximum of the correlation function after interpolation 1207 function [vector,F] = SUBPIX2DGAUSS (result_conv,x,y) 1208 %------------------------------------------------------------------------ 1209 % vector=[0 0]; %default 1210 F=1; 1215 FF=true; 1211 1216 peaky=y; 1212 1217 peakx=x; 1213 result_conv(result_conv<1)=1; %set to 1 correlation values smaller than 1 (to avoid divergence in the log)1214 1218 [npy,npx]=size(result_conv); 1215 1219 if (x < npx) && (y < npy) && (x > 1) && (y > 1) 1216 F=0; 1220 FF=false; 1221 max_conv=result_conv(y,x);% max correlation 1222 peak2noise= max(4,max_conv/std(reshape(result_conv,1,[])));% ratio of max conv to standard deviation of correlations (estiamtion of noise level), set to value 4 if it is too low 1223 result_conv=result_conv*peak2noise/max_conv;% renormalise the correlation with respect to the noise 1224 result_conv(result_conv<1)=1; %set to 1 correlation values smaller than 1 (=0 by discretisation, to avoid divergence in the log) 1217 1225 for i=-1:1 1218 1226 for j=-1:1 1219 %following 15 lines based on 1220 %H. Nobach ??? M. Honkanen (2005) 1221 %Two-dimensional Gaussian regression for sub-pixel displacement 1222 %estimation in particle image velocimetry or particle position 1223 %estimation in particle tracking velocimetry 1224 %Experiments in Fluids (2005) 38: 511???515 1227 %following 15 lines based on H. Nobach and M. Honkanen (2005) 1228 % Two-dimensional Gaussian regression for sub-pixel displacement 1229 % estimation in particle image velocimetry or particle position 1230 % estimation in particle tracking velocimetry 1231 % Experiments in Fluids (2005) 38: 511-515 1225 1232 c10(j+2,i+2)=i*log(result_conv(y+j, x+i)); 1226 1233 c01(j+2,i+2)=j*log(result_conv(y+j, x+i)); … … 1235 1242 c20=(1/6)*sum(sum(c20)); 1236 1243 c02=(1/6)*sum(sum(c02)); 1237 deltax=(c11*c01-2*c10*c02)/(4*c20*c02-c11 ^2);1238 deltay=(c11*c10-2*c01*c20)/(4*c20*c02-c11 ^2);1244 deltax=(c11*c01-2*c10*c02)/(4*c20*c02-c11*c11); 1245 deltay=(c11*c10-2*c01*c20)/(4*c20*c02-c11*c11); 1239 1246 if abs(deltax)<1 1240 1247 peakx=x+deltax; -
trunk/src/series/extract_rdvision.m
r1149 r1161 122 122 if exist(filexml,'file') 123 123 [XmlData,errormsg]=imadoc2struct(filexml); 124 if ~isempty(errormsg) 124 if isempty(errormsg) 125 msgbox_uvmat('CONFIRMATION',[filexml ' used' ]); 126 else 125 127 msgbox_uvmat('ERROR',errormsg); 126 128 return -
trunk/src/series/stereo_civ.m
r1152 r1161 38 38 %AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 39 39 40 function [Data,errormsg,result_conv ]= stereo_civ(Param)40 function [Data,errormsg,result_conv, XmlData]= stereo_civ(Param) 41 41 Data=[]; 42 42 errormsg=''; … … 85 85 WaitbarHandle=findobj(hseries,'Tag','Waitbar');%handle of waitbar in GUI series 86 86 87 %%%%%%%%%%%%%%%% Modif pour test %%%%%%%%%%%%%%%%%% 88 % CheckInputFile=isfield(Param,'InputTable');%= 1 in test use for TestCiv (no nc file involved) 89 CheckOutputFile = isfield(Param,'OutputSubDir') ; %= 1 in test use for TestPatch (no nc file produced) 90 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 91 87 92 %% input files and indexing 88 93 MaxIndex_i=Param.IndexRange.MaxIndex_i; … … 95 100 time=[]; 96 101 for iview=1:size(Param.InputTable,1) 102 %XmlFileName=find_imadoc(Param.InputTable{iview,1},Param.InputTable{iview,2},Param.InputTable{iview,3},Param.InputTable{iview,5}); 97 103 XmlFileName=find_imadoc(Param.InputTable{iview,1},Param.InputTable{iview,2}); 98 104 if isempty(XmlFileName) … … 235 241 236 242 %% Output directory 237 OutputDir=[Param.OutputSubDir Param.OutputDirExt]; 243 OutputDir='/Test'; 244 if CheckOutputFile 245 OutputDir=[Param.OutputSubDir Param.OutputDirExt]; 246 end 247 238 248 239 249 ListGlobalAttribute={'Conventions','Program','CivStage'}; … … 252 262 end 253 263 if isempty(time)% time = index i by default 254 MaxIndex_i=max(i2_series_Civ1 );255 MaxIndex_j=max(j2_series_Civ1 );264 MaxIndex_i=max(i2_series_Civ1, [], 'all'); 265 MaxIndex_j=max(j2_series_Civ1, [], 'all'); 256 266 time=(1:MaxIndex_i)'*ones(1,MaxIndex_j); 257 267 time=[zeros(1,MaxIndex_j);time];% insert a first line of zeros … … 312 322 313 323 314 [A,Rangx,Rangy]=phys_ima(A,XmlData,1); 324 [A,Rangx,Rangy]=phys_ima(A,XmlData,1);%transform image A in phys coordinates 315 325 [Npy,Npx]=size(A{1}); 316 326 PhysImageA=fullfile_uvmat(RootPath_A,Civ1Dir,RootFile_A,'.png','_1a',i1_series_Civ1(ifield),[],1); … … 372 382 Data.Civ1_F=reshape(F,[],1); 373 383 384 %%%%%%%%%%%%%%%% ajout fonction test %%%%%%% 385 if ~isfield (Param.ActionInput,'Civ2') && ~isfield (Param.ActionInput,'Civ3') && ~isfield(Param.ActionInput,'Patch1') 386 [Data.Xmid, Data.Ymid, Data.Uphys, Data.Vphys, Data.Zphys, ... 387 Data.Yphys, Data.Xphys, Data.Error] = getPhysValues(Rangx, ... 388 Rangy, Npx, Npy, Data.Civ1_X, Data.Civ1_Y, Data.Civ1_U, ... 389 Data.Civ1_V, XmlData); 390 391 if ~isempty(errormsg) 392 disp_uvmat('ERROR',errormsg,checkrun) 393 return 394 end 395 end 396 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 397 374 398 end 375 399 … … 414 438 return 415 439 end 416 417 Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch1_Rho','Patch1_Threshold','Patch1_SubDomain'}]; 440 441 %%%%%%%%%%%%%%%%%%%% modif fonction test %%%%%%%%%%%%%%%%%%%%%%% 442 try 443 Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch1_Rho','Patch1_Threshold','Patch1_SubDomain'}]; 444 catch 445 Data.ListGlobalAttribute={'Patch1_Rho','Patch1_Threshold','Patch1_SubDomain'}; 446 end 447 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 448 449 418 450 Data.Patch1_FieldSmooth=Param.ActionInput.Patch1.FieldSmooth; 419 451 Data.Patch1_MaxDiff=Param.ActionInput.Patch1.MaxDiff; 420 452 Data.Patch1_SubDomainSize=Param.ActionInput.Patch1.SubDomainSize; 421 nbvar=length(Data.ListVarName); 422 Data.ListVarName=[Data.ListVarName {'Civ1_U_smooth','Civ1_V_smooth','Civ1_SubRange','Civ1_NbCentres','Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps'}]; 423 Data.VarDimName=[Data.VarDimName {'nb_vec_1','nb_vec_1',{'nb_coord','nb_bounds','nb_subdomain_1'},'nb_subdomain_1',... 424 {'nb_tps_1','nb_coord','nb_subdomain_1'},{'nb_tps_1','nb_subdomain_1'},{'nb_tps_1','nb_subdomain_1'}}]; 453 454 %%%%%%%%%%%%%%%%%%% modif fonction test %%%%%%%%%%%%%%%%%%%%%%%% 455 try 456 nbvar=length(Data.ListVarName); 457 Data.ListVarName=[Data.ListVarName {'Civ1_U_smooth','Civ1_V_smooth','Civ1_SubRange','Civ1_NbCentres','Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps'}]; 458 Data.VarDimName=[Data.VarDimName {'nb_vec_1','nb_vec_1',{'nb_coord','nb_bounds','nb_subdomain_1'},'nb_subdomain_1',... 459 {'nb_tps_1','nb_coord','nb_subdomain_1'},{'nb_tps_1','nb_subdomain_1'},{'nb_tps_1','nb_subdomain_1'}}]; 460 catch 461 nbvar=0; 462 Data.ListVarName={'Civ1_U_smooth','Civ1_V_smooth','Civ1_SubRange','Civ1_NbCentres','Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps'}; 463 Data.VarDimName={'nb_vec_1','nb_vec_1',{'nb_coord','nb_bounds','nb_subdomain_1'},'nb_subdomain_1',... 464 {'nb_tps_1','nb_coord','nb_subdomain_1'},{'nb_tps_1','nb_subdomain_1'},{'nb_tps_1','nb_subdomain_1'}}; 465 end 466 467 if ~isfield(Param.ActionInput,'Civ1') 468 Data.Civ1_X = Param.Civ1_X ; 469 Data.Civ1_Y = Param.Civ1_Y ; 470 Data.Civ1_U = Param.Civ1_U ; 471 Data.Civ1_V = Param.Civ1_V ; 472 Data.Civ1_FF = Param.Civ1_FF ; 473 end 474 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 475 425 476 Data.VarAttribute{nbvar+1}.Role='vector_x'; 426 477 Data.VarAttribute{nbvar+2}.Role='vector_y'; … … 436 487 end 437 488 [Data.Civ1_SubRange,Data.Civ1_NbCentres,Data.Civ1_Coord_tps,Data.Civ1_U_tps,Data.Civ1_V_tps,tild,Ures, Vres,tild,FFres]=... 438 filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomainSize,Data.Patch1_FieldSmooth,Data.Patch1_MaxDiff); 489 filter_tps([Data.Civ1_X(ind_good) Data.Civ1_Y(ind_good)],Data.Civ1_U(ind_good),Data.Civ1_V(ind_good),[],Data.Patch1_SubDomainSize,Data.Patch1_FieldSmooth,Data.Patch1_MaxDiff); 490 439 491 Data.Civ1_U_smooth(ind_good)=Ures; 440 492 Data.Civ1_V_smooth(ind_good)=Vres; 441 493 Data.Civ1_FF(ind_good)=FFres; 442 Data.CivStage=3; 494 Data.CivStage=3; 495 496 if ~isfield (Param.ActionInput,'Civ2') && ~isfield (Param.ActionInput,'Civ3') 497 498 %%%%%%%%% modif fonction test %%%%%%%%%%%%%%%%% 499 try 500 [Data.Xmid, Data.Ymid, Data.Uphys, Data.Vphys, Data.Zphys, ... 501 Data.Yphys, Data.Xphys, Data.Error] = getPhysValues(Rangx, ... 502 Rangy, Npx, Npy, Data.Civ1_X, Data.Civ1_Y, Data.Civ1_U_smooth, ... 503 Data.Civ1_V_smooth, XmlData); 504 catch % si on a pas Rangx, Rangy, Npx, Npy on ouvre les images pour les recalculer 505 try 506 ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(ifield),[],j1_series_Civ1(ifield)); 507 [A{1},VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ1(ifield)); 508 ImageName_B=fullfile_uvmat(RootPath_B,SubDir_B,RootFile_B,FileExt_B,NomType_B,i2_series_Civ1(ifield),[],j2_series_Civ1(ifield)); 509 [A{2},VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ1(ifield)); 510 catch ME 511 if ~isempty(ME.message) 512 disp_uvmat('ERROR', ['error reading input image: ' ME.message],checkrun) 513 return 514 end 515 end 516 [A,Rangx,Rangy]=phys_ima(A,XmlData,1);%transform image A in phys coordinates 517 [Npy,Npx]=size(A{1}); 518 [Data.Xmid, Data.Ymid, Data.Uphys, Data.Vphys, Data.Zphys, ... 519 Data.Yphys, Data.Xphys, Data.Error] = getPhysValues(Rangx, ... 520 Rangy, Npx, Npy, Data.Civ1_X, Data.Civ1_Y, Data.Civ1_U_smooth, ... 521 Data.Civ1_V_smooth, XmlData); 522 end 523 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 524 525 if ~isempty(errormsg) 526 disp_uvmat('ERROR',errormsg,checkrun) 527 return 528 end 529 end 443 530 444 531 end 532 533 534 445 535 446 536 %% Civ2 … … 553 643 Data.Civ2_F=reshape(F,[],1); 554 644 Data.CivStage=Data.CivStage+1; 645 646 %%%%%%%%%%%%%%%% ajout fonction test %%%%%%% 647 if ~isfield (Param.ActionInput,'Civ3') && ~isfield(Param.ActionInput,'Patch2') 648 [Data.Xmid, Data.Ymid, Data.Uphys, Data.Vphys, Data.Zphys, ... 649 Data.Yphys, Data.Xphys, Data.Error] = getPhysValues(Rangx, ... 650 Rangy, Npx, Npy, Data.Civ2_X, Data.Civ2_Y, Data.Civ2_U, ... 651 Data.Civ2_V, XmlData); 652 653 if ~isempty(errormsg) 654 disp_uvmat('ERROR',errormsg,checkrun) 655 return 656 end 657 end 658 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 555 659 end 556 660 … … 612 716 Data.Civ2_FF(ind_good)=FFres; 613 717 Data.CivStage=Data.CivStage+1; 718 719 720 if ~isfield (Param.ActionInput,'Civ3') 721 [Data.Xmid, Data.Ymid, Data.Uphys, Data.Vphys, Data.Zphys, ... 722 Data.Yphys, Data.Xphys, Data.Error] = getPhysValues(Rangx, ... 723 Rangy, Npx, Npy, Data.Civ2_X, Data.Civ2_Y, Data.Civ2_U_smooth, ... 724 Data.Civ2_V_smooth, XmlData); 725 726 if ~isempty(errormsg) 727 disp_uvmat('ERROR',errormsg,checkrun) 728 return 729 end 730 end 731 614 732 end 615 733 … … 769 887 Data.CivStage=Data.CivStage+1; 770 888 771 % get z from u and v (displacements)772 Data.Xmid=Rangx(1)+(Rangx(2)-Rangx(1))*(Data.Civ3_X-0.5)/(Npx-1);%temporary coordinate (velocity taken at the point middle from imgae 1 and 2)773 Data.Ymid=Rangy(2)+(Rangy(1)-Rangy(2))*(Data.Civ3_Y-0.5)/(Npy-1);%temporary coordinate (velocity taken at the point middle from imgae 1 and 2)774 Data.Uphys=Data.Civ3_U_smooth*(Rangx(2)-Rangx(1))/(Npx-1);775 Data.Vphys=Data.Civ3_V_smooth*(Rangy(1)-Rangy(2))/(Npy-1);776 [Data.Zphys,Data.Xphys,Data.Yphys,Data.Error]=shift2z(Data.Xmid,Data.Ymid,Data.Uphys,Data.Vphys,XmlData); %Data.Xphys and Data.Xphys are real coordinate (geometric correction more accurate than xtemp/ytemp) 889 890 [Data.Xmid, Data.Ymid, Data.Uphys, Data.Vphys, Data.Zphys, ... 891 Data.Yphys, Data.Xphys, Data.Error] = getPhysValues(Rangx, ... 892 Rangy, Npx, Npy, Data.Civ3_X, Data.Civ3_Y, Data.Civ3_U_smooth, ... 893 Data.Civ3_V_smooth, XmlData); 894 777 895 if ~isempty(errormsg) 778 896 disp_uvmat('ERROR',errormsg,checkrun) … … 784 902 785 903 %% write result in a netcdf file if requested 904 786 905 if LSM ~= 1 % store all data 787 if exist('ncfile ','var')788 errormsg=struct2nc(ncfile ,Data);906 if exist('ncfile2','var') 907 errormsg=struct2nc(ncfile2,Data); 789 908 if isempty(errormsg) 790 disp([ncfile ' written'])909 disp([ncfile2 ' written']) 791 910 else 792 911 disp(errormsg) … … 794 913 end 795 914 else 915 916 796 917 % store only phys data 797 Data_light.ListVarName={'Xphys','Yphys','Zphys','Civ 3_C','DX','DY','Error'};918 Data_light.ListVarName={'Xphys','Yphys','Zphys','Civ_C','DX','DY','Error'}; 798 919 Data_light.VarDimName={'nb_vec_3','nb_vec_3','nb_vec_3','nb_vec_3','nb_vec_3','nb_vec_3','nb_vec_3'}; 799 920 Data_light.VarAttribute{1}.Role='coord_x'; … … 802 923 Data_light.VarAttribute{5}.Role='vector_x'; 803 924 Data_light.VarAttribute{6}.Role='vector_y'; 804 ind_good=find(Data.Civ3_FF==0); 805 Data_light.Zphys=Data.Zphys(ind_good); 806 Data_light.Yphys=Data.Yphys(ind_good); 807 Data_light.Xphys=Data.Xphys(ind_good); 808 Data_light.Civ3_C=Data.Civ3_C(ind_good); 809 Data_light.DX=Data.Uphys(ind_good); 810 Data_light.DY=Data.Vphys(ind_good); 811 Data_light.Error=Data.Error(ind_good); 925 926 % vrifie la dernire passe effectue 927 if isfield (Param.ActionInput,'Civ3') 928 try 929 ind_good=find(Data.Civ3_FF==0); 930 Data_light.Civ_C=Data.Civ3_C(ind_good); 931 catch 932 Data_light.Civ_C=Data.Civ3_C; 933 end 934 elseif isfield (Param.ActionInput,'Civ2') 935 try 936 ind_good=find(Data.Civ2_FF==0); 937 Data_light.Civ_C=Data.Civ2_C(ind_good); 938 catch 939 Data_light.Civ_C=Data.Civ2_C; 940 end 941 elseif isfield (Param.ActionInput,'Civ1') 942 try 943 ind_good=find(Data.Civ1_FF==0); 944 Data_light.Civ_C=Data.Civ1_C(ind_good); 945 catch 946 Data_light.Civ_C=Data.Civ1_C; 947 end 948 end 949 950 try 951 Data_light.Zphys=Data.Zphys(ind_good); 952 Data_light.Yphys=Data.Yphys(ind_good); 953 Data_light.Xphys=Data.Xphys(ind_good); 954 Data_light.DX=Data.Uphys(ind_good); 955 Data_light.DY=Data.Vphys(ind_good); 956 Data_light.Error=Data.Error(ind_good); 957 catch 958 Data_light.Zphys=Data.Zphys; 959 Data_light.Yphys=Data.Yphys; 960 Data_light.Xphys=Data.Xphys; 961 Data_light.DX=Data.Uphys; 962 Data_light.DY=Data.Vphys; 963 Data_light.Error=Data.Error; 964 end 965 966 812 967 if exist('ncfile2','var') 813 968 errormsg=struct2nc(ncfile2,Data_light); … … 827 982 end 828 983 829 984 end 830 985 831 986 % 'civ': function piv.m adapted from PIVlab http://pivlab.blogspot.com/ … … 1068 1223 end 1069 1224 result_conv=result_conv*corrmax/(255*sum_square);% keep the last correlation matrix for output 1225 end 1070 1226 1071 1227 %------------------------------------------------------------------------ … … 1098 1254 end 1099 1255 vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1]; 1256 end 1100 1257 1101 1258 %------------------------------------------------------------------------ … … 1141 1298 end 1142 1299 vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1]; 1300 end 1143 1301 1144 1302 %'RUN_FIX': function for fixing velocity fields: … … 1189 1347 end 1190 1348 1349 end 1191 1350 1192 1351 %------------------------------------------------------------------------ … … 1250 1409 j2_series=ind2*ones(1,size(i_series,2)); 1251 1410 check_bounds=zeros(size(i1_series));% no limitations due to min-max indices 1411 end 1252 1412 end 1253 1413 … … 1258 1418 % ymid+ v/2: set of apparent phys y coordinates in the ref plane, image B 1259 1419 % XmlData: content of the xml files containing geometric calibration parameters 1420 1421 1260 1422 function [z,Xphy,Yphy,Error]=shift2z(xmid, ymid, u, v,XmlData) 1261 1423 z=0; … … 1320 1482 Xphy=mean(xnew,1); 1321 1483 Yphy=mean(ynew,1); 1322 1323 1324 1325 1326 1484 end 1485 1486 function [Xmid, Ymid, Uphys, Vphys, Zphys, Yphys, Xphys, Error] ... 1487 = getPhysValues(Rangx, Rangy, Npx, Npy, Data_Civ_X, Data_Civ_Y, ... 1488 Data_Civ_U_smooth, Data_Civ_V_smooth, XmlData) 1489 1490 % get z from u and v (displacements) 1491 Xmid=Rangx(1)+(Rangx(2)-Rangx(1))*(Data_Civ_X-0.5)/(Npx-1);%temporary coordinate (velocity taken at the point middle from imgae 1 and 2) 1492 Ymid=Rangy(2)+(Rangy(1)-Rangy(2))*(Data_Civ_Y-0.5)/(Npy-1);%temporary coordinate (velocity taken at the point middle from imgae 1 and 2) 1493 Uphys=Data_Civ_U_smooth*(Rangx(2)-Rangx(1))/(Npx-1); 1494 Vphys=Data_Civ_V_smooth*(Rangy(1)-Rangy(2))/(Npy-1); 1495 [Zphys,Xphys,Yphys,Error]=shift2z(Xmid,Ymid,Uphys,Vphys,XmlData); %Data.Xphys and Data.Xphys are real coordinate (geometric correction more accurate than xtemp/ytempy 1496 1497 end -
trunk/src/series/stereo_input.m
r1129 r1161 1797 1797 set(handles.configSource,'String','NEW') 1798 1798 set(handles.OK,'BackgroundColor',[1 0 1]) 1799 1800 1799 1801 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1800 1802 %%%%%%%%%%%%%% TEST functions … … 1814 1816 Param.Action.RUN=1; 1815 1817 Param.ActionInput=read_GUI(handles.civ_input); 1816 if isfield(Param.ActionInput,'Fix1') 1817 Param.ActionInput=rmfield(Param.ActionInput,'Fix1'); 1818 end 1818 1819 1819 if isfield(Param.ActionInput,'Patch1') 1820 1820 Param.ActionInput=rmfield(Param.ActionInput,'Patch1'); … … 1829 1829 Param.ActionInput=rmfield(Param.ActionInput,'Patch2'); 1830 1830 end 1831 if isfield(Param ,'OutputSubDir')1832 Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series1831 if isfield(Param.ActionInput,'Civ3')%remove options that may be selected beyond Patch1 1832 Param.ActionInput=rmfield(Param.ActionInput,'Civ3'); 1833 1833 end 1834 if isfield(Param.ActionInput,'Fix3') 1835 Param.ActionInput=rmfield(Param.ActionInput,'Fix3'); 1836 end 1837 if isfield(Param.ActionInput,'Patch3') 1838 Param.ActionInput=rmfield(Param.ActionInput,'Patch3'); 1839 end 1840 % if isfield(Param,'OutputSubDir') 1841 % Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series 1842 % end 1834 1843 Param.ActionInput.Civ1.CorrSmooth=0;% launch Civ1 with no data point (to get the image names for A and B) 1835 [Data,errormsg ]=civ_series(Param);% get the civ1+fix1 results1836 if ~isempty(errormsg), return, end % rmq: error msg displayed in civ_series1844 [Data,errormsg, ~, xmlData]=stereo_civ(Param);% get the civ1+fix1 results 1845 % if ~isempty(errormsg), return, end % rmq: error msg displayed in civ_series 1837 1846 1838 1847 %% create image data ImageData for display 1839 1848 ImageData.ListVarName={'ny','nx','A'}; 1840 1849 ImageData.VarDimName= {'ny','nx',{'ny','nx'}}; 1841 ImageData.A=imread(Data.Civ1_ImageA); % read the first image 1850 1851 %%%%%%%%%%%%%%%%% modif fonction test %%%%%%%%%%% 1852 ImageData.VarAttribute{1}.Role='coord_y'; 1853 ImageData.VarAttribute{2}.Role='coord_x'; 1854 ImageData.VarAttribute{3}.Role='scalar'; 1855 1856 A{1}=imread(Data.Civ1_ImageA); % read the first image 1857 A{2}=imread(Data.Civ1_ImageB); % read the first image 1858 1859 phys_img = phys_ima(A,xmlData,1);%transform image A in phys coordinates 1860 ImageData.A = phys_img{1}; 1861 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1862 1842 1863 if ndims(ImageData.A)==3 %case of color image 1843 1864 ImageData.VarDimName= {'ny','nx',{'ny','nx','rgb'}}; … … 1856 1877 ViewData.PlotAxes.X=Data.Civ1_X'; 1857 1878 ViewData.PlotAxes.Y=Data.Civ1_Y'; 1858 ViewData.PlotAxes.B=imread(Data.Civ1_ImageB);%store the second image in the UserData of the GUI view_field 1879 1880 %%%%%%%%%%%%%%%%%%%%%%% 1881 ViewData.PlotAxes.B=phys_img{2};%store the second image in the UserData of the GUI view_field 1882 %%%%%%%%%%%%%%%%%%%%%%% 1883 1859 1884 set(hview_field,'UserData',ViewData)% store the info in the UserData of image view_field 1860 1885 … … 1897 1922 Param.Action.RUN=1; 1898 1923 Param.ActionInput=read_GUI(handles.civ_input); 1924 1899 1925 if isfield(Param.ActionInput,'Civ2')%remove options that may be selected beyond Patch1 1900 1926 Param.ActionInput=rmfield(Param.ActionInput,'Civ2'); … … 1906 1932 Param.ActionInput=rmfield(Param.ActionInput,'Patch2'); 1907 1933 end 1908 if isfield(Param ,'OutputSubDir')1909 Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series1934 if isfield(Param.ActionInput,'Civ3')%remove options that may be selected beyond Patch1 1935 Param.ActionInput=rmfield(Param.ActionInput,'Civ3'); 1910 1936 end 1937 if isfield(Param.ActionInput,'Fix3') 1938 Param.ActionInput=rmfield(Param.ActionInput,'Fix3'); 1939 end 1940 if isfield(Param.ActionInput,'Patch3') 1941 Param.ActionInput=rmfield(Param.ActionInput,'Patch3'); 1942 end 1943 % if isfield(Param,'OutputSubDir') 1944 % Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series 1945 % end 1946 1911 1947 ParamPatch1=Param.ActionInput.Patch1; %store the patch1 parameters 1912 1948 Param.ActionInput=rmfield(Param.ActionInput,'Patch1');% does not execute Patch 1913 [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results 1949 1950 [Data,errormsg]=stereo_civ(Param);% get the civ1+fix1 results 1914 1951 bckcolor=get(handles.civ_input,'Color'); 1915 1952 set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calculation is finished … … 1921 1958 Param.Civ1_V=Data.Civ1_V; 1922 1959 Param.Civ1_FF=Data.Civ1_FF; 1923 Param=rmfield(Param,'InputTable');%desactivate input file reading 1960 1961 %%%%% modif fonction test %%%%%% 1962 % Param=rmfield(Param,'InputTable');%desactivate input file reading 1963 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1964 1924 1965 if isfield(Param.ActionInput,'Civ1') 1925 1966 Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant … … 1935 1976 for irho=1:7 1936 1977 Param.ActionInput.Patch1.FieldSmooth=SmoothingParam(irho); 1937 [Data,errormsg]= civ_series(Param);%apply the processing fct 1938 if ~isempty(errormsg) 1939 msgbox_uvmat('ERROR',errormsg) 1940 return 1941 end 1978 [Data,errormsg]= stereo_civ(Param);%apply the processing fct 1979 1980 %%%%%%%%%% modif fonction test %%%%%%%%%%%%%% 1981 % if ~isempty(errormsg) 1982 % msgbox_uvmat('ERROR',errormsg) 1983 % return 1984 % end 1985 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1986 1942 1987 ind_good=find(Data.Civ1_FF==0); 1943 1988 Civ1_U_Diff=Data.Civ1_U(ind_good)-Data.Civ1_U_smooth(ind_good); … … 1976 2021 Param.Action.RUN=1; 1977 2022 Param.ActionInput=read_GUI(handles.civ_input); 1978 if isfield(Param,'OutputSubDir') 1979 Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series 2023 2024 if isfield(Param.ActionInput,'Patch2') 2025 Param.ActionInput=rmfield(Param.ActionInput,'Patch2'); 1980 2026 end 2027 if isfield(Param.ActionInput,'Civ3')%remove options that may be selected beyond Patch1 2028 Param.ActionInput=rmfield(Param.ActionInput,'Civ3'); 2029 end 2030 if isfield(Param.ActionInput,'Fix3') 2031 Param.ActionInput=rmfield(Param.ActionInput,'Fix3'); 2032 end 2033 if isfield(Param.ActionInput,'Patch3') 2034 Param.ActionInput=rmfield(Param.ActionInput,'Patch3'); 2035 end 2036 2037 % if isfield(Param,'OutputSubDir') 2038 % Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series 2039 % end 2040 1981 2041 Param.ActionInput.Civ2.CorrSmooth=0;% launch Civ2 with no data point (to get the image names for A and B) 1982 2042 set(handles.Civ1,'BackgroundColor',[1 1 0]) 1983 2043 set(handles.Fix1,'BackgroundColor',[1 1 0]) 1984 2044 set(handles.Patch1,'BackgroundColor',[1 1 0]) 1985 [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results 2045 [Data,errormsg, ~, xmlData]=stereo_civ(Param);% get the civ1+fix1+patch1+civ2+fix2 results 2046 % if ~isempty(errormsg), return, end 1986 2047 1987 2048 %% create image data ImageData for display 1988 2049 ImageData.ListVarName={'ny','nx','A'}; 1989 2050 ImageData.VarDimName= {'ny','nx',{'ny','nx'}}; 1990 ImageData.A=imread(Data.Civ2_ImageA); % read the first image 2051 2052 %%%%%%%%%%%%%%%%% modif fonction test %%%%%%%%%%% 2053 ImageData.VarAttribute{1}.Role='coord_y'; 2054 ImageData.VarAttribute{2}.Role='coord_x'; 2055 ImageData.VarAttribute{3}.Role='scalar'; 2056 2057 A{1}=imread(Data.Civ2_ImageA); % read the first image 2058 A{2}=imread(Data.Civ2_ImageB); % read the first image 2059 2060 phys_img = phys_ima(A,xmlData,1);%transform image A in phys coordinates 2061 ImageData.A = phys_img{1}; 2062 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2063 1991 2064 if ndims(ImageData.A)==3 %case of color image 1992 2065 ImageData.VarDimName= {'ny','nx',{'ny','nx','rgb'}}; … … 2012 2085 % store info in the UserData of view-field 2013 2086 ViewData.CivHandle=handles.civ_input;% indicate the handle of the civ GUI in view_field 2014 ViewData.PlotAxes.B=imread(Data.Civ2_ImageB);%store the second image in the UserData of the GUI view_field 2087 2088 %%%%%%%%%%%% modif fonction test %%%%%%%%%%%%%%%%%%%%%%%%%% 2089 ViewData.PlotAxes.B=phys_img{2};%store the second image in the UserData of the GUI view_field 2090 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2091 2015 2092 ViewData.PlotAxes.X=Data.Civ2_X'; 2016 2093 ViewData.PlotAxes.Y=Data.Civ2_Y'; … … 2038 2115 set(corrfig,'name','image correlation') 2039 2116 set(corrfig,'DeleteFcn',{@closeview_field})% 2040 set(handles.TestCiv 1,'BackgroundColor',[1 0 0])2117 set(handles.TestCiv2,'BackgroundColor',[1 0 0]) 2041 2118 else 2042 set(handles.TestCiv 1,'BackgroundColor',[1 0 0])% paint button to red2119 set(handles.TestCiv2,'BackgroundColor',[1 0 0])% paint button to red 2043 2120 corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display 2044 2121 if ~isempty(corrfig) -
trunk/src/series/test_filter_tps.m
r1157 r1161 284 284 %plot rms difference and proportion of excluded vectors 285 285 figure(2) 286 cl a286 clf 287 287 if CivStage==3% civ1 288 288 ref=0.2; %recommanded value for diff rms -
trunk/src/tps_coeff.m
r1139 r1161 19 19 20 20 % INPUT: 21 % ctrs: NxNbDim matrix representing the positions of the N centers, sources of the tps (NbDim=space dimension )21 % ctrs: NxNbDim matrix representing the positions of the N centers, sources of the tps (NbDim=space dimension, N>=3) 22 22 % U: Nx1 column vector representing the values of the considered scalar measured at the centres ctrs 23 23 % smoothing: smoothing parameter: the result is smoother for larger smoothing. -
trunk/src/uvmat.m
r1154 r1161 2139 2139 [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles); 2140 2140 % detect the file type, get the movie object if relevant, and look for the corresponding file series: 2141 [RootPath,SubDir, RootFile,i1_series,i2_series,j1_series,j2_series,tild,FileInfo,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]);2141 [RootPath,SubDir,~,i1_series,i2_series,j1_series,j2_series,~,FileInfo,MovieObject]=find_file_series(fullfile(RootPath,SubDir),[RootFile FileIndices FileExt]); 2142 2142 if isempty(i1_series) 2143 2143 fileinput=uigetfile_uvmat('pick an input file for the second line',fullfile(RootPath,SubDir)); … … 2154 2154 end 2155 2155 else 2156 % initiate the input file series and inputfilerefresh the current field view:2156 % initiate the input file series and refresh the current field view: 2157 2157 errormsg=update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,2); 2158 2158 end … … 2494 2494 %FileType=FileInfo.FileType; 2495 2495 if isfield(XmlData,'Time')&& ~isempty(XmlData.Time) && ... 2496 (strcmp(FileInfo.FileType,'image')|| strcmp(FileInfo.FileType,'multimage')) %||strcmp(FileType,'civdata')||strcmp(FileType,'civx'))2496 (strcmp(FileInfo.FileType,'image')|| strcmp(FileInfo.FileType,'multimage')) 2497 2497 TimeName='xml'; 2498 2498 elseif strcmp(FileInfo.FieldType,'civdata')% ajouter pivdata_fluidimage … … 3418 3418 3419 3419 %------------------------------------------------------------------------ 3420 % --- Executes on button press in InputFileREFRESH. 3420 % --- Executes on button press in InputFileREFRESH. 3421 3421 function REFRESH_Callback(hObject, eventdata, handles) 3422 3422 %------------------------------------------------------------------------ … … 3470 3470 3471 3471 %% initialisation 3472 errormsg=''; 3472 3473 pointer=get(handles.uvmat,'Pointer'); 3473 3474 if strcmp(pointer,'watch')% reinitialise the mouse if stuck to 'watch' … … 3486 3487 3487 3488 %% determine the main input file information for action 3488 if isempty(regexp(FileName,'^http://' )) &&~exist(FileName,'file')3489 if isempty(regexp(FileName,'^http://', 'once')) &&~exist(FileName,'file') 3489 3490 errormsg=['input file ' FileName ' does not exist']; 3490 3491 return 3491 3492 end 3492 3493 NomType=get(handles.NomType,'String'); 3493 NomType_1='';3494 if strcmp(get(handles.NomType_1,'Visible'),'on')3495 NomType_1=get(handles.NomType_1,'String');3496 end3494 % NomType_1=''; 3495 % if strcmp(get(handles.NomType_1,'Visible'),'on') 3496 % NomType_1=get(handles.NomType_1,'String'); 3497 % end 3497 3498 %update the z position index 3498 3499 mode_slice=get(handles.slices,'String'); … … 3501 3502 set(handles.z_index,'String',num2str(z_index)) 3502 3503 else 3503 nbslice=str2 num(get(handles.num_NbSlice,'String'));3504 nbslice=str2double(get(handles.num_NbSlice,'String')); 3504 3505 z_index=mod(num_i1-1,nbslice)+1; 3505 3506 set(handles.z_index,'String',num2str(z_index)) … … 3556 3557 FieldName= list_fields{get(handles.FieldName,'Value')}; % selected field 3557 3558 if strcmp(FieldName,'get_field...') 3558 FieldName_Callback( hObject, eventdata, handles)3559 FieldName_Callback(get(handles.FieldName), [], handles) 3559 3560 return 3560 3561 else
Note: See TracChangeset
for help on using the changeset viewer.