Changeset 1141 for trunk/src/series


Ignore:
Timestamp:
May 3, 2024, 6:16:47 PM (5 months ago)
Author:
sommeria
Message:

smoothig parameter renormalised in filter_tps

Location:
trunk/src/series
Files:
3 edited

Legend:

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

    r1127 r1141  
    177177for index=1:NbField
    178178   
    179     update_waitbar(WaitbarHandle,index/NbField)
    180    
    181    
    182    
     179
    183180   
    184181      %% generating the name of the merged field
     
    333330    Vtest=ZItemp(:,:,2)-ZItemp(:,:,1);
    334331   
    335     [Xa,Ya]=px_XYZ(XmlData{1}.GeometryCalib,XI,YI,ZI);% set of image coordinates on view a
    336     [Xb,Yb]=px_XYZ(XmlData{2}.GeometryCalib,XI,YI,ZI);% set of image coordinates on view b
     332    [Xa,Ya]=px_XYZ(XmlData{1}.GeometryCalib,[],XI,YI,ZI);% set of image coordinates on view a
     333    [Xb,Yb]=px_XYZ(XmlData{2}.GeometryCalib,[],XI,YI,ZI);% set of image coordinates on view b
    337334   
    338335   
     
    377374   
    378375    %remove wrong vector 
    379     if isfield(Data{1},'FF')
     376    if isfield(Data{2},'FF')
    380377        temp=find(Data{2}.FF==0);
    381378        X2=Data{2}.X(temp);
  • trunk/src/series/civ_input.m

    r1139 r1141  
    319319
    320320%% set the menu and default choice of civ pairs
    321 if ~isfield(Param.IndexRange,'first_j')||isequal(MaxIndex_j,MinIndex_j)% no possibility of j pairs
     321if isequal(MaxIndex_j,MinIndex_j)% no possibility of j pairs
    322322    PairMenu={'series(Di)'};
    323 elseif  MaxIndex_i==1 && MaxIndex_j>1% simple series in j
     323elseif MaxIndex_j-MinIndex_j==1
     324    PairMenu={'pair j1-j2'};
     325elseif  MaxIndex_i==MinIndex_i && MaxIndex_j-MinIndex_j>2% simple series in j
    324326    PairMenu={'pair j1-j2';'series(Dj)'};
    325327else
     
    17951797% --------------------------------------------------------------------
    17961798function TestPatch1_Callback(hObject, eventdata, handles)
    1797 
    1798 if get(handles.TestPatch1,'Value')% if TestPatch1 is activated
    1799     hseries=findobj(allchild(0),'Tag','series');
    1800     Param=read_GUI(hseries);
    1801     CivDir=fullfile(Param.OutputPath,Param.Experiment,Param.Device,[Param.OutputSubDir Param.OutputDirExt]);
    1802     % ListXml=dir(CivXmlDir);
    1803     if exist(CivDir,'dir')
    1804         CivFile=uigetfile_uvmat('pick .nc file with civ1-fix1 data',CivDir,'.nc');
    1805         [Field,VelTypeOut,errormsg]=read_civdata(CivFile)
    1806         for ilist=1:numel(Field.ListGlobalAttribute)
    1807             r=regexp(Field.ListGlobalAttribute{ilist},'Civ1_(?<field>.+)','names');% \D = not a digit, \d =digi
    1808             if ~isempty(r)
    1809                 ParamTest.Civ1.(r.field)=(Field.(['Civ1_' r.field]));
    1810             end
    1811             r=regexp(Field.ListGlobalAttribute{ilist},'Fix1_(?<field>.+)','names');% \D = not a digit, \d =digi
    1812             if ~isempty(r)
    1813                 ParamTest.Fix1.(r.field)=(Field.(['Fix1_' r.field]));
    1814             end
    1815         end
    1816         fill_GUI(ParamTest,handles.civ_input)% fill the elements of the GUI series with the input parameters
    1817         drawnow
    1818         update_CivOptions(handles,0)
    1819        
    1820         set(handles.TestPatch1,'BackgroundColor',[1 1 0])%paint TestPatch1 button in yellow to indicate activation
    1821 %         set(handles.Civ1,'BackgroundColor',[1 1 0])% indicate civ1 calculation is performed
    1822         Param.Action.RUN=1;
    1823          Param.ActionInput=read_GUI(handles.civ_input);
    1824          Param.ActionInput.CheckCiv1=0;% do not repeat Civ1 computation       
    1825         if isfield(Param.ActionInput,'Civ2')%remove options that may be selected beyond Patch1
    1826             Param.ActionInput=rmfield(Param.ActionInput,'Civ2');
    1827         end
    1828         if isfield(Param.ActionInput,'Fix2')
    1829             Param.ActionInput=rmfield(Param.ActionInput,'Fix2');
    1830         end
    1831         if isfield(Param.ActionInput,'Patch2')
    1832             Param.ActionInput=rmfield(Param.ActionInput,'Patch2');
    1833         end
    1834         if isfield(Param,'OutputSubDir')
    1835             Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series
    1836         end
    1837         ParamPatch1=Param.ActionInput.Patch1; %store the patch1 parameters
    1838         Param.ActionInput=rmfield(Param.ActionInput,'Patch1');% does not execute Patch
    1839         Param.IndexRange.first_i=str2num(get(handles.ref_i,'String'));
    1840         Param.IndexRange.last_i=Param.IndexRange.first_i;
    1841         if strcmp(get(handles.ref_j,'Visible'),'on')
    1842             Param.IndexRange.first_j=str2num(get(handles.ref_j,'String'));
    1843             Param.IndexRange.last_j=Param.IndexRange.first_j;
    1844         else
    1845             Param.IndexRange.first_j=1;
    1846             Param.IndexRange.last_j=1;
    1847         end
    1848         [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results
    1849         bckcolor=get(handles.civ_input,'Color');
    1850         set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calculation is finished
    1851        
    1852         %% prepare Param for iterative Patch processing without input file reading
    1853         Param.Civ1_X=Data.Civ1_X;
    1854         Param.Civ1_Y=Data.Civ1_Y;
    1855         Param.Civ1_U=Data.Civ1_U;
    1856         Param.Civ1_V=Data.Civ1_V;
    1857         Param.Civ1_FF=Data.Civ1_FF;
    1858         Param=rmfield(Param,'InputTable');%desactivate input file reading
    1859         if isfield(Param.ActionInput,'Civ1')
    1860             Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant
    1861         end
    1862         if isfield(Param.ActionInput,'Fix1')
    1863             Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant
    1864         end
    1865         SmoothingParam=(ParamPatch1.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value
    1866         NbGood=numel(find(Data.Civ1_FF==0));
    1867         NbExclude=zeros(1,7);% initialize the set of smoothing parameters
    1868         DiffVel=zeros(1,7);% initialize the rms difference between patch and civ
    1869         Param.ActionInput.Patch1=ParamPatch1;% retrieve Patch1 parameters
    1870         for irho=1:7
    1871             Param.ActionInput.Patch1.FieldSmooth=SmoothingParam(irho);
    1872             [Data,errormsg]= civ_series(Param);%apply the processing fct
    1873             if ~isempty(errormsg)
    1874                 msgbox_uvmat('ERROR',errormsg)
    1875                 return
    1876             end
    1877             ind_good=find(Data.Civ1_FF==0);
    1878             Civ1_U_Diff=Data.Civ1_U(ind_good)-Data.Civ1_U_smooth(ind_good);
    1879             Civ1_V_Diff=Data.Civ1_V(ind_good)-Data.Civ1_V_smooth(ind_good);
    1880             DiffVel(irho)=sqrt(mean(Civ1_U_Diff.*Civ1_U_Diff+Civ1_V_Diff.*Civ1_V_Diff));
    1881             NbExclude(irho)=(NbGood-numel(ind_good))/NbGood;
    1882         end
    1883         figure(1)
    1884         semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r',SmoothingParam,0.2*ones(size(SmoothingParam)),'m')
    1885         grid on
    1886         legend('rms velocity diff. Patch1-Civ1 (pixels)','proportion of excluded vectors (between 0 to 1)','recommended diff Patch1-Civ1')
    1887         xlabel('smoothing parameter')
    1888         ylabel('smoothing effect')
    1889         set(handles.TestPatch1,'BackgroundColor',[0 1 0])
    1890     else
    1891         corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
    1892         if ~isempty(corrfig)
    1893             delete(corrfig)
    1894         end
    1895         hview_field=findobj(allchild(0),'tag','view_field');% look for view_field
    1896         if ~isempty(hview_field)
    1897             delete(hview_field)
    1898         end
    1899     end
    1900 else
    1901     msgbox_uvmat('ERROR','no output file: first perform a civ1-fix1 computation')
    1902     return
    1903 end
     1799msgbox_uvmat('WARNING','open the civ file and run "series/test_patch_tps" ')
     1800
     1801% if get(handles.TestPatch1,'Value')% if TestPatch1 is activated
     1802%     hseries=findobj(allchild(0),'Tag','series');
     1803%     Param=read_GUI(hseries);
     1804%     CivDir=fullfile(Param.OutputPath,Param.Experiment,Param.Device,[Param.OutputSubDir Param.OutputDirExt]);
     1805%     % ListXml=dir(CivXmlDir);
     1806%     if exist(CivDir,'dir')
     1807%         CivFile=uigetfile_uvmat('pick .nc file with civ1-fix1 data',CivDir,'.nc');
     1808%         [Field,VelTypeOut,errormsg]=read_civdata(CivFile)
     1809%         for ilist=1:numel(Field.ListGlobalAttribute)
     1810%             r=regexp(Field.ListGlobalAttribute{ilist},'Civ1_(?<field>.+)','names');% \D = not a digit, \d =digi
     1811%             if ~isempty(r)
     1812%                 ParamTest.Civ1.(r.field)=(Field.(['Civ1_' r.field]));
     1813%             end
     1814%             r=regexp(Field.ListGlobalAttribute{ilist},'Fix1_(?<field>.+)','names');% \D = not a digit, \d =digi
     1815%             if ~isempty(r)
     1816%                 ParamTest.Fix1.(r.field)=(Field.(['Fix1_' r.field]));
     1817%             end
     1818%         end
     1819%         fill_GUI(ParamTest,handles.civ_input)% fill the elements of the GUI series with the input parameters
     1820%         drawnow
     1821%         update_CivOptions(handles,0)
     1822%
     1823%         set(handles.TestPatch1,'BackgroundColor',[1 1 0])%paint TestPatch1 button in yellow to indicate activation
     1824% %         set(handles.Civ1,'BackgroundColor',[1 1 0])% indicate civ1 calculation is performed
     1825%         Param.Action.RUN=1;
     1826%          Param.ActionInput=read_GUI(handles.civ_input);
     1827%          Param.ActionInput.CheckCiv1=0;% do not repeat Civ1 computation       
     1828%         if isfield(Param.ActionInput,'Civ2')%remove options that may be selected beyond Patch1
     1829%             Param.ActionInput=rmfield(Param.ActionInput,'Civ2');
     1830%         end
     1831%         if isfield(Param.ActionInput,'Fix2')
     1832%             Param.ActionInput=rmfield(Param.ActionInput,'Fix2');
     1833%         end
     1834%         if isfield(Param.ActionInput,'Patch2')
     1835%             Param.ActionInput=rmfield(Param.ActionInput,'Patch2');
     1836%         end
     1837%         if isfield(Param,'OutputSubDir')
     1838%             Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series
     1839%         end
     1840%         ParamPatch1=Param.ActionInput.Patch1; %store the patch1 parameters
     1841%         Param.ActionInput=rmfield(Param.ActionInput,'Patch1');% does not execute Patch
     1842%         Param.IndexRange.first_i=str2num(get(handles.ref_i,'String'));
     1843%         Param.IndexRange.last_i=Param.IndexRange.first_i;
     1844%         if strcmp(get(handles.ref_j,'Visible'),'on')
     1845%             Param.IndexRange.first_j=str2num(get(handles.ref_j,'String'));
     1846%             Param.IndexRange.last_j=Param.IndexRange.first_j;
     1847%         else
     1848%             Param.IndexRange.first_j=1;
     1849%             Param.IndexRange.last_j=1;
     1850%         end
     1851%         [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results
     1852%         bckcolor=get(handles.civ_input,'Color');
     1853%         set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calculation is finished
     1854%
     1855%         %% prepare Param for iterative Patch processing without input file reading
     1856%         Param.Civ1_X=Data.Civ1_X;
     1857%         Param.Civ1_Y=Data.Civ1_Y;
     1858%         Param.Civ1_U=Data.Civ1_U;
     1859%         Param.Civ1_V=Data.Civ1_V;
     1860%         Param.Civ1_FF=Data.Civ1_FF;
     1861%         Param=rmfield(Param,'InputTable');%desactivate input file reading
     1862%         if isfield(Param.ActionInput,'Civ1')
     1863%             Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant
     1864%         end
     1865%         if isfield(Param.ActionInput,'Fix1')
     1866%             Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant
     1867%         end
     1868%         SmoothingParam=(ParamPatch1.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value
     1869%         NbGood=numel(find(Data.Civ1_FF==0));
     1870%         NbExclude=zeros(1,7);% initialize the set of smoothing parameters
     1871%         DiffVel=zeros(1,7);% initialize the rms difference between patch and civ
     1872%         Param.ActionInput.Patch1=ParamPatch1;% retrieve Patch1 parameters
     1873%         for irho=1:7
     1874%             Param.ActionInput.Patch1.FieldSmooth=SmoothingParam(irho);
     1875%             [Data,errormsg]= civ_series(Param);%apply the processing fct
     1876%             if ~isempty(errormsg)
     1877%                 msgbox_uvmat('ERROR',errormsg)
     1878%                 return
     1879%             end
     1880%             ind_good=find(Data.Civ1_FF==0);
     1881%             Civ1_U_Diff=Data.Civ1_U(ind_good)-Data.Civ1_U_smooth(ind_good);
     1882%             Civ1_V_Diff=Data.Civ1_V(ind_good)-Data.Civ1_V_smooth(ind_good);
     1883%             DiffVel(irho)=sqrt(mean(Civ1_U_Diff.*Civ1_U_Diff+Civ1_V_Diff.*Civ1_V_Diff));
     1884%             NbExclude(irho)=(NbGood-numel(ind_good))/NbGood;
     1885%         end
     1886%         figure(1)
     1887%         semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r',SmoothingParam,0.2*ones(size(SmoothingParam)),'m')
     1888%         grid on
     1889%         legend('rms velocity diff. Patch1-Civ1 (pixels)','proportion of excluded vectors (between 0 to 1)','recommended diff Patch1-Civ1')
     1890%         xlabel('smoothing parameter')
     1891%         ylabel('smoothing effect')
     1892%         set(handles.TestPatch1,'BackgroundColor',[0 1 0])
     1893%     else
     1894%         corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
     1895%         if ~isempty(corrfig)
     1896%             delete(corrfig)
     1897%         end
     1898%         hview_field=findobj(allchild(0),'tag','view_field');% look for view_field
     1899%         if ~isempty(hview_field)
     1900%             delete(hview_field)
     1901%         end
     1902%     end
     1903% else
     1904%     msgbox_uvmat('ERROR','no output file: first perform a civ1-fix1 computation')
     1905%     return
     1906% end
    19041907 
    19051908%------------------------------------------------------------------------
     
    20112014function TestPatch2_Callback(hObject, eventdata, handles)
    20122015if get(handles.TestPatch2,'Value')% if TestPatch2 is activated
    2013      set(handles.TestPatch2,'BackgroundColor',[1 1 0])%paint TestPatch2 button in yellow to indicate activation
    2014      set(handles.Civ1,'BackgroundColor',[1 1 0])% indicate civ1 calculation is activated
    2015      set(handles.Fix1,'BackgroundColor',[1 1 0])% indicate fix1 calculation is activated
    2016      set(handles.Patch1,'BackgroundColor',[1 1 0])% indicate Patch1 calculation is activated
    2017      set(handles.Civ2,'BackgroundColor',[1 1 0])% indicate civ2 calculation is activated
    2018      set(handles.Fix2,'BackgroundColor',[1 1 0])% indicate fix2 calculation is activated
    2019      hseries=findobj(allchild(0),'Tag','series');
    2020      Param=read_GUI(hseries);
    2021      Param.Action.RUN=1;
    2022      Param.ActionInput=read_GUI(handles.civ_input);
    2023      if isfield(Param,'OutputSubDir')
    2024      Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series
    2025      end
    2026      ParamPatch2=Param.ActionInput.Patch2; %store the patch1 parameters
    2027      Param.ActionInput=rmfield(Param.ActionInput,'Patch2');% does not execute Patch
    2028      Param.IndexRange.first_i=str2num(get(handles.ref_i,'String'));
    2029      Param.IndexRange.last_i=Param.IndexRange.first_i;
    2030      if strcmp(get(handles.ref_j,'Visible'),'on')
    2031          Param.IndexRange.first_j=str2num(get(handles.ref_j,'String'));
    2032          Param.IndexRange.last_j=Param.IndexRange.first_j;
    2033      else
    2034          Param.IndexRange.first_j=1;
    2035          Param.IndexRange.last_j=1;
    2036      end
    2037      [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results
    2038      bckcolor=get(handles.civ_input,'Color');
    2039      set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calculation is finished
    2040      set(handles.Fix1,'BackgroundColor',bckcolor)% indicate fix1 calculation is finished
    2041      set(handles.Patch1,'BackgroundColor',bckcolor)% indicate Patch1 calculation is finished
    2042      set(handles.Civ2,'BackgroundColor',bckcolor)% indicate civ2 calculation is finished
    2043      set(handles.Fix2,'BackgroundColor',bckcolor)% indicate fix2 calculation is finished
    2044      
    2045      %% prepare Param for iterative Patch processing without input file reading
    2046      Param.Civ2_X=Data.Civ2_X;
    2047      Param.Civ2_Y=Data.Civ2_Y;
    2048      Param.Civ2_U=Data.Civ2_U;
    2049      Param.Civ2_V=Data.Civ2_V;
    2050      Param.Civ2_FF=Data.Civ2_FF;
    2051      Param=rmfield(Param,'InputTable');%desactivate input file reading
    2052     if isfield(Param.ActionInput,'Civ1')
    2053         Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant
    2054     end
    2055     if isfield(Param.ActionInput,'Fix1')
    2056         Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant
    2057     end
    2058     if isfield(Param.ActionInput,'Patch1')
    2059         Param.ActionInput=rmfield(Param.ActionInput,'Patch1');%desactivate fix1:remove fix1 input param if relevant
    2060     end
    2061     if isfield(Param.ActionInput,'Civ2')
    2062         Param.ActionInput=rmfield(Param.ActionInput,'Civ2');%desactivate civ2: remove civ2 input param if relevant
    2063     end
    2064     if isfield(Param.ActionInput,'Fix2')
    2065         Param.ActionInput=rmfield(Param.ActionInput,'Fix2');%desactivate fix1:remove fix1 input param if relevant
    2066     end
    2067     SmoothingParam=(ParamPatch2.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value
    2068     NbGood=numel(find(Data.Civ2_FF==0));
    2069     NbExclude=zeros(1,7);% initialize the set of smoothing parameters
    2070     DiffVel=zeros(1,7);% initialize the rms difference between patch and civ
    2071     Param.ActionInput.Patch2=ParamPatch2;% retrieve Patch2 parameters
    2072     for irho=1:7
    2073         Param.ActionInput.Patch2.FieldSmooth=SmoothingParam(irho);
    2074         [Data,errormsg]= civ_series(Param);%apply the processing fct
    2075         if ~isempty(errormsg)
    2076             msgbox_uvmat('ERROR',errormsg)
    2077             return
    2078         end
    2079         ind_good=find(Data.Civ2_FF==0);
    2080         Civ2_U_Diff=Data.Civ2_U(ind_good)-Data.Civ2_U_smooth(ind_good);
    2081         Civ2_V_Diff=Data.Civ2_V(ind_good)-Data.Civ2_V_smooth(ind_good);
    2082         DiffVel(irho)=sqrt(mean(Civ2_U_Diff.*Civ2_U_Diff+Civ2_V_Diff.*Civ2_V_Diff));
    2083         NbExclude(irho)=(NbGood-numel(ind_good))/NbGood;
    2084     end
    2085     figure(1)
    2086     semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r',SmoothingParam,0.1*ones(size(SmoothingParam)),'m')
    2087     grid on
    2088     legend('rms velocity diff. Patch2-Civ2 (pixels)','proportion of excluded vectors (between 0 to 1)','recommended value diff. Patch2-Civ2')
    2089     xlabel('smoothing parameter')
    2090     ylabel('smoothing effect')
    2091     set(handles.TestPatch2,'BackgroundColor',[0 1 0])
    2092 else
    2093     corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
    2094     if ~isempty(corrfig)
    2095         delete(corrfig)
    2096     end
    2097     hview_field=findobj(allchild(0),'tag','view_field');% look for view_field
    2098     if ~isempty(hview_field)
    2099         delete(hview_field)
    2100     end
    2101 end
    2102    
    2103 
    2104 %'nomtype2pair': creates nomencalture for index pairs knowing the image nomenclature
     2016    msgbox_uvmat('WARNING','open the civ file and run "series/test_patch_tps" ')
     2017end
     2018%      set(handles.TestPatch2,'BackgroundColor',[1 1 0])%paint TestPatch2 button in yellow to indicate activation
     2019%      set(handles.Civ1,'BackgroundColor',[1 1 0])% indicate civ1 calculation is activated
     2020%      set(handles.Fix1,'BackgroundColor',[1 1 0])% indicate fix1 calculation is activated
     2021%      set(handles.Patch1,'BackgroundColor',[1 1 0])% indicate Patch1 calculation is activated
     2022%      set(handles.Civ2,'BackgroundColor',[1 1 0])% indicate civ2 calculation is activated
     2023%      set(handles.Fix2,'BackgroundColor',[1 1 0])% indicate fix2 calculation is activated
     2024%      hseries=findobj(allchild(0),'Tag','series');
     2025%      Param=read_GUI(hseries);
     2026%      Param.Action.RUN=1;
     2027%      Param.ActionInput=read_GUI(handles.civ_input);
     2028%      if isfield(Param,'OutputSubDir')
     2029%      Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series
     2030%      end
     2031%      ParamPatch2=Param.ActionInput.Patch2; %store the patch1 parameters
     2032%      Param.ActionInput=rmfield(Param.ActionInput,'Patch2');% does not execute Patch
     2033%      Param.IndexRange.first_i=str2num(get(handles.ref_i,'String'));
     2034%      Param.IndexRange.last_i=Param.IndexRange.first_i;
     2035%      if strcmp(get(handles.ref_j,'Visible'),'on')
     2036%          Param.IndexRange.first_j=str2num(get(handles.ref_j,'String'));
     2037%          Param.IndexRange.last_j=Param.IndexRange.first_j;
     2038%      else
     2039%          Param.IndexRange.first_j=1;
     2040%          Param.IndexRange.last_j=1;
     2041%      end
     2042%      [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results
     2043%      bckcolor=get(handles.civ_input,'Color');
     2044%      set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calculation is finished
     2045%      set(handles.Fix1,'BackgroundColor',bckcolor)% indicate fix1 calculation is finished
     2046%      set(handles.Patch1,'BackgroundColor',bckcolor)% indicate Patch1 calculation is finished
     2047%      set(handles.Civ2,'BackgroundColor',bckcolor)% indicate civ2 calculation is finished
     2048%      set(handles.Fix2,'BackgroundColor',bckcolor)% indicate fix2 calculation is finished
     2049%
     2050%      %% prepare Param for iterative Patch processing without input file reading
     2051%      Param.Civ2_X=Data.Civ2_X;
     2052%      Param.Civ2_Y=Data.Civ2_Y;
     2053%      Param.Civ2_U=Data.Civ2_U;
     2054%      Param.Civ2_V=Data.Civ2_V;
     2055%      Param.Civ2_FF=Data.Civ2_FF;
     2056%      Param=rmfield(Param,'InputTable');%desactivate input file reading
     2057%     if isfield(Param.ActionInput,'Civ1')
     2058%         Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant
     2059%     end
     2060%     if isfield(Param.ActionInput,'Fix1')
     2061%         Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant
     2062%     end
     2063%     if isfield(Param.ActionInput,'Patch1')
     2064%         Param.ActionInput=rmfield(Param.ActionInput,'Patch1');%desactivate fix1:remove fix1 input param if relevant
     2065%     end
     2066%     if isfield(Param.ActionInput,'Civ2')
     2067%         Param.ActionInput=rmfield(Param.ActionInput,'Civ2');%desactivate civ2: remove civ2 input param if relevant
     2068%     end
     2069%     if isfield(Param.ActionInput,'Fix2')
     2070%         Param.ActionInput=rmfield(Param.ActionInput,'Fix2');%desactivate fix1:remove fix1 input param if relevant
     2071%     end
     2072%     SmoothingParam=(ParamPatch2.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value
     2073%     NbGood=numel(find(Data.Civ2_FF==0));
     2074%     NbExclude=zeros(1,7);% initialize the set of smoothing parameters
     2075%     DiffVel=zeros(1,7);% initialize the rms difference between patch and civ
     2076%     Param.ActionInput.Patch2=ParamPatch2;% retrieve Patch2 parameters
     2077%     for irho=1:7
     2078%         Param.ActionInput.Patch2.FieldSmooth=SmoothingParam(irho);
     2079%         [Data,errormsg]= civ_series(Param);%apply the processing fct
     2080%         if ~isempty(errormsg)
     2081%             msgbox_uvmat('ERROR',errormsg)
     2082%             return
     2083%         end
     2084%         ind_good=find(Data.Civ2_FF==0);
     2085%         Civ2_U_Diff=Data.Civ2_U(ind_good)-Data.Civ2_U_smooth(ind_good);
     2086%         Civ2_V_Diff=Data.Civ2_V(ind_good)-Data.Civ2_V_smooth(ind_good);
     2087%         DiffVel(irho)=sqrt(mean(Civ2_U_Diff.*Civ2_U_Diff+Civ2_V_Diff.*Civ2_V_Diff));
     2088%         NbExclude(irho)=(NbGood-numel(ind_good))/NbGood;
     2089%     end
     2090%     figure(1)
     2091%     semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r',SmoothingParam,0.1*ones(size(SmoothingParam)),'m')
     2092%     grid on
     2093%     legend('rms velocity diff. Patch2-Civ2 (pixels)','proportion of excluded vectors (between 0 to 1)','recommended value diff. Patch2-Civ2')
     2094%     xlabel('smoothing parameter')
     2095%     ylabel('smoothing effect')
     2096%     set(handles.TestPatch2,'BackgroundColor',[0 1 0])
     2097% else
     2098%     corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
     2099%     if ~isempty(corrfig)
     2100%         delete(corrfig)
     2101%     end
     2102%     hview_field=findobj(allchild(0),'tag','view_field');% look for view_field
     2103%     if ~isempty(hview_field)
     2104%         delete(hview_field)
     2105%     end
     2106% end
     2107%
     2108
     2109%'nomtype2pair': creates nomenclature for index pairs knowing the image nomenclature
    21052110%---------------------------------------------------------------------
    21062111function NomTypeNc=nomtype2pair(NomTypeIma,mode_selected)
  • trunk/src/series/test_patch_tps.m

    r1139 r1141  
    202202    str=num2str(FieldSmooth(irho));
    203203    str=regexprep(str,'\.','p');
    204     Ustr{irho}=['U_diff_' str];
    205     Vstr{irho}=['V_diff_' str];
     204    Ustr{irho}=['U_' str];
     205    Vstr{irho}=['V_' str];
    206206    Xstr{irho}=['X_' str];
    207207    Ystr{irho}=['Y_' str];
    208     Dimstr{irho}=['NbVec_' str];
     208    Dimstr{irho}='NbVec';
    209209    str_i{irho}=str;
    210210end
     
    213213DataOut.ListGlobalAttribute={'CivStage'};
    214214DataOut.CivStage=Param.InputFields.VelType;
    215 DataOut.ListVarName=[{'FieldSmooth','Diff_rms','NbExclude'} Xstr Ystr Ustr Vstr] ;
    216 DataOut.VarDimName=[{'FieldSmooth','FieldSmooth','FieldSmooth'} Dimstr Dimstr Dimstr Dimstr];
     215DataOut.ListVarName=[{'FieldSmooth','Diff_rms','NbExclude','FF','X','Y'} Ustr Vstr] ;
     216DataOut.VarDimName=[{'FieldSmooth','FieldSmooth','FieldSmooth','NbVec','NbVec','NbVec'} Dimstr Dimstr];
     217DataOut.VarAttribute{4}.Role='falseflag';
    217218DataOut.FieldSmooth=FieldSmooth;
    218219
     
    226227        Uin=Data.U(ind_good);
    227228        Vin=Data.V(ind_good);
     229        tic
    228230    for irho=1:NbSmooth
    229231        [SubRange,NbCentres,Coord_tps,U_tps,V_tps,~,U_smooth, V_smooth,~,FFres]=...
    230232            filter_tps([Xin Yin],Uin,Vin,[],SubDomainSize,FieldSmooth(irho),MaxDiff);
    231233        if irho==1
    232         figure(irho)
     234            DataOut.FF=zeros(size(Xin));
     235            DataOut.X=Xin;
     236            DataOut.Y=Yin;
     237        figure(1)
     238            cla
     239            scatter(Xin,Yin,1)
    233240            for irec=1:size(SubRange,3)
    234241                rectangle('Position',[SubRange(:,1,irec)' SubRange(:,2,irec)'-SubRange(:,1,irec)'])
    235             end
     242            end       
    236243            title('subdomains for thin shell splines (tps)')
    237244        end
    238245        ind_good=find(FFres==0);
     246        ind_false=find(FFres~=0);
    239247        U_Diff=Uin(ind_good)-U_smooth(ind_good);
    240248        V_Diff=Vin(ind_good)-V_smooth(ind_good);
    241249        DataOut.Diff_rms(irho)=sqrt(mean(U_Diff.*U_Diff+V_Diff.*V_Diff)/2);
    242250        DataOut.NbExclude(irho)=(NbGood-numel(ind_good))/NbGood;
    243         DataOut.(['X_' str_i{irho}])=Xin(ind_good);
    244         DataOut.(['Y_' str_i{irho}])=Yin(ind_good);
    245         DataOut.(['U_diff_' str_i{irho}])=U_soomth(ind_good);
    246         DataOut.(['V_diff_' str_i{irho}])=V_Diff;
    247     end
     251        DataOut.(['U_' str_i{irho}])=U_smooth;
     252        DataOut.(['V_' str_i{irho}])=V_smooth;
     253        DataOut.FF(ind_false)=FieldSmooth(irho);
     254    end
     255    time=toc
    248256    OutputFile=fullfile_uvmat(OutputPath,OutputDir,RootFileOut,FileExtOut,NomTypeOut,i1_series{1}(index),[],j1_series{1}(index),j2_series{1}(index))
    249257    errormsg=struct2nc(OutputFile,DataOut)
    250258end
    251 figure(1)
     259figure
    252260    semilogx(FieldSmooth,DataOut.Diff_rms,'b',FieldSmooth,DataOut.NbExclude,'r',FieldSmooth,0.1*ones(size(FieldSmooth)),'m')
    253261    grid on
    254262    title( [filecell{1,1} ':' Param.InputFields.VelType])
    255     legend({'rms vel. diff. ' ;' ratio excluded vectors';'recommended diff'})
     263    legend({'rms vel. diff. ' ;' ratio excluded vectors';'recommended diff'},'Location','northwest')
    256264    xlabel('smoothing parameter')
    257265    ylabel('rms (pixels) and exclusion ratio')
     266    OutputFig=fullfile(OutputPath,OutputDir,'plot_rms_diff.png')
     267    saveas(2,OutputFig)
    258268
    259269
Note: See TracChangeset for help on using the changeset viewer.