Changeset 1161


Ignore:
Timestamp:
Jul 19, 2024, 5:57:46 AM (5 months ago)
Author:
sommeria
Message:

filter_tps modified to avoid possible bugs in case of few vectors, subpixel interpolation slightly modified in civ

Location:
trunk/src
Files:
1 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/filter_tps.m

    r1154 r1161  
    1515% coord=[X Y]: matrix whose first column is the x coordinates of the initial data, the second column the y coordiantes
    1616% 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)
    1818% FieldSmooth: smoothing parameter
    19 % Threshold: max diff accepted between smoothed and initial data 
     19% Threshold: max diff accepted between smoothed and initial data
    2020
    2121
     
    4949AspectRatio=Range(2)/Range(1);
    5050NbSubDomain=NbVec/SubDomainSize;% estimated number of subdomains
    51 NbSubDomainX=max(floor(sqrt(NbSubDomain/AspectRatio)),1);% estimated number of subdomains in x 
     51NbSubDomainX=max(floor(sqrt(NbSubDomain/AspectRatio)),1);% estimated number of subdomains in x
    5252NbSubDomainY=max(floor(sqrt(NbSubDomain*AspectRatio)),1);% estimated number of subdomains in y
    5353NbSubDomain=NbSubDomainX*NbSubDomainY;% new estimated number of subdomains in a matrix shape partition in subdomains
     
    7878FF=false(NbVec,1);%false flag=0 (false) by default
    7979nb_select=zeros(NbVec,1);
    80 check_empty=zeros(1,NbSubDomain);
     80check_empty=false(1,NbSubDomain);
    8181
    8282%% calculate tps coeff in each subdomain
     
    8484    SubRange(1,:,isub)=[CentreX(isub)-0.55*Siz(1) CentreX(isub)+0.55*Siz(1)];%bounds of subdomain #isub in x coordinate
    8585    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=[];
    8786    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
    9193        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
    9398        % if no vector in the subdomain  #isub, skip the subdomain
    9499        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
    102111        else
    103112            [U_smooth_sub,U_tps_sub]=tps_coeff(Coord(ind_sel,:),U(ind_sel),smoothing);
     
    109118            if exist('Threshold','var')&&~isempty(Threshold)
    110119                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
    112121            end
    113122            % if no value exceeds threshold, the result is recorded
     123
    114124            if isequal(numel(ind_ind_sel),numel(ind_sel))
    115125                x_width=(SubRange(1,2,isub)-SubRange(1,1,isub))/pi;
     
    128138                display(['tps done with ' num2str(numel(ind_sel)) ' vectors in subdomain # ' num2str(isub)  ' among ' num2str(NbSubDomain)])
    129139                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);
    134146            % else interpolation-smoothing is done again with the selected vectors
    135147            else
     
    153165            end
    154166        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
    155172    end
    156173end
  • trunk/src/get_file_info.m

    r1157 r1161  
    170170                                end
    171171                            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
    173176                                FileInfo.CivStage=Data.CivStage;
    174177                            else
  • trunk/src/proj_field.m

    r1158 r1161  
    17231723                        ProjData.coord_y=coord_y_proj;
    17241724                        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');
    17261726                        ProjData.(VarName)=squeeze(ProjData.(VarName));
    17271727                    end
  • trunk/src/read_civdata.m

    r1153 r1161  
    218218var={};
    219219switch 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',...
    227227            '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',...
    229229            'vector_y_tps','vector_z_tps','ancillary','ancillary','ancillary','ancillary'};
    230230          %  rmq: NbCentres and NbSites obsolete replaced by NbCentre, kept for consistency with previous data
     
    233233    case {'civ2','filter2'}
    234234        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');
    237237end
    238238var=[varout;varin];
    239239if ~strcmp(ProjModeRequest,'interp_tps')
    240     var=var(:,1:9);%suppress tps if not needed
     240    var=var(:,1:8);%suppress tps if not needed
    241241end
    242242vel_type_out=vel_type;
  • trunk/src/script_delete_PCO.m

    r1160 r1161  
    5454                DirPCORaw=dir(TifFolder);
    5555                DirPCORawCells=struct2cell(DirPCORaw);
    56                 CheckTif=regexp(DirPCORAwCells(1,:),'.tif$');
     56                CheckTif=regexp(DirPCORawCells(1,:),'.tif$');
    5757                IndexTif=find(~cellfun('isempty',CheckTif));
    58                 ListTif=DirPCORAwCells(1,IndexTif);
     58                ListTif=DirPCORawCells(1,IndexTif);
    5959                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)
    6464                catch ME
    6565                    disp(ME.message)
     
    6767                end
    6868                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'];
    8089                            List2check=[List2check;PngFolder];
    81                         else
    82                             List2delete=[List2delete;PngFolder];% approve deletion of the source multitif files
    8390                        end
    84                     else
    85                         status=['extraction not finished,' num2str(numel(DirPng)-6) ' images extracted'];
    86                         List2check=[List2check;PngFolder];
    8791                    end
    88                 else
    89                     List2extract=[List2extract;TifFolder];
    9092                end
    9193            end
     
    9395    end
    9496end
    95        
     97
     98
    9699
    97100List2extract
  • trunk/src/script_delete_rdvision.m

    r1160 r1161  
    9797                    catch ME
    9898                        disp(['error in ' filename_seq])
     99                        disp(ME.message)
    99100                    end
    100101                    DirPng=dir(PngFolder);         
  • trunk/src/series.m

    r1156 r1161  
    26152615            set(handles.RUN, 'Enable','On'), set(handles.RUN,'BackgroundColor',[1 0 0]),return,end
    26162616end
     2617num_first_i_Callback(hObject, eventdata, handles)
     2618num_first_j_Callback(hObject, eventdata, handles)
    26172619
    26182620%% enable or desable j index visibility
     
    26202622    enable_j(handles,'off')
    26212623else% show j index if relevant in the input series
     2624    if isfield(SeriesData,'j1_series')
    26222625    j1_series=SeriesData.j1_series;
    26232626    for iview=1:size(j1_series,1)
     
    26262629            break
    26272630        end
     2631    end
    26282632    end
    26292633end
  • trunk/src/series/civ_3D.m

    r1160 r1161  
    314314            return
    315315        end
    316         %for z_index=2:floor((NbSlice-1)/par_civ1.Dz)% loop on slices
     316     % loop on slices
    317317        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.Dz
    319             par_civ1.ImageB=circshift(par_civ1.ImageA,-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);
    320320            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)
    322322                ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(1,ifield),[],j_image_index);%
    323323                A= read_image(ImageName_A,FileType_A);
     
    330330            [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,:,:),...
    331331                Data.Civ1_C(z_index,:,:), Data.Civ1_FF(z_index,:,:), result_conv, errormsg] = civ3D (par_civ1);
    332 
    333332            if ~isempty(errormsg)
    334333                disp_uvmat('ERROR',errormsg,checkrun)
     
    523522            Data.CivStage=4;
    524523        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
    536525        Shiftx=zeros(size(par_civ2.Grid,1),1);% shift expected from civ1 data
    537526        Shifty=zeros(size(par_civ2.Grid,1),1);
    538527        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
    545529        NbSubDomain=size(SubRange,3);
    546530        for isub=1:NbSubDomain% for each sub-domain of Patch1
     
    555539                Shiftx(ind_sel)=Shiftx(ind_sel)+EM*U_tps(1:nbvec_sub+3,isub);%velocity shift estimated by tps from civ1
    556540                Shifty(ind_sel)=Shifty(ind_sel)+EM*V_tps(1:nbvec_sub+3,isub);
    557                 if par_civ2.CheckDeformation
    558                     [EMDX,EMDY] = tps_eval_dxy(epoints,ctrs);%2D matrix of distances between extrapolation points epoints and spline centres (=site points) ctrs
    559                     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                 end
    564541            end
    565542        end
     
    924901                        correl_xy=conv2(subima2,flip(flip(subima1,2),1),'valid');
    925902                        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 errors
     903                        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
    928905                    end
    929906                    [corrmax,dz]=max(max_xy);
     
    990967FF=false;
    991968peakz=z;peaky=y;peakx=x;
    992 % if z < npz && z > 1 && y < npy && y > 1 && x < npx && x > 1
    993 %     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 % else
    1006 %     FF=true;
    1007 % end
     969if 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);
     982else
     983    FF=true;
     984end
    1008985
    1009986vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1 peakz-floor(npz/2)-1];
  • trunk/src/series/civ_input.m

    r1156 r1161  
    132132                    [~,~,~,~,~,~,~,~,NomTypeImaA]=fileparts_uvmat(Data.Civ1_ImageA);
    133133       % [~,~,~,~,~,~,~,~,NomTypeImaB]=fileparts_uvmat(Data.Civ1_ImageB);
    134              else
     134             elseif isfield(Data,'Civ2_ImageA')
    135135                 series('display_file_name',hhseries,Data.Civ2_ImageA,'append');%append the image series to the input list
    136136                         [~,~,~,~,~,~,~,~,NomTypeImaA]=fileparts_uvmat(Data.Civ2_ImageA);
     
    415415%% Civ1 parameters
    416416%Param.CheckCiv1=1;
    417 Param.Civ1.CorrBoxSize=[25 25 1];
    418 Param.Civ1.SearchBoxSize=[55 55 5];
     417Param.Civ1.CorrBoxSize=[31 31 1];
     418Param.Civ1.SearchBoxSize=[61 61 5];
    419419Param.Civ1.SearchBoxShift=[0 0];
    420420Param.Civ1.CorrSmooth=1;
     
    432432%% Patch1 parameters
    433433%Param.CheckPatch1=1;
    434 Param.Patch1.FieldSmooth=20;
    435 Param.Patch1.MaxDiff=2;
     434Param.Patch1.FieldSmooth=200;
     435Param.Patch1.MaxDiff=1.5;
    436436Param.Patch1.SubDomainSize=125;
    437437
     
    452452
    453453%% Patch2 parameters
    454 Param.Patch2.FieldSmooth=5;
    455 Param.Patch2.MaxDiff=1.5000;
     454Param.Patch2.FieldSmooth=20;
     455Param.Patch2.MaxDiff=1;
    456456Param.Patch2.SubDomainSize=250;
    457 Param.Patch2.TestPatch2=0;
    458457
    459458fill_GUI(Param,handles.civ_input)% fill the elements of the GUI series with the input parameters
     
    706705    end 
    707706    mode_value=get(handles.ListPairMode,'Value');
    708     if isempty(mode_value)
     707    if isempty(mode_value)|| mode_value>numel(mode_list)
    709708        mode_value=1;
    710709    end
     
    835834    mode_list=get(handles.ListPairMode,'String');
    836835    mode_value=get(handles.ListPairMode,'Value');
    837     if isempty(mode_value)
     836    if isempty(mode_value)||mode_value>numel(mode_list)
    838837        mode_value=1;
    839838    end
  • trunk/src/series/civ_series.m

    r1160 r1161  
    10521052    par_civ.CorrSmooth=2;% use SUBPIX2DGAUSS (take into account more points near the max)
    10531053end
    1054 
     1054 
    10551055if par_civ.CorrSmooth~=0 % par_civ.CorrSmooth=0 implies no civ computation (just input image and grid points given)
    10561056    for ivec=1:nbvec
     
    11301130                %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    11311131                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
    11331134                %Find the correlation max, at 255
    1134                 [y,x] = find(result_conv==255,1);
     1135                [y,x] = find(result_conv==corrmax,1);
    11351136                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
    11361137                sum_square=sum_square*sum(sum(subimage2_crop.*subimage2_crop));% product of variances of image 1 and 2
     
    11691170    end
    11701171end
    1171 result_conv=result_conv*corrmax/(255*sum_square);% keep the last correlation matrix for output
     1172result_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
     1185function [vector,FF] = SUBPIXGAUSS (result_conv,x,y)
     1186%------------------------------------------------------------------------
     1187% vector=[0 0]; %default
     1188FF=true;% error flag for vector truncated by the limited search box
     1189[npy,npx]=size(result_conv);
     1190
     1191peaky = y; peakx=x;
     1192if 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);
     1206end
     1207
     1208vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1];
    11721209
    11731210%------------------------------------------------------------------------
    11741211% --- 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)
     1212function [vector,FF] = SUBPIX2DGAUSS (result_conv,x,y)
    11831213%------------------------------------------------------------------------
    11841214% 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;
     1215FF=true;
    12111216peaky=y;
    12121217peakx=x;
    1213 result_conv(result_conv<1)=1; %set to 1 correlation values smaller than 1 (to avoid divergence in the log)
    12141218[npy,npx]=size(result_conv);
    12151219if (x < npx) && (y < npy) && (x > 1) && (y > 1)
    1216     F=0;
     1220    FF=false;
     1221max_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)
    12171225    for i=-1:1
    12181226        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
    12251232            c10(j+2,i+2)=i*log(result_conv(y+j, x+i));
    12261233            c01(j+2,i+2)=j*log(result_conv(y+j, x+i));
     
    12351242    c20=(1/6)*sum(sum(c20));
    12361243    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);
    12391246    if abs(deltax)<1
    12401247        peakx=x+deltax;
  • trunk/src/series/extract_rdvision.m

    r1149 r1161  
    122122    if exist(filexml,'file')
    123123        [XmlData,errormsg]=imadoc2struct(filexml);
    124         if ~isempty(errormsg)
     124        if isempty(errormsg)
     125            msgbox_uvmat('CONFIRMATION',[filexml ' used' ]);
     126        else
    125127            msgbox_uvmat('ERROR',errormsg);
    126128            return
  • trunk/src/series/stereo_civ.m

    r1152 r1161  
    3838%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    3939
    40 function [Data,errormsg,result_conv]= stereo_civ(Param)
     40function [Data,errormsg,result_conv, XmlData]= stereo_civ(Param)
    4141Data=[];
    4242errormsg='';
     
    8585WaitbarHandle=findobj(hseries,'Tag','Waitbar');%handle of waitbar in GUI series
    8686
     87%%%%%%%%%%%%%%%% Modif pour test %%%%%%%%%%%%%%%%%%
     88% CheckInputFile=isfield(Param,'InputTable');%= 1 in test use for TestCiv (no nc file involved)
     89CheckOutputFile = isfield(Param,'OutputSubDir') ; %= 1 in test use for TestPatch (no nc file produced)
     90%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     91
    8792%% input files and indexing
    8893MaxIndex_i=Param.IndexRange.MaxIndex_i;
     
    95100time=[];
    96101for 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});
    97103    XmlFileName=find_imadoc(Param.InputTable{iview,1},Param.InputTable{iview,2});
    98104    if isempty(XmlFileName)
     
    235241
    236242%% Output directory
    237 OutputDir=[Param.OutputSubDir Param.OutputDirExt];
     243OutputDir='/Test';
     244if CheckOutputFile
     245    OutputDir=[Param.OutputSubDir Param.OutputDirExt];
     246end
     247
    238248
    239249ListGlobalAttribute={'Conventions','Program','CivStage'};
     
    252262end
    253263if 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');
    256266    time=(1:MaxIndex_i)'*ones(1,MaxIndex_j);
    257267    time=[zeros(1,MaxIndex_j);time];% insert a first line of zeros
     
    312322
    313323       
    314         [A,Rangx,Rangy]=phys_ima(A,XmlData,1);
     324        [A,Rangx,Rangy]=phys_ima(A,XmlData,1);%transform image A in phys coordinates
    315325        [Npy,Npx]=size(A{1});
    316326        PhysImageA=fullfile_uvmat(RootPath_A,Civ1Dir,RootFile_A,'.png','_1a',i1_series_Civ1(ifield),[],1);
     
    372382        Data.Civ1_F=reshape(F,[],1);
    373383
     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
    374398    end
    375399   
     
    414438            return
    415439        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           
    418450        Data.Patch1_FieldSmooth=Param.ActionInput.Patch1.FieldSmooth;
    419451        Data.Patch1_MaxDiff=Param.ActionInput.Patch1.MaxDiff;
    420452        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       
    425476        Data.VarAttribute{nbvar+1}.Role='vector_x';
    426477        Data.VarAttribute{nbvar+2}.Role='vector_y';
     
    436487        end
    437488        [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           
    439491        Data.Civ1_U_smooth(ind_good)=Ures;
    440492        Data.Civ1_V_smooth(ind_good)=Vres;
    441493        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
    443530               
    444531    end
     532
     533   
     534   
    445535   
    446536    %% Civ2
     
    553643        Data.Civ2_F=reshape(F,[],1);
    554644        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        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    555659    end
    556660   
     
    612716        Data.Civ2_FF(ind_good)=FFres;
    613717        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
    614732    end
    615733   
     
    769887        Data.CivStage=Data.CivStage+1;
    770888           
    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
    777895        if ~isempty(errormsg)
    778896            disp_uvmat('ERROR',errormsg,checkrun)
     
    784902   
    785903    %% write result in a netcdf file if requested
     904
    786905    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);
    789908            if isempty(errormsg)
    790                 disp([ncfile ' written'])
     909                disp([ncfile2 ' written'])
    791910            else
    792911                disp(errormsg)
     
    794913        end
    795914    else
     915       
     916       
    796917       % store only phys data
    797         Data_light.ListVarName={'Xphys','Yphys','Zphys','Civ3_C','DX','DY','Error'};
     918        Data_light.ListVarName={'Xphys','Yphys','Zphys','Civ_C','DX','DY','Error'};
    798919        Data_light.VarDimName={'nb_vec_3','nb_vec_3','nb_vec_3','nb_vec_3','nb_vec_3','nb_vec_3','nb_vec_3'};
    799920        Data_light.VarAttribute{1}.Role='coord_x';
     
    802923         Data_light.VarAttribute{5}.Role='vector_x';
    803924         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
    812967       if exist('ncfile2','var')
    813968            errormsg=struct2nc(ncfile2,Data_light);
     
    827982end
    828983
    829 
     984end
    830985
    831986% 'civ': function piv.m adapted from PIVlab http://pivlab.blogspot.com/
     
    10681223end
    10691224result_conv=result_conv*corrmax/(255*sum_square);% keep the last correlation matrix for output
     1225end
    10701226
    10711227%------------------------------------------------------------------------
     
    10981254end
    10991255vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1];
     1256end
    11001257
    11011258%------------------------------------------------------------------------
     
    11411298end
    11421299vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1];
     1300end
    11431301
    11441302%'RUN_FIX': function for fixing velocity fields:
     
    11891347end
    11901348
     1349end
    11911350
    11921351%------------------------------------------------------------------------
     
    12501409        j2_series=ind2*ones(1,size(i_series,2));
    12511410        check_bounds=zeros(size(i1_series));% no limitations due to min-max indices
     1411    end
    12521412end
    12531413
     
    12581418% ymid+ v/2: set of apparent phys y coordinates in the ref plane, image B
    12591419% XmlData: content of the xml files containing geometric calibration parameters
     1420
     1421
    12601422function [z,Xphy,Yphy,Error]=shift2z(xmid, ymid, u, v,XmlData)
    12611423z=0;
     
    13201482Xphy=mean(xnew,1);
    13211483Yphy=mean(ynew,1);
    1322 
    1323 
    1324 
    1325 
    1326 
     1484end
     1485
     1486function [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
     1497end
  • trunk/src/series/stereo_input.m

    r1129 r1161  
    17971797set(handles.configSource,'String','NEW')
    17981798set(handles.OK,'BackgroundColor',[1 0 1])
     1799
     1800
    17991801%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    18001802%%%%%%%%%%%%%%   TEST functions
     
    18141816     Param.Action.RUN=1;
    18151817     Param.ActionInput=read_GUI(handles.civ_input);
    1816      if isfield(Param.ActionInput,'Fix1')
    1817          Param.ActionInput=rmfield(Param.ActionInput,'Fix1');
    1818      end
     1818
    18191819     if isfield(Param.ActionInput,'Patch1')
    18201820         Param.ActionInput=rmfield(Param.ActionInput,'Patch1');
     
    18291829         Param.ActionInput=rmfield(Param.ActionInput,'Patch2');
    18301830     end
    1831      if isfield(Param,'OutputSubDir')
    1832      Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series
     1831     if isfield(Param.ActionInput,'Civ3')%remove options that may be selected beyond Patch1
     1832         Param.ActionInput=rmfield(Param.ActionInput,'Civ3');
    18331833     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
    18341843     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 results
    1836      if ~isempty(errormsg), return, end % rmq: error msg displayed in civ_series
     1844     [Data,errormsg, ~, xmlData]=stereo_civ(Param);% get the civ1+fix1 results
     1845     % if ~isempty(errormsg), return, end % rmq: error msg displayed in civ_series
    18371846     
    18381847 %% create image data ImageData for display
    18391848     ImageData.ListVarName={'ny','nx','A'};
    18401849     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
    18421863     if ndims(ImageData.A)==3 %case of color image
    18431864         ImageData.VarDimName= {'ny','nx',{'ny','nx','rgb'}};
     
    18561877     ViewData.PlotAxes.X=Data.Civ1_X';
    18571878     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
    18591884     set(hview_field,'UserData',ViewData)% store the info in the UserData of image view_field
    18601885   
     
    18971922     Param.Action.RUN=1;
    18981923     Param.ActionInput=read_GUI(handles.civ_input);
     1924
    18991925     if isfield(Param.ActionInput,'Civ2')%remove options that may be selected beyond Patch1
    19001926         Param.ActionInput=rmfield(Param.ActionInput,'Civ2');
     
    19061932         Param.ActionInput=rmfield(Param.ActionInput,'Patch2');
    19071933     end
    1908      if isfield(Param,'OutputSubDir')
    1909      Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series
     1934     if isfield(Param.ActionInput,'Civ3')%remove options that may be selected beyond Patch1
     1935         Param.ActionInput=rmfield(Param.ActionInput,'Civ3');
    19101936     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
    19111947     ParamPatch1=Param.ActionInput.Patch1; %store the patch1 parameters
    19121948     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
    19141951     bckcolor=get(handles.civ_input,'Color');
    19151952     set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calculation is finished
     
    19211958     Param.Civ1_V=Data.Civ1_V;
    19221959     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
    19241965    if isfield(Param.ActionInput,'Civ1')
    19251966        Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant
     
    19351976    for irho=1:7
    19361977        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
    19421987        ind_good=find(Data.Civ1_FF==0);
    19431988        Civ1_U_Diff=Data.Civ1_U(ind_good)-Data.Civ1_U_smooth(ind_good);
     
    19762021     Param.Action.RUN=1;
    19772022     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');
    19802026     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
    19812041     Param.ActionInput.Civ2.CorrSmooth=0;% launch Civ2 with no data point (to get the image names for A and B)
    19822042     set(handles.Civ1,'BackgroundColor',[1 1 0])
    19832043     set(handles.Fix1,'BackgroundColor',[1 1 0])
    19842044     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
    19862047     
    19872048     %% create image data ImageData for display
    19882049     ImageData.ListVarName={'ny','nx','A'};
    19892050     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
    19912064     if ndims(ImageData.A)==3 %case of color image
    19922065         ImageData.VarDimName= {'ny','nx',{'ny','nx','rgb'}};
     
    20122085    % store info in the UserData of view-field
    20132086    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   
    20152092    ViewData.PlotAxes.X=Data.Civ2_X';
    20162093    ViewData.PlotAxes.Y=Data.Civ2_Y';
     
    20382115        set(corrfig,'name','image correlation')
    20392116        set(corrfig,'DeleteFcn',{@closeview_field})%
    2040         set(handles.TestCiv1,'BackgroundColor',[1 0 0])
     2117        set(handles.TestCiv2,'BackgroundColor',[1 0 0])
    20412118    else
    2042         set(handles.TestCiv1,'BackgroundColor',[1 0 0])% paint button to red
     2119        set(handles.TestCiv2,'BackgroundColor',[1 0 0])% paint button to red
    20432120        corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
    20442121        if ~isempty(corrfig)
  • trunk/src/series/test_filter_tps.m

    r1157 r1161  
    284284%plot rms difference and proportion of excluded vectors
    285285figure(2)
    286 cla
     286clf
    287287if CivStage==3% civ1
    288288    ref=0.2; %recommanded value for diff rms
  • trunk/src/tps_coeff.m

    r1139 r1161  
    1919
    2020% 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)
    2222%  U: Nx1 column vector representing the values of the considered scalar measured at the centres ctrs
    2323%  smoothing: smoothing parameter: the result is smoother for larger smoothing.
  • trunk/src/uvmat.m

    r1154 r1161  
    21392139    [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles);
    21402140    % 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]);
    21422142    if isempty(i1_series)
    21432143        fileinput=uigetfile_uvmat('pick an input file for the second line',fullfile(RootPath,SubDir));
     
    21542154        end
    21552155    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:
    21572157        errormsg=update_rootinfo(handles,i1_series,i2_series,j1_series,j2_series,FileInfo,MovieObject,2);
    21582158    end
     
    24942494%FileType=FileInfo.FileType;
    24952495if 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'))
    24972497    TimeName='xml';
    24982498elseif strcmp(FileInfo.FieldType,'civdata')% ajouter pivdata_fluidimage
     
    34183418
    34193419%------------------------------------------------------------------------
    3420 % --- Executes on button press in InputFileREFRESH.
     3420% --- Executes on button press in InputFileREFRESH. 
    34213421function REFRESH_Callback(hObject, eventdata, handles)
    34223422%------------------------------------------------------------------------
     
    34703470
    34713471%% initialisation
     3472errormsg='';
    34723473pointer=get(handles.uvmat,'Pointer');
    34733474if strcmp(pointer,'watch')% reinitialise the mouse if stuck to 'watch'
     
    34863487
    34873488%% determine the main input file information for action
    3488 if isempty(regexp(FileName,'^http://')) &&~exist(FileName,'file')
     3489if isempty(regexp(FileName,'^http://', 'once')) &&~exist(FileName,'file')
    34893490    errormsg=['input file ' FileName ' does not exist'];
    34903491    return
    34913492end
    34923493NomType=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 end
     3494% NomType_1='';
     3495% if strcmp(get(handles.NomType_1,'Visible'),'on')
     3496%     NomType_1=get(handles.NomType_1,'String');
     3497% end
    34973498%update the z position index
    34983499mode_slice=get(handles.slices,'String');
     
    35013502    set(handles.z_index,'String',num2str(z_index))
    35023503else
    3503     nbslice=str2num(get(handles.num_NbSlice,'String'));
     3504    nbslice=str2double(get(handles.num_NbSlice,'String'));
    35043505    z_index=mod(num_i1-1,nbslice)+1;
    35053506    set(handles.z_index,'String',num2str(z_index))
     
    35563557        FieldName= list_fields{get(handles.FieldName,'Value')}; % selected field
    35573558        if strcmp(FieldName,'get_field...')
    3558             FieldName_Callback(hObject, eventdata, handles)
     3559            FieldName_Callback(get(handles.FieldName), [], handles)
    35593560            return
    35603561        else
Note: See TracChangeset for help on using the changeset viewer.