Ignore:
Timestamp:
May 9, 2024, 6:51:30 PM (5 months ago)
Author:
sommeria
Message:

new display of false vectors

File:
1 edited

Legend:

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

    r1137 r1143  
    22% --- call the sub-functions:
    33%   civ: PIV function itself
    4 %   fix: removes false vectors after detection by various criteria
     4%   detect_false: put a flag to false vectors after detection by various criteria
    55%   filter_tps: make interpolation-smoothing
    66%------------------------------------------------------------------------
     
    2222%     Param.ActionInput: substructure with the parameters provided by the GUI civ_input
    2323%                      .Civ1: parameters for civ1cc
    24 %                      .Fix1: parameters for fix1
     24%                      .Fix1: parameters for detect_false1
    2525%                      .Patch1:
    2626%                      .Civ2: for civ2
     
    131131            iview_A=2;% the second line is used for the input images of Civ2
    132132        end
    133 %         if strcmp(Param.ActionInput.ListCompareMode,'shift')
    134 %             iview_B=iview_A+1; % the second image series is on the next line of the input table
    135 %         end
    136133        if iview_A~=0
    137134            RootPath_A=Param.InputTable{iview_A,1};
     
    237234            NbField=numel(i1_series_Civ2);
    238235        else
    239             NbField=numel(i1_series_Civ1);% no image used (only fix or patch) TO CHECK
     236            NbField=numel(i1_series_Civ1);% no image used (only detect_false or patch) TO CHECK
    240237        end
    241238
     
    347344    ImageName_A='';ImageName_B='';%default
    348345    VideoObject_A=[];VideoObject_B=[];
     346   
    349347    %% Civ1
    350348    % if Civ1 computation is requested
     
    544542    %% Fix1
    545543    if isfield (Param.ActionInput,'Fix1')
    546         disp('fix1 started')
     544        disp('detect_false1 started')
    547545        if ~isfield (Param.ActionInput,'Civ1')% if we use existing Civ1, remove previous data beyond Civ1
    548546            Fix1_attr=find(strcmp('Fix1',Data.ListGlobalAttribute));
     
    563561        nbvar=length(Data.ListVarName);
    564562        Data.VarAttribute{nbvar}.Role='errorflag';
    565         Data.Civ1_FF=int8(fix(Param.ActionInput.Fix1,Data.Civ1_F,Data.Civ1_C,Data.Civ1_U,Data.Civ1_V));
     563        Data.Civ1_FF=int8(detect_false(Param.ActionInput.Fix1,Data.Civ1_F,Data.Civ1_C,Data.Civ1_U,Data.Civ1_V));
    566564        Data.CivStage=2;
    567565    end
     
    823821        if exist('ncfile','var')
    824822            CivFile=ncfile;
    825             [Data,tild,tild,errormsg]=nc2struct(CivFile);%read civ1 and fix1 data in the existing netcdf file
     823            [Data,tild,tild,errormsg]=nc2struct(CivFile);%read civ1 and detect_false1 data in the existing netcdf file
    826824            if ~isempty(errormsg)
    827825                disp_uvmat('ERROR',errormsg,checkrun)
     
    842840    %% Fix2
    843841    if isfield (Param.ActionInput,'Fix2')
    844         disp('fix2 started')
     842        disp('detect_false2 started')
    845843        list_param=fieldnames(Param.ActionInput.Fix2)';
    846844        Fix2_param=regexprep(list_param,'^.+','Fix2_$0');% insert 'Fix1_' before  each string in ListFixParam
     
    857855                Data.VarDimName=[Data.VarDimName {'nb_vectors2'}];
    858856            end
    859             Data.vec_FixFlag=fix(Param.Fix2,Data.vec2_F,Data.vec2_C,Data.vec2_U,Data.vec2_V,Data.vec2_X,Data.vec2_Y);
     857            Data.vec_FixFlag=detect_false(Param.Fix2,Data.vec2_F,Data.vec2_C,Data.vec2_U,Data.vec2_V);
    860858        else
    861859            Data.ListVarName=[Data.ListVarName {'Civ2_FF'}];
     
    863861            nbvar=length(Data.ListVarName);
    864862            Data.VarAttribute{nbvar}.Role='errorflag';
    865             Data.Civ2_FF=double(fix(Param.ActionInput.Fix2,Data.Civ2_F,Data.Civ2_C,Data.Civ2_U,Data.Civ2_V));
     863            Data.Civ2_FF=double(detect_false(Param.ActionInput.Fix2,Data.Civ2_F,Data.Civ2_C,Data.Civ2_U,Data.Civ2_V));
    866864            Data.CivStage=Data.CivStage+1;
    867865        end
     
    12931291end
    12941292
    1295 %'RUN_FIX': function for fixing velocity fields:
    1296 %-----------------------------------------------
    1297 % RUN_FIX(filename,field,flagindex,thresh_vecC,thresh_vel,iter,flag_mask,maskname,fileref,fieldref)
    1298 %
    1299 %filename: name of the netcdf file (used as input and output)
    1300 %field: structure specifying the names of the fields to fix (depending on civ1 or civ2)
    1301 %.vel_type='civ1' or 'civ2';
    1302 %.nb=name of the dimension common to the field to fix ('nb_vectors' for civ1);
    1303 %.fixflag=name of fix flag variable ('vec_FixFlag' for civ1)
    1304 %flagindex: flag specifying which values of vec_f are removed:
    1305 % if flagindex(1)=1: vec_f=-2 vectors are removed
    1306 % if flagindex(2)=1: vec_f=3 vectors are removed
    1307 % if flagindex(3)=1: vec_f=2 vectors are removed (if iter=1) or vec_f=4 vectors are removed (if iter=2)
    1308 %iter=1 for civ1 fields and iter=2 for civ2 fields
    1309 %thresh_vecC: threshold in the image correlation vec_C
    1310 %flag_mask: =1 mask used to remove vectors (0 else)
    1311 %maskname: name of the mask image file for fix
    1312 %thresh_vel: threshold on velocity, or on the difference with the reference file fileref if exists
    1313 %inf_sup=1: remove values smaller than threshold thresh_vel, =2, larger than threshold
    1314 %fileref: .nc file name for a reference velocity (='': refrence 0 used)
    1315 %fieldref: 'civ1','filter1'...feld used in fileref
    1316 
    1317 function FF=fix(Param,F,C,U,V,X,Y)
     1293
     1294function FF=detect_false(Param,F,C,U,V)
    13181295FF=zeros(size(F));%default
    1319 
    1320 %criterium on warn flags
    1321 FlagName={'CheckFmin2','CheckF2','CheckF3','CheckF4'};
    1322 FlagVal=[-2 2 3 4];
    1323 for iflag=1:numel(FlagName)
    1324     if isfield(Param,FlagName{iflag}) && Param.(FlagName{iflag})
    1325         FF=(FF==1| F==FlagVal(iflag));
    1326     end
    1327 end
    1328 %criterium on correlation values
     1296% FF=-2, for correlation max at edge
     1297% FF=-1, for too small correlation
     1298% FF=1, for velocity outside bounds
     1299% FF=2 for exclusion by difference with the smoothed field
     1300FF(F==-2)=-2;
    13291301if isfield (Param,'MinCorr')
    1330     FF=FF==1 | C<Param.MinCorr;
     1302     FF(C<Param.MinCorr)=-1;
    13311303end
    13321304if (isfield(Param,'MinVel')&&~isempty(Param.MinVel))||(isfield (Param,'MaxVel')&&~isempty(Param.MaxVel))
    13331305    Umod= U.*U+V.*V;
    13341306    if isfield (Param,'MinVel')&&~isempty(Param.MinVel)
    1335         FF=FF==1 | Umod<(Param.MinVel*Param.MinVel);
     1307        U2Min=Param.MinVel*Param.MinVel;
     1308        FF(Umod<U2Min)=1;
    13361309    end
    13371310    if isfield (Param,'MaxVel')&&~isempty(Param.MaxVel)
    1338         FF=FF==1 | Umod>(Param.MaxVel*Param.MaxVel);
    1339     end
    1340 end
     1311         U2Max=Param.MaxVel*Param.MaxVel;
     1312        FF(Umod>U2Max)=1;
     1313    end
     1314end
     1315
     1316
     1317%criterium on warn flags
     1318% FlagName={'CheckFmin2','CheckF2','CheckF3','CheckF4'};
     1319% FlagVal=[-2 2 3 4];
     1320% for iflag=1:numel(FlagName)
     1321%     if isfield(Param,FlagName{iflag}) && Param.(FlagName{iflag})
     1322%         FF=(FF==1| F==FlagVal(iflag));
     1323%     end
     1324% end
     1325% %criterium on correlation values
     1326% if isfield (Param,'MinCorr')
     1327%     FF=FF==1 | C<Param.MinCorr;
     1328% end
     1329% if (isfield(Param,'MinVel')&&~isempty(Param.MinVel))||(isfield (Param,'MaxVel')&&~isempty(Param.MaxVel))
     1330%     Umod= U.*U+V.*V;
     1331%     if isfield (Param,'MinVel')&&~isempty(Param.MinVel)
     1332%         FF=FF==1 | Umod<(Param.MinVel*Param.MinVel);
     1333%     end
     1334%     if isfield (Param,'MaxVel')&&~isempty(Param.MaxVel)
     1335%         FF=FF==1 | Umod>(Param.MaxVel*Param.MaxVel);
     1336%     end
     1337% end
    13411338
    13421339
Note: See TracChangeset for help on using the changeset viewer.