Changeset 873 for trunk


Ignore:
Timestamp:
Feb 17, 2015, 1:46:13 AM (10 years ago)
Author:
sommeria
Message:

civ improved at mask edge

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/plot_field.m

    r872 r873  
    222222
    223223%% text display
    224 htext=findobj(hfig,'Tag','TableDisplay');
    225 hchecktable=findobj(hfig,'Tag','CheckTable');
    226 if ~isempty(htext)&&~isempty(hchecktable)
    227     if isempty(index_0D)
    228 %         set(htext,'Data',{})
    229 %         set(htext,'visible','off')
    230 %         set(hchecktable,'visible','off')
    231 %         set(hchecktable,'Value',0)
    232     else
    233         errormsg=plot_text(Data,CellInfo(index_0D),htext);
    234         set(htext,'visible','on')
    235         set(hchecktable,'visible','on')
    236         set(hchecktable,'Value',1)
    237     end
    238     set(hfig,'Unit','pixels');
    239     set(htext,'Unit','pixels')
    240     PosFig=get(hfig,'Position');
    241     % case of no plot with view_field: only text display
    242     if strcmp(get(hfig,'Tag'),'view_field')
    243         if isempty(index_1D) && isempty(index_2D)% case of no plot: only text display
    244             set(haxes,'Visible','off')         
    245             PosTable=get(htext,'Position');
    246             set(hfig,'Position',[PosFig(1) PosFig(2)  PosTable(3) PosTable(4)])
    247         else
    248             set(haxes,'Visible','on')
    249             set(hfig,'Position',[PosFig(1) PosFig(2)  877 677])%default size for view_field
    250         end
    251     end
    252 end
    253 
     224if ~(isfield(PlotParamOut,'Axes')&&isfield(PlotParamOut.Axes,'TextDisplay')&&(PlotParamOut.Axes.TextDisplay)) % if text is not already given as statistics
     225    htext=findobj(hfig,'Tag','TableDisplay');
     226    hchecktable=findobj(hfig,'Tag','CheckTable');
     227    if ~isempty(htext)&&~isempty(hchecktable)
     228        if isempty(index_0D)
     229            %         set(htext,'Data',{})
     230            %         set(htext,'visible','off')
     231            %         set(hchecktable,'visible','off')
     232            %         set(hchecktable,'Value',0)
     233        else
     234            errormsg=plot_text(Data,CellInfo(index_0D),htext);
     235            set(htext,'visible','on')
     236            set(hchecktable,'visible','on')
     237            set(hchecktable,'Value',1)
     238        end
     239        set(hfig,'Unit','pixels');
     240        set(htext,'Unit','pixels')
     241        PosFig=get(hfig,'Position');
     242        % case of no plot with view_field: only text display
     243        if strcmp(get(hfig,'Tag'),'view_field')
     244            if isempty(index_1D) && isempty(index_2D)% case of no plot: only text display
     245                set(haxes,'Visible','off')
     246                PosTable=get(htext,'Position');
     247                set(hfig,'Position',[PosFig(1) PosFig(2)  PosTable(3) PosTable(4)])
     248            else
     249                set(haxes,'Visible','on')
     250                set(hfig,'Position',[PosFig(1) PosFig(2)  877 677])%default size for view_field
     251            end
     252        end
     253    end
     254end
    254255%% display error message
    255256if ~isempty(errormsg)
     
    574575%% give statistics for pdf
    575576ind_var=find(testplot);
    576 if numel(ind_var)==1 && isfield(data,'VarAttribute') &&numel(data.VarAttribute)>=ind_var &&...
    577         isfield(data.VarAttribute{ind_var},'Role') && strcmp(data.VarAttribute{ind_var}.Role,'histo')
    578     pdf_val=data.(data.ListVarName{ind_var});
    579     x=coord_x{1};
    580     TableData=cell(12,2);
    581     TableData(:,1)={'SampleNbr';'Mean';'RMS';'Skewness';'Kurtosis';...
    582         'Min';'FirstCentile';'FirstDecile';'Median';'LastDecile';'LastCentile';'Max'};
    583     Val=zeros(12,1);
    584     Val(1)=sum(pdf_val);% total sample number
    585     pdf_val=pdf_val/Val(1);% normalised pdf
    586     Val(2)=sum(x.*pdf_val);%Mean
    587     x=x-Val(2); %centered variable
    588     Variance=sum(x.*x.*pdf_val);
    589     Val(3)=sqrt(Variance);
    590     Val(4)=(sum(x.*x.*x.*pdf_val))/(Variance*Val(3));%skewness
    591     Val(5)=(sum(x.*x.*x.*x.*pdf_val))/(Variance*Variance);%kurtosis
    592     Val(6)=min(x);
    593     cumpdf=cumsum(pdf_val);
    594     ind_centile=find(cumpdf>=0.01,1);
    595     Val(7)=x(ind_centile);
    596     ind_decile=find(cumpdf>=0.1,1);
    597     Val(8)=x(ind_decile);
    598     ind_median=find(cumpdf>= 0.5,1);
    599     Val(9)=x(ind_median);
    600     ind_decile=find(cumpdf>=0.9,1);
    601     Val(10)=x(ind_decile);
    602     ind_centile=find(cumpdf>=0.99,1);
    603     Val(11)=x(ind_centile);
    604     Val(12)=max(x);   
    605     TableData(:,2)=mat2cell(Val,ones(12,1),1)
    606     TableData=[TableData(1:5,:);{'   -- centered','stat: --'};TableData(6:12,:)];
    607     htable=findobj(hfig,'Tag','TableDisplay')
     577TableData={'Variable';'SampleNbr';'bin size';'Mean';'RMS';'Skewness';'Kurtosis';'    centered ';...
     578    'Min';'FirstCentile';'FirstDecile';'Median';'LastDecile';'LastCentile';'Max'};
     579CoordinatesOut.TextDisplay=0;
     580for icell=1:numel(CellInfo)
     581    if isfield(CellInfo{icell},'VarIndex_histo')
     582        check_stat=1;
     583        CoordinatesOut.TextDisplay=1;
     584        VarName=data.ListVarName{CellInfo{icell}.CoordIndex};
     585        pdf_val=data.(data.ListVarName{CellInfo{icell}.VarIndex_histo});
     586        x=coord_x{icell};
     587        Val=zeros(12,1);
     588        Val(1)=sum(pdf_val);% total sample number
     589        Val(7)=min(x);
     590        Val(13)=max(x);
     591        Val(2)=(Val(13)-Val(7))/(numel(x)-1);%bin size
     592        pdf_val=pdf_val/Val(1);% normalised pdf
     593        Val(3)=sum(x.*pdf_val);%Mean
     594        x=x-Val(3); %centered variable
     595        Variance=sum(x.*x.*pdf_val);
     596        Val(4)=sqrt(Variance);
     597        Val(5)=(sum(x.*x.*x.*pdf_val))/(Variance*Val(4));%skewness
     598        Val(6)=(sum(x.*x.*x.*x.*pdf_val))/(Variance*Variance);%kurtosis
     599        cumpdf=cumsum(pdf_val);
     600        ind_centile=find(cumpdf>=0.01,1);% first index with cumsum >=0.01
     601        Val(8)=(cumpdf(ind_centile)-0.01)*x(ind_centile-1)+(0.01-cumpdf(ind_centile-1))*x(ind_centile);
     602        Val(8)=Val(8)/(cumpdf(ind_centile)-cumpdf(ind_centile-1));%linear interpolation near ind_centile
     603        ind_decile=find(cumpdf>=0.1,1);
     604        Val(9)=(cumpdf(ind_decile)-0.1)*x(ind_decile-1)+(0.1-cumpdf(ind_decile-1))*x(ind_decile);
     605        Val(9)=Val(9)/(cumpdf(ind_decile)-cumpdf(ind_decile-1));%linear interpolation near ind_decile;
     606        ind_median=find(cumpdf>= 0.5,1);
     607        Val(10)=(cumpdf(ind_median)-0.5)*x(ind_median-1)+(0.5-cumpdf(ind_median-1))*x(ind_median);
     608        Val(10)=Val(10)/(cumpdf(ind_median)-cumpdf(ind_median-1));%linear interpolation near ind_median;
     609        %     Val(9)=x(ind_median);
     610        ind_decile=find(cumpdf>=0.9,1);
     611        Val(11)=(cumpdf(ind_decile)-0.9)*x(ind_decile-1)+(0.9-cumpdf(ind_decile-1))*x(ind_decile);
     612        Val(11)=Val(11)/(cumpdf(ind_decile)-cumpdf(ind_decile-1));%linear interpolation near ind_median;
     613        ind_centile=find(cumpdf>=0.99,1);
     614        Val(12)=(cumpdf(ind_centile)-0.99)*x(ind_centile-1)+(0.99-cumpdf(ind_centile-1))*x(ind_centile);
     615        Val(12)=Val(12)/(cumpdf(ind_centile)-cumpdf(ind_centile-1));%linear interpolation near ind_centile;
     616        Val(13)=max(x);
     617        Column=mat2cell(Val,ones(13,1),1);
     618        Column=[{VarName};Column(1:6);{'stat: --'};Column(7:13)];
     619        TableData=[TableData Column];
     620    end
     621end
     622if CoordinatesOut.TextDisplay;
     623    disp(TableData);
     624    htable=findobj(hfig,'Tag','TableDisplay');
    608625    set(htable,'Data',TableData)
    609626    set(htable,'Visible','on')
  • trunk/src/proj_field.m

    r871 r873  
    368368
    369369CoordMesh=zeros(1,numel(FieldData.ListVarName));
    370 %VarMesh=nan(1,numel(FieldData.ListVarName));
    371 % MinValue=nan(1,numel(FieldData.ListVarName));
    372 % MaxValue=nan(1,numel(FieldData.ListVarName));
    373370if isfield (FieldData,'VarAttribute')
    374371    for iattr=1:length(FieldData.VarAttribute)%initialization of variable attribute values
     
    379376            CoordMesh(iattr)=FieldData.VarAttribute{iattr}.CoordMesh;
    380377        end
    381 %         if isfield(FieldData.VarAttribute{iattr},'Mesh')
    382 %             VarMesh(iattr)=FieldData.VarAttribute{iattr}.Mesh;
    383 %         end
    384 %         if isfield(FieldData.VarAttribute{iattr},'MinValue')
    385 %             VarMesh(iattr)=FieldData.VarAttribute{iattr}.MinValue;
    386 %         end
    387 %         if isfield(FieldData.VarAttribute{iattr},'MaxValue')
    388 %             VarMesh(iattr)=FieldData.VarAttribute{iattr}.MaxValue;
    389 %         end
    390378    end
    391379end
  • trunk/src/series/civ_input.m

    r862 r873  
    373373
    374374%% Civ1 parameters
     375Param.CheckCiv1=1;
    375376Param.Civ1.CorrBoxSize=[25 25];
    376377Param.Civ1.SearchBoxSize=[55 55];
     
    381382Param.Civ1.CheckGrid=0;
    382383Param.Civ1.CheckMask=0;
     384Param.Civ1.Mask='';
    383385Param.Civ1.CheckThreshold=0;
    384386Param.Civ1.TestCiv1=0;
    385387
    386388%% Fix1 parameters
     389Param.CheckFix1=1;
    387390Param.Fix1.CheckFmin2=1;
    388391Param.Fix1.CheckF3=1;
     
    390393
    391394%% Patch1 parameters
     395Param.CheckPatch1=1;
    392396Param.Patch1.FieldSmooth=10;
    393397Param.Patch1.MaxDiff=1.5000;
     
    396400
    397401%% Civ2 parameters
     402Param.CheckCiv2=1;
    398403Param.Civ2.CorrBoxSize=[21 21];
    399404Param.Civ2.SearchBoxSize=[27 27];
     
    403408Param.Civ2.CheckGrid=0;
    404409Param.Civ2.CheckMask=0;
     410Param.Civ2.Mask='';
    405411Param.Civ2.CheckThreshold=0;
    406412Param.Civ2.TestCiv2=0;
    407413
    408414%% Fix2 parameters
     415Param.CheckFix2=1;
    409416Param.Fix2.CheckFmin2=1;
    410417Param.Fix2.CheckF4=1;
     
    413420
    414421%% Patch2 parameters
     422Param.CheckPatch2=1;
    415423Param.Patch2.FieldSmooth=2;
    416424Param.Patch2.MaxDiff=1.5000;
     
    419427
    420428fill_GUI(Param,handles.civ_input)% fill the elements of the GUI series with the input parameters
     429update_CivOptions(handles,0)
    421430
    422431% -----------------------------------------------------------------------
     
    11291138% --- Executes on selection in menu CorrSmooth.
    11301139function num_CorrSmooth_Callback(hObject, eventdata, handles)
    1131 set(handles.configSource,'String','NEW')
     1140set(handles.ConfigSource,'String','NEW')
    11321141set(handles.OK,'BackgroundColor',[1 0 1])
    11331142%------------------------------------------------------------------------
     
    14731482end
    14741483set(hObject,'BackgroundColor',[1 0 1])
    1475 set(handles.configSource,'String','NEW')
     1484set(handles.ConfigSource,'String','NEW')
    14761485set(handles.OK,'BackgroundColor',[1 0 1])
    14771486%------------------------------------------------------------------------
     
    15181527    set(handle_txtbox,'Visible','off')
    15191528end
    1520 set(handles.configSource,'String','NEW')
    1521 set(handles.configSource,'BackgroundColor',[1 0 1])
     1529set(handles.ConfigSource,'String','NEW')
     1530set(handles.ConfigSource,'BackgroundColor',[1 0 1])
    15221531
    15231532% %------------------------------------------------------------------------
     
    17351744    set(obj,'Visible','off')
    17361745end
    1737 set(handles.configSource,'String','NEW')
     1746set(handles.ConfigSource,'String','NEW')
    17381747set(handles.OK,'BackgroundColor',[1 0 1])
    17391748%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    17481757if get(handles.TestCiv1,'Value')
    17491758    set(handles.TestCiv1,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch 
    1750     %Param.Action.RUN=1;
    1751    
     1759    set(handles.CheckFix1,'value',0)% desactivate next step
     1760    set(handles.CheckPatch1,'value',0)% desactivate next step
     1761    set(handles.CheckCiv2,'value',0)% desactivate next step
     1762    set(handles.CheckFix2,'value',0)% desactivate next step
     1763    set(handles.CheckPatch2,'value',0)% desactivate next step
     1764    update_CivOptions(handles,0)
    17521765      hseries=findobj(allchild(0),'Tag','series');
    17531766     Param=read_GUI(hseries);
     
    18871900    end
    18881901    figure(1)
    1889     hold on
    1890     semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r')
     1902    semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r',SmoothingParam,0.2*ones(size(SmoothingParam)),'m')
    18911903    grid on
    1892     legend('rms velocity diff. Patch1-Civ1 (pixels)','proportion of excluded vectors (between 0 to 1)')
     1904    legend('rms velocity diff. Patch1-Civ1 (pixels)','proportion of excluded vectors (between 0 to 1)','recommended diff Patch1-Civ1')
    18931905    xlabel('smoothing parameter')
    18941906    ylabel('smoothing effect')
     
    19121924if get(handles.TestCiv2,'Value')
    19131925    set(handles.TestCiv2,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch
     1926    set(handles.CheckFix2,'value',0)% desactivate next step
     1927    set(handles.CheckPatch2,'value',0)% desactivate next step
     1928    update_CivOptions(handles,0)
    19141929      hseries=findobj(allchild(0),'Tag','series');
    19151930     Param=read_GUI(hseries);
     
    20652080    end
    20662081    figure(1)
    2067     hold on
    2068     semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r')
     2082    semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r',SmoothingParam,0.1*ones(size(SmoothingParam)),'m')
    20692083    grid on
    2070     legend('rms velocity diff. Patch2-Civ2 (pixels)','proportion of excluded vectors (between 0 to 1)')
     2084    legend('rms velocity diff. Patch2-Civ2 (pixels)','proportion of excluded vectors (between 0 to 1)','recommended value diff. Patch2-Civ2')
    20712085    xlabel('smoothing parameter')
    20722086    ylabel('smoothing effect')
  • trunk/src/series/civ_series.m

    r862 r873  
    705705        par_civ2.SearchBoxShift=(Civ2_Dt/Civ1_Dt)*[Shiftx(nbval>=1)./nbval(nbval>=1) Shifty(nbval>=1)./nbval(nbval>=1)];
    706706        % shift the grid points by half the expected shift to provide the correlation box position in image A
    707         par_civ2.Grid=[par_civ2.Grid(nbval>=1,1)-par_civ2.SearchBoxShift(nbval>=1,1)/2 par_civ2.Grid(nbval>=1,2)-par_civ2.SearchBoxShift(nbval>=1,2)/2];
     707        par_civ2.Grid=[par_civ2.Grid(nbval>=1,1)-par_civ2.SearchBoxShift(:,1)/2 par_civ2.Grid(nbval>=1,2)-par_civ2.SearchBoxShift(:,2)/2];
    708708        if par_civ2.CheckDeformation
    709709            par_civ2.DUDX=DUDX./nbval;
     
    732732             end
    733733        end
    734         %         Data.Civ2_Time=1;
    735         %         Data.Civ2_Dt=1;
    736734        for ilist=1:length(list_param)
    737735            Data.(Civ2_param{4+ilist})=Param.ActionInput.Civ2.(list_param{ilist});
     
    961959checkmask=0;
    962960MinA=min(min(par_civ.ImageA));
    963 MinB=min(min(par_civ.ImageB));
     961%MinB=min(min(par_civ.ImageB));
     962check_undefined=false(size(par_civ.ImageA));
    964963if isfield(par_civ,'Mask') && ~isempty(par_civ.Mask)
    965964    checkmask=1;
     
    968967        return
    969968    end
    970     %  check_noflux=(par_civ.Mask<100) ;%TODO: to implement
    971969    check_undefined=(par_civ.Mask<200 & par_civ.Mask>=20 );
    972     par_civ.ImageA(check_undefined)=MinA;% put image A to zero (i.e. the min image value) in the undefined  area
    973     par_civ.ImageB(check_undefined)=MinB;% put image B to zero (i.e. the min image value) in the undefined  area
     970    par_civ.ImageA(check_undefined)=0;% put image A to zero (i.e. the min image value) in the undefined  area
     971    par_civ.ImageB(check_undefined)=0;% put image B to zero (i.e. the min image value) in the undefined  area
    974972end
    975973
     
    994992        image1_crop=MinA*ones(numel(subrange1_y),numel(subrange1_x));% default value=min of image A
    995993        image2_crop=MinA*ones(numel(subrange2_y),numel(subrange2_x));% default value=min of image A
     994        mask1_crop=ones(numel(subrange1_y),numel(subrange1_x));% default value=1 for mask
     995        mask2_crop=ones(numel(subrange2_y),numel(subrange2_x));% default value=min for mask
    996996        check1_x=subrange1_x>=1 & subrange1_x<=par_civ.ImageWidth;% check which points in the subimage 1 are contained in the initial image 1
    997997        check1_y=subrange1_y>=1 & subrange1_y<=par_civ.ImageHeight;
     
    10001000        image1_crop(check1_y,check1_x)=par_civ.ImageA(subrange1_y(check1_y),subrange1_x(check1_x));%extract a subimage (correlation box) from image A
    10011001        image2_crop(check2_y,check2_x)=par_civ.ImageB(subrange2_y(check2_y),subrange2_x(check2_x));%extract a larger subimage (search box) from image B
    1002         image1_mean=mean(mean(image1_crop));
    1003         image2_mean=mean(mean(image2_crop));
    1004         %threshold on image minimum
    1005         if check_MinIma && (image1_mean < par_civ.MinIma || image2_mean < par_civ.MinIma)
    1006             F(ivec)=3;
    1007         end
    1008         %threshold on image maximum
    1009         if check_MaxIma && (image1_mean > par_civ.MaxIma || image2_mean > par_civ.MaxIma)
    1010             F(ivec)=3;
    1011         end
    1012        
     1002        mask1_crop(check1_y,check1_x)=check_undefined(subrange1_y(check1_y),subrange1_x(check1_x));%extract a mask subimage (correlation box) from image A
     1003        mask2_crop(check2_y,check2_x)=check_undefined(subrange2_y(check2_y),subrange2_x(check2_x));%extract a mask subimage (search box) from image B
     1004        sizemask=sum(sum(mask1_crop))/(numel(subrange1_y)*numel(subrange1_x));%size of the masked part relative to the correlation sub-image
     1005        if sizemask > 1/2% eliminate point if more than half of the correlation box is masked
     1006            F(ivec)=3; %
     1007        else
     1008            image1_mean=mean(mean(image1_crop))/(1-sizemask);
     1009            image2_mean=mean(mean(image2_crop))/(1-sizemask);
     1010            %threshold on image minimum
     1011            if check_MinIma && (image1_mean < par_civ.MinIma || image2_mean < par_civ.MinIma)
     1012                F(ivec)=3;
     1013            end
     1014            %threshold on image maximum
     1015            if check_MaxIma && (image1_mean > par_civ.MaxIma || image2_mean > par_civ.MaxIma)
     1016                F(ivec)=3;
     1017            end
     1018        end
    10131019        if F(ivec)~=3
    1014             image1_crop=image1_crop-image1_mean;%substract the mean
    1015             image2_crop=image2_crop-image2_mean;
     1020            image1_crop=(image1_crop-image1_mean).*~mask1_crop;%substract the mean, put to zero the masked parts
     1021            image2_crop=(image2_crop-image2_mean).*~mask2_crop;
    10161022            if CheckDeformation
    10171023                xi=(1:mesh:size(image1_crop,2));
  • trunk/src/view_field.m

    r809 r873  
    127127set(handles.text_display,'Position',pos_1)
    128128% reset position of TableDisplay
    129 set(handles.TableDisplay,'Position',pos_1)
     129pos_TableDisplay=[pos_1(1) 2 pos_1(3) 2.2*pos_1(4)];
     130set(handles.TableDisplay,'Position',pos_TableDisplay)
     131
    130132% reset position of CheckTable
    131133pos_CheckTable=get(handles.CheckTable,'Position');% [lower x lower y width height] for CheckHold
    132 pos_CheckTable(1)=pos_1(1)-pos_CheckTable(3);       % set 'CheckHold' to the right of the fig
    133 pos_CheckTable(2)=size_fig(4)-pos_CheckTable(4);          % set 'CheckHold' to the lower edge of text display
     134pos_CheckTable(1)=pos_1(1);%-pos_CheckTable(3);       % set 'CheckHold' to the right of the fig
     135pos_CheckTable(2)=pos_TableDisplay(2)+pos_TableDisplay(4);%size_fig(4)-pos_CheckTable(4);          % set 'CheckHold' to the lower edge of text display
    134136set(handles.CheckTable,'Position',pos_CheckTable)
    135137
Note: See TracChangeset for help on using the changeset viewer.