Changeset 927 for trunk/src


Ignore:
Timestamp:
Feb 24, 2016, 7:39:00 PM (9 years ago)
Author:
sommeria
Message:

'new'

Location:
trunk/src/series
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series/civ2vel_3C.m

    r924 r927  
    3434
    3535%=======================================================================
    36 % Copyright 2008-2016, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
     36% Copyright 2008-2015, LEGI UMR 5519 / CNRS UJF G-INP, Grenoble, France
    3737%   http://www.legi.grenoble-inp.fr
    3838%   Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
     
    5252
    5353function ParamOut=civ2vel_3C(Param)
    54 
     54disp('test')
    5555%% set the input elements needed on the GUI series when the function is selected in the menu ActionName or InputTable refreshed
    5656if isstruct(Param) && isequal(Param.Action.RUN,0)
     
    6868    ParamOut.OutputFileMode='NbInput';% '=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice
    6969    %check the input files
     70    ParamOut.CheckOverwriteVisible='on'; % manage the overwrite of existing files (default=1)
    7071    first_j=[];
    7172    if size(Param.InputTable,1)<2
     
    170171warning off
    171172
     173CheckOverwrite=1;%default
     174if isfield(Param,'CheckOverwrite')
     175    CheckOverwrite=Param.CheckOverwrite;
     176end
    172177for index=1:NbField
     178   
    173179    update_waitbar(WaitbarHandle,index/NbField)
     180   
     181   
     182   
     183   
     184      %% generating the name of the merged field
     185    i1=i1_series{1}(index);
     186    if ~isempty(i2_series{end})
     187        i2=i2_series{end}(index);
     188    else
     189        i2=i1;
     190    end
     191    j1=1;
     192    j2=1;
     193    if ~isempty(j1_series{1})
     194        j1=j1_series{1}(index);
     195        if ~isempty(j2_series{end})
     196            j2=j2_series{end}(index);
     197        else
     198            j2=j1;
     199        end
     200    end
     201    OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},'.nc','_1-2',i1,i2,j1,j2);
     202   
     203    %%
     204   
     205   
    174206    if ~isempty(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue')
    175207        disp('program stopped by user')
     
    177209    end
    178210   
     211     if (~CheckOverwrite && exist(OutputFile,'file')) 
     212            disp('existing output file already exists, skip to next field')
     213            continue% skip iteration if the mode overwrite is desactivated and the result file already exists
     214     end   
     215     
    179216    %%%%%%%%%%%%%%%% loop on views (input lines) %%%%%%%%%%%%%%%%
    180217    Data=cell(1,NbView);%initiate the set Data
     
    185222   clear ZItemp
    186223   ZItemp=zeros(size(XI,1),size(XI,2),2);
     224   
     225   if index==1
     226        first_img=i1_series{1,1}(1,1); %id of the first image of the series
     227   end
     228     
     229     idtemp=0;
    187230 for indextemp=index:index+1;
     231     idtemp=idtemp+1;
    188232    if NbView==3 % if there is only 1 stereo folder, extract directly Xphys,Yphys and Zphys
    189        
    190         [Data{3},tild,errormsg] = nc2struct([Param.InputTable{3,1},'/',Param.InputTable{3,2},'/',Param.InputTable{3,3},'_',int2str(indextemp),'.nc']);
    191        
     233     
     234       
     235       
     236        [Data{3},tild,errormsg] = nc2struct([Param.InputTable{3,1},'/',Param.InputTable{3,2},'/',Param.InputTable{3,3},'_',int2str(first_img+indextemp-1),'.nc']);
    192237       
    193238        if  exist('Data{3}.Civ3_FF','var') % FF is present, remove wrong vector
     
    219264        end
    220265       
    221         [Data{3},tild,errormsg] = nc2struct([Param.InputTable{3,1},'/',Param.InputTable{3,2},'/',Param.InputTable{3,3},'_',int2str(indextemp),'.nc']);
     266   
     267       
     268        [Data{3},tild,errormsg] = nc2struct([Param.InputTable{3,1},'/',Param.InputTable{3,2},'/',Param.InputTable{3,3},'_',int2str(first_img+indextemp-1),'.nc']);
     269   
    222270        if exist('Data{3}.Civ3_FF','var') % if FF is present, remove wrong vector
    223271            temp=find(Data{3}.Civ3_FF==0);
     
    241289       
    242290       
    243         [Data{4},tild,errormsg] = nc2struct([Param.InputTable{4,1},'/',Param.InputTable{4,2},'/',Param.InputTable{4,3},'_',int2str(indextemp),'.nc']);
     291
     292         [Data{4},tild,errormsg] = nc2struct([Param.InputTable{4,1},'/',Param.InputTable{4,2},'/',Param.InputTable{4,3},'_',int2str(first_img+indextemp-1),'.nc']);
    244293        if exist('Data{4}.Civ3_FF','var') % if FF is present, remove wrong vector
    245294            temp=find(Data{4}.Civ3_FF==0);
     
    279328   
    280329   
    281        ZItemp(:,:,indextemp)=griddata(Xphys,Yphys,Zphys,XI,YI); %interpolation on the choosen gridd
     330       ZItemp(:,:,idtemp)=griddata(Xphys,Yphys,Zphys,XI,YI); %interpolation on the choosen gridd
    282331   
    283332end
     
    320369    Va=griddata(X1,Y1,V1,Xa,Ya);
    321370   
    322     [Ua,Va,Xa,Ya]=Ud2U(XmlData{1}.GeometryCalib,Xa,Ya,Ua,Va); % convert Xd data to X
     371%     [Ua,Va,Xa,Ya]=Ud2U(XmlData{1}.GeometryCalib,Xa,Ya,Ua,Va); % convert Xd data to X
    323372    [A]=get_coeff(XmlData{1}.GeometryCalib,Xa,Ya,XI,YI,ZI); %get coef A~
    324373   
     
    332381    Vb=griddata(X2,Y2,V2,Xb,Yb);
    333382
    334     [Ub,Vb,Xb,Yb]=Ud2U(XmlData{2}.GeometryCalib,Xb,Yb,Ub,Vb); % convert Xd data to X
     383%     [Ub,Vb,Xb,Yb]=Ud2U(XmlData{2}.GeometryCalib,Xb,Yb,Ub,Vb); % convert Xd data to X
    335384    [B]=get_coeff(XmlData{2}.GeometryCalib,Xb,Yb,XI,YI,ZI); %get coef B~
    336385   
     
    369418
    370419   
    371     %% generating the name of the merged field
    372     i1=i1_series{1}(index);
    373     if ~isempty(i2_series{end})
    374         i2=i2_series{end}(index);
    375     else
    376         i2=i1;
    377     end
    378     j1=1;
    379     j2=1;
    380     if ~isempty(j1_series{1})
    381         j1=j1_series{1}(index);
    382         if ~isempty(j2_series{end})
    383             j2=j2_series{end}(index);
    384         else
    385             j2=j1;
    386         end
    387     end
    388     OutputFile=fullfile_uvmat(RootPath{1},OutputDir,RootFile{1},'.nc','_1-2',i1,i2,j1,j2);
     420 
    389421   
    390422    %% recording the merged field
     
    399431        MergeData.coord_x=xI;
    400432        MergeData.coord_y=yI;
    401         MergeData.Z=ZI;
    402433    end
    403434    MergeData.U=U/Dt;
    404435    MergeData.V=V/Dt;
    405436    MergeData.W=W/Dt;
    406    
    407     mfx=(XmlData{1}.GeometryCalib.fx_fy(1)+XmlData{2}.GeometryCalib.fx_fy(1))/2;
    408     mfy=(XmlData{1}.GeometryCalib.fx_fy(2)+XmlData{2}.GeometryCalib.fx_fy(2))/2;
    409     MergeData.Error=(sqrt(mfx^2+mfy^2)/4).*sqrt(sum(Error.*Error,3));
     437    MergeData.Z=ZI;
     438   
     439%     mfx=(XmlData{1}.GeometryCalib.fx_fy(1)+XmlData{2}.GeometryCalib.fx_fy(1))/2;
     440%     mfy=(XmlData{1}.GeometryCalib.fx_fy(2)+XmlData{2}.GeometryCalib.fx_fy(2))/2;
     441    MergeData.Error=0.5*sqrt(sum(Error.^2,3));
    410442    errormsg=struct2nc(OutputFile,MergeData);%save result file
    411443    if isempty(errormsg)
     
    496528%% result
    497529Den=(Dxb-Dxa).*(Dxb-Dxa)+(Dyb-Dya).*(Dyb-Dya);
    498 error=((Dyb-Dya).*(-u)-(Dxb-Dxa).*(-v))./Den;
     530error=abs(((Dyb-Dya).*(-u)-(Dxb-Dxa).*(-v)))./Den;
    499531% ex=-error.*(Dyb-Dya);
    500532% ey=-error.*(Dxb-Dxa);
  • trunk/src/series/stereo_civ.m

    r924 r927  
    2121%     .Patch2:
    2222% ncfile: name of a netcdf file to be created for the result (extension .nc)
    23 
    24 %=======================================================================
    25 % Copyright 2008-2016, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
    26 %   http://www.legi.grenoble-inp.fr
    27 %   Joel.Sommeria - Joel.Sommeria (A) legi.cnrs.fr
    2823%
    29 %     This file is part of the toolbox UVMAT.
    30 %
     24%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
     25%  Copyright 2011-2015, LEGI / CNRS UJF G-INP, Joel.Sommeria@legi.grenoble-inp.fr
     26%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
     27%     This is part of the toolbox UVMAT.
     28%
    3129%     UVMAT is free software; you can redistribute it and/or modify
    32 %     it under the terms of the GNU General Public License as published
    33 %     by the Free Software Foundation; either version 2 of the license,
    34 %     or (at your option) any later version.
    35 %
     30%     it under the terms of the GNU General Public License as published by
     31%     the Free Software Foundation; either version 2 of the License, or
     32%     (at your option) any later version.
     33% 
    3634%     UVMAT is distributed in the hope that it will be useful,
    3735%     but WITHOUT ANY WARRANTY; without even the implied warranty of
    3836%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    39 %     GNU General Public License (see LICENSE.txt) for more details.
    40 %=======================================================================
     37%     GNU General Public License (open UVMAT/COPYING.txt) for more details.
     38%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    4139
    4240function [Data,errormsg,result_conv]= stereo_civ(Param)
     
    6765    Data.OutputSubDirMode='auto'; %select the last subDir in the input table as root of the output subdir name (option 'all'/'first'/'last', 'all' by default)
    6866    Data.OutputFileMode='NbInput_i';% one output file expected per value of i index (used for waitbar)
     67    Data.CheckOverwriteVisible='on'; % manage the overwrite of existing files (default=1)
     68
    6969    return
    7070end
     
    168168end
    169169if isempty(i1_series_Civ1)||(~isempty(PairCiv2) && isempty(i1_series_Civ2))
    170     disp_uvmat('ERROR','no image pair fo civ in the input file index range',checkrun)
     170    disp_uvmat('ERROR','no image pair for civ in the input file index range',checkrun)
    171171    return
    172172end
     
    265265tic
    266266%%%%% MAIN LOOP %%%%%%
     267CheckOverwrite=1;%default
     268if isfield(Param,'CheckOverwrite')
     269    CheckOverwrite=Param.CheckOverwrite;
     270end
     271
    267272for ifield=1:NbField
    268273    update_waitbar(WaitbarHandle,ifield/NbField)
     
    282287        ncfile2=fullfile_uvmat(RootPath_A,Civ1Dir,[RootFile_A,'_Light'],'.nc',NomTypeNc,i2_series_Civ1(ifield),[],...
    283288            j1_series_Civ1(ifield),j2_series_Civ1(ifield));
     289       
     290     if (~CheckOverwrite && exist(ncfile,'file')) || (~CheckOverwrite && exist(ncfile2,'file'))
     291            disp('existing output file already exists, skip to next field')
     292            result_conv=0;
     293            continue% skip iteration if the mode overwrite is desactivated and the result file already exists
     294     end   
     295   
    284296       
    285297    %% Civ1
     
    845857       
    846858    end
    847    end
    848 
    849   disp(['ellapsed time for the loop ' num2str(toc) ' s'])
     859end
     860disp(['ellapsed time for the loop ' num2str(toc) ' s'])
     861tic
     862while toc < rand(1)*10
     863    for i = 1:100000, sqrt(1237); end
     864end
    850865
    851866
     
    10991114[npy,npx]=size(result_conv);
    11001115result_conv(result_conv<1)=1; %set to 1 correlation values smaller than 1 (to avoid divergence in the log)
    1101 %the following 8 lines are copyright (c) 1998, Uri Shavit, Roi Gurka, Alex Liberzon, Technion ï¿œ Israel Institute of Technology
     1116%the following 8 lines are copyright (c) 1998, Uri Shavit, Roi Gurka, Alex Liberzon, Technion ??? Israel Institute of Technology
    11021117%http://urapiv.wordpress.com
    11031118peaky = y;
     
    11361151        for j=-1:1
    11371152            %following 15 lines based on
    1138             %H. Nobach ï¿œ M. Honkanen (2005)
     1153            %H. Nobach ??? M. Honkanen (2005)
    11391154            %Two-dimensional Gaussian regression for sub-pixel displacement
    11401155            %estimation in particle image velocimetry or particle position
    11411156            %estimation in particle tracking velocimetry
    1142             %Experiments in Fluids (2005) 38: 511ï¿œ515
     1157            %Experiments in Fluids (2005) 38: 511???515
    11431158            c10(j+2,i+2)=i*log(result_conv(y+j, x+i));
    11441159            c01(j+2,i+2)=j*log(result_conv(y+j, x+i));
Note: See TracChangeset for help on using the changeset viewer.