Changeset 860 for trunk/src


Ignore:
Timestamp:
Jan 27, 2015, 8:53:50 PM (10 years ago)
Author:
sommeria
Message:

Testpatch_fixed

Location:
trunk/src/series
Files:
2 edited

Legend:

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

    r859 r860  
    419419
    420420fill_GUI(Param,handles.civ_input)% fill the elements of the GUI series with the input parameters
    421 
    422 %update_CivOptions(handles,0)
    423 %set(handles.ConfigSource,'String','\default')
    424 
    425 % %Param=read_GUI(handles.civ_input)
    426 % hseries=findobj(allchild(0),'Name','series');% look for the GUI series
    427 % hhseries=guidata(hseries);%handles of elements in the GUI series
    428 % SeriesData=get(hseries,'UserData');%read parameters on the GUI series
    429 % if isfield (SeriesData,'ActionInput')
    430 %     SeriesData=rmfield(SeriesData,'ActionInput');% remove recorded civ parameters
    431 % end
    432 % set(hseries,'UserData',SeriesData)
    433 % %% exit the GUI and close it
    434 % %handles.output.ActionInput=rmfield(ActionInput;
    435 % guidata(hObject, handles);% Update handles structure
    436 % uiresume(handles.civ_input);
    437 % set(hhseries.ActionName,'BusyAction','cancel')
    438 % series('ActionName_Callback',hObject,eventdata,hhseries); %
    439 
    440421
    441422% -----------------------------------------------------------------------
     
    17651746    set(handles.TestCiv1,'BackgroundColor',[1 1 0])% paint TestCiv1 button to yellow to confirm civ launch 
    17661747    %Param.Action.RUN=1;
    1767     Param.ActionInput=read_GUI(handles.civ_input);
    1768     par_civ=Param.ActionInput.Civ1;
    1769     [Data,ImageName_B]=get_param_civ1(handles);
    1770 
    1771     %% create the figure view_field for image visualization
    1772     hview_field=view_field(Data); %view the image in the GUI view_field
    1773     set(0,'CurrentFigure',hview_field)
    1774     hhview_field=guihandles(hview_field);
    1775     set(hview_field,'CurrentAxes',hhview_field.PlotAxes)
    1776     ViewData=get(hview_field,'UserData');
    1777     ViewData.CivHandle=handles.civ_input;% indicate the handle of the civ GUI in view_field
    1778     ViewData.PlotAxes.B=imread(ImageName_B);%store the second image in the UserData of the GUI view_field
    17791748   
    1780     %% prepare measurement grid
    1781     if isfield(par_civ,'Grid')% grid points set as input
    1782             par_civ.Grid=dlmread(par_civ.Grid);
    1783             par_civ.Grid(1,:)=[];%the first line must be removed (heading in the grid file)
    1784     else% automatic grid
    1785         minix=floor(par_civ.Dx/2)-0.5;
    1786         maxix=minix+par_civ.Dx*floor((size(Data.A,2)-1)/par_civ.Dx);
    1787         miniy=floor(par_civ.Dy/2)-0.5;
    1788         maxiy=minix+par_civ.Dy*floor((size(Data.A,1)-1)/par_civ.Dy);
    1789         [GridX,GridY]=meshgrid(minix:par_civ.Dx:maxix,miniy:par_civ.Dy:maxiy);
    1790         ViewData.PlotAxes.X=reshape(GridX,[],1);
    1791         ViewData.PlotAxes.Y=reshape(GridY,[],1);
    1792     end
    1793 
    1794     set(hview_field,'UserData',ViewData)% store the info in the UserData of image view_field
     1749      hseries=findobj(allchild(0),'Tag','series');
     1750     Param=read_GUI(hseries);
     1751     Param.Action.RUN=1;
     1752     Param.ActionInput=read_GUI(handles.civ_input);
     1753     if isfield(Param,'OutputSubDir')
     1754     Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series
     1755     end
     1756     Param.ActionInput.Civ1.CorrSmooth=0;% launch Civ1 with no data point (to get the image names for A and B)
     1757     [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results
     1758   
     1759 %% create image data ImageData for display
     1760     ImageData.ListVarName={'ny','nx','A'};
     1761     ImageData.VarDimName= {'ny','nx',{'ny','nx'}};
     1762     ImageData.A=imread(Data.Civ1_ImageA); % read the first image
     1763     if ndims(ImageData.A)==3 %case of color image
     1764         ImageData.VarDimName= {'ny','nx',{'ny','nx','rgb'}};
     1765     end
     1766     ImageData.ny=[size(ImageData.A,1) 1];
     1767     ImageData.nx=[1 size(ImageData.A,2)];
     1768     ImageData.CoordUnit='pixel';% used to set equal scaling for x and y in image dispa=ly
     1769
     1770     %% create the figure view_field for image visualization
     1771     hview_field=view_field(ImageData); %view the image in the GUI view_field
     1772     set(0,'CurrentFigure',hview_field)
     1773     hhview_field=guihandles(hview_field);
     1774     set(hview_field,'CurrentAxes',hhview_field.PlotAxes)
     1775     ViewData=get(hview_field,'UserData');
     1776     ViewData.CivHandle=handles.civ_input;% indicate the handle of the civ GUI in view_field
     1777     ViewData.PlotAxes.X=Data.Civ1_X';
     1778     ViewData.PlotAxes.Y=Data.Civ1_Y';
     1779     ViewData.PlotAxes.B=imread(Data.Civ1_ImageB);%store the second image in the UserData of the GUI view_field
     1780     set(hview_field,'UserData',ViewData)% store the info in the UserData of image view_field
    17951781   
    17961782    %% look for a current figure for image correlation display
     
    18261812
    18271813if get(handles.TestPatch1,'Value')% if TestPatch1 is activated
    1828      set(handles.TestPatch1,'BackgroundColor',[1 1 0])%paint TestPatch1 button in yellow to induicate activation
     1814     set(handles.TestPatch1,'BackgroundColor',[1 1 0])%paint TestPatch1 button in yellow to indicate activation
     1815     set(handles.Civ1,'BackgroundColor',[1 1 0])% indicate civ1 calculation is performed
    18291816     hseries=findobj(allchild(0),'Tag','series');
    18301817     Param=read_GUI(hseries);
    18311818     Param.Action.RUN=1;
    18321819     Param.ActionInput=read_GUI(handles.civ_input);
     1820     if isfield(Param,'OutputSubDir')
    18331821     Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series
     1822     end
     1823     ParamPatch1=Param.ActionInput.Patch1; %store the patch1 parameters
     1824     Param.ActionInput=rmfield(Param.ActionInput,'Patch1');% does not execute Patch
    18341825     [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results
     1826     bckcolor=get(handles.civ_input,'Color');
     1827     set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calculation is finished
    18351828     
    18361829     %% prepare Param for iterative Patch processing without input file reading
     
    18471840        Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant
    18481841    end
    1849     SmoothingParam=(Param.ActionInput.Patch1.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value
     1842    SmoothingParam=(ParamPatch1.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value
    18501843    NbGood=numel(find(Data.Civ1_FF==0));
     1844    NbExclude=zeros(1,7);% initialize the set of smoothing parameters
     1845    DiffVel=zeros(1,7);% initialize the rms difference between patch and civ
     1846    Param.ActionInput.Patch1=ParamPatch1;% retrieve Patch1 parameters
    18511847    for irho=1:7
    18521848        Param.ActionInput.Patch1.FieldSmooth=SmoothingParam(irho);
     
    18621858        NbExclude(irho)=(NbGood-numel(ind_good))/NbGood;
    18631859    end
    1864     figure
     1860    figure(1)
     1861    hold on
    18651862    semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r')
    18661863    grid on
     
    18681865    xlabel('smoothing parameter')
    18691866    ylabel('smoothing effect')
    1870     set(handles.TestPatch1,'BackgroundColor',[1 0 0])
     1867    set(handles.TestPatch1,'BackgroundColor',[0 1 0])
    18711868else
    18721869    corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
     
    19151912    set(0,'CurrentFigure',hview_field)
    19161913    % plot the boundaries of the subdomains used for patch
    1917     RectCentre=squeeze(mean(Data.Civ1_SubRange,2));
    19181914    for isub=1:size(Data.Civ1_SubRange,3);
    19191915        pos_x=Data.Civ1_SubRange(1,1,isub);
     
    19741970
    19751971
     1972% --- Executes on button press in TestPatch2.
     1973function TestPatch2_Callback(hObject, eventdata, handles)
     1974if get(handles.TestPatch2,'Value')% if TestPatch2 is activated
     1975     set(handles.TestPatch2,'BackgroundColor',[1 1 0])%paint TestPatch2 button in yellow to indicate activation
     1976     set(handles.Civ1,'BackgroundColor',[1 1 0])% indicate civ1 calculation is activated
     1977     set(handles.Fix1,'BackgroundColor',[1 1 0])% indicate fix1 calculation is activated
     1978     set(handles.Patch1,'BackgroundColor',[1 1 0])% indicate Patch1 calculation is activated
     1979     set(handles.Civ2,'BackgroundColor',[1 1 0])% indicate civ2 calculation is activated
     1980     set(handles.Fix2,'BackgroundColor',[1 1 0])% indicate fix2 calculation is activated
     1981     hseries=findobj(allchild(0),'Tag','series');
     1982     Param=read_GUI(hseries);
     1983     Param.Action.RUN=1;
     1984     Param.ActionInput=read_GUI(handles.civ_input);
     1985     if isfield(Param,'OutputSubDir')
     1986     Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series
     1987     end
     1988     ParamPatch2=Param.ActionInput.Patch2; %store the patch1 parameters
     1989     Param.ActionInput=rmfield(Param.ActionInput,'Patch2');% does not execute Patch
     1990     [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results
     1991     bckcolor=get(handles.civ_input,'Color');
     1992     set(handles.Civ1,'BackgroundColor',bckcolor)% indicate civ1 calculation is finished
     1993     set(handles.Fix1,'BackgroundColor',bckcolor)% indicate fix1 calculation is finished
     1994     set(handles.Patch1,'BackgroundColor',bckcolor)% indicate Patch1 calculation is finished
     1995     set(handles.Civ2,'BackgroundColor',bckcolor)% indicate civ2 calculation is finished
     1996     set(handles.Fix2,'BackgroundColor',bckcolor)% indicate fix2 calculation is finished
     1997     
     1998     %% prepare Param for iterative Patch processing without input file reading
     1999     Param.Civ2_X=Data.Civ2_X;
     2000     Param.Civ2_Y=Data.Civ2_Y;
     2001     Param.Civ2_U=Data.Civ2_U;
     2002     Param.Civ2_V=Data.Civ2_V;
     2003     Param.Civ2_FF=Data.Civ2_FF;
     2004     Param=rmfield(Param,'InputTable');%desactivate input file reading
     2005    if isfield(Param.ActionInput,'Civ1')
     2006        Param.ActionInput=rmfield(Param.ActionInput,'Civ1');%desactivate civ1: remove civ1 input param if relevant
     2007    end
     2008    if isfield(Param.ActionInput,'Fix1')
     2009        Param.ActionInput=rmfield(Param.ActionInput,'Fix1');%desactivate fix1:remove fix1 input param if relevant
     2010    end
     2011    if isfield(Param.ActionInput,'Patch1')
     2012        Param.ActionInput=rmfield(Param.ActionInput,'Patch1');%desactivate fix1:remove fix1 input param if relevant
     2013    end
     2014    if isfield(Param.ActionInput,'Civ2')
     2015        Param.ActionInput=rmfield(Param.ActionInput,'Civ2');%desactivate civ2: remove civ2 input param if relevant
     2016    end
     2017    if isfield(Param.ActionInput,'Fix2')
     2018        Param.ActionInput=rmfield(Param.ActionInput,'Fix2');%desactivate fix1:remove fix1 input param if relevant
     2019    end
     2020    SmoothingParam=(ParamPatch2.FieldSmooth/10)*2.^(1:7);%scan the smoothing param from 1/10 to 12.8 current value
     2021    NbGood=numel(find(Data.Civ2_FF==0));
     2022    NbExclude=zeros(1,7);% initialize the set of smoothing parameters
     2023    DiffVel=zeros(1,7);% initialize the rms difference between patch and civ
     2024    Param.ActionInput.Patch2=ParamPatch2;% retrieve Patch2 parameters
     2025    for irho=1:7
     2026        Param.ActionInput.Patch2.FieldSmooth=SmoothingParam(irho);
     2027        [Data,errormsg]= civ_series(Param);%apply the processing fct
     2028        if ~isempty(errormsg)
     2029            msgbox_uvmat('ERROR',errormsg)
     2030            return
     2031        end
     2032        ind_good=find(Data.Civ2_FF==0);
     2033        Civ2_U_Diff=Data.Civ2_U(ind_good)-Data.Civ2_U_smooth(ind_good);
     2034        Civ2_V_Diff=Data.Civ2_V(ind_good)-Data.Civ2_V_smooth(ind_good);
     2035        DiffVel(irho)=sqrt(mean(Civ2_U_Diff.*Civ2_U_Diff+Civ2_V_Diff.*Civ2_V_Diff));
     2036        NbExclude(irho)=(NbGood-numel(ind_good))/NbGood;
     2037    end
     2038    figure(1)
     2039    hold on
     2040    semilogx(SmoothingParam,DiffVel,'b',SmoothingParam,NbExclude,'r')
     2041    grid on
     2042    legend('rms velocity diff. Patch2-Civ2 (pixels)','proportion of excluded vectors (between 0 to 1)')
     2043    xlabel('smoothing parameter')
     2044    ylabel('smoothing effect')
     2045    set(handles.TestPatch2,'BackgroundColor',[0 1 0])
     2046else
     2047    corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
     2048    if ~isempty(corrfig)
     2049        delete(corrfig)
     2050    end
     2051    hview_field=findobj(allchild(0),'tag','view_field');% look for view_field
     2052    if ~isempty(hview_field)
     2053        delete(hview_field)
     2054    end
     2055end
     2056   
     2057
    19762058%'nomtype2pair': creates nomencalture for index pairs knowing the image nomenclature
    19772059%---------------------------------------------------------------------
     
    21372219end
    21382220
    2139 
    2140 %------------------------------------------------------------------------
    2141 function [Data,ImageName_B]=get_param_civ1(handles)
    2142 
    2143  ref_i=str2double(get(handles.ref_i,'String'));% read reference i index
    2144  if strcmp(get(handles.ref_j,'Visible'),'on')
    2145      ref_j=str2double(get(handles.ref_j,'String'));% read reference j index if relevant
    2146  else
    2147      ref_j=1;%default j index
    2148  end
    2149  Data.ListVarName={'ny','nx','A'};
    2150  Data.VarDimName= {'ny','nx',{'ny','nx'}};
    2151  hseries=findobj(allchild(0),'Tag','series');
    2152  hhseries=guidata(hseries);
    2153  InputTable=get(hhseries.InputTable,'Data');
    2154  ind_A=1;
    2155  if strcmp(InputTable{1,5},'.nc');
    2156      ind_A=2;
    2157  end
    2158  list_pair=get(handles.ListPairCiv1,'String');%get the menu of image pairs
    2159  PairString=list_pair{get(handles.ListPairCiv1,'Value')};
    2160  [ind1,ind2,mode]=find_pair_indices(PairString,ref_i,ref_j);%,MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j)
    2161  switch mode
    2162      case 'Di'
    2163          i1=ref_i-ind1;
    2164          i2=ref_i+ind2;
    2165          j1=ref_j;
    2166          j2=ref_j;
    2167      case 'Dj'
    2168          i1=ref_i;
    2169          i2=ref_i;
    2170          j1=ref_j-ind1;
    2171          j2=ref_j+ind2;
    2172      case 'burst'
    2173          i1=ref_i;
    2174          i2=ref_i;
    2175          j1=ind1;
    2176          j2=ind2;
    2177  end
    2178  ImageName_A=fullfile_uvmat(InputTable{ind_A,1},InputTable{ind_A,2},InputTable{ind_A,3},InputTable{ind_A,5},InputTable{ind_A,4},...
    2179      i1,[],j1);
    2180  ImageName_B=fullfile_uvmat(InputTable{ind_A,1},InputTable{ind_A,2},InputTable{ind_A,3},InputTable{ind_A,5},InputTable{ind_A,4},...
    2181      i2,[],j2);
    2182  Data.A=imread(ImageName_A); % read the first image
    2183  if ndims(Data.A)==3 %case of color image
    2184      Data.VarDimName= {'ny','nx',{'ny','nx','rgb'}};
    2185  end
    2186  Data.ny=[size(Data.A,1) 1];
    2187  Data.nx=[1 size(Data.A,2)];
    2188  Data.CoordUnit='pixel';% used to set equal scaling for x and y in image dispa=ly
    2189 %  par_civ1=read_GUI(handles.Civ1);
    2190 % FileInfo=get_file_info(ImageName_A);
    2191 %  par_civ1.FileTypeA=FileInfo.FileType;
    2192 %  par_civ1.ImageWidth=size(Data.A,2);
    2193 %  par_civ1.ImageHeight=size(Data.A,1);
    2194 %  par_civ1.Mask='all';% will provide only the grid set for PIV, no image correlation
    2195 %  par_civ1.FrameIndexA=num2str(i1);
    2196 %  par_civ1.FrameIndexB=num2str(i2);
    2197 %  par_civ1.ImageName_B=ImageName_B;
    2198 
    21992221%------------------------------------------------------------------------
    22002222% --- Executes on button press in ImportParam.
     
    22432265% --- Executes on selection change in CheckCiv3.
    22442266function CheckCiv3_Callback(hObject, eventdata, handles)
    2245    
     2267
     2268
    22462269%------------------------------------------------------------------------
    22472270% --- Executes on key press with selection of a uicontrol
     
    22572280
    22582281
    2259 % --- Executes on button press in TestPatch2.
    2260 function TestPatch2_Callback(hObject, eventdata, handles)
    2261 
    2262 
    2263 
     2282
     2283
     2284
     2285
  • trunk/src/series/civ_series.m

    r859 r860  
    737737        Data.Civ2_C=reshape(ctable,[],1);
    738738        Data.Civ2_F=reshape(F,[],1);
     739    elseif ~isfield(Data,'ListVarName') % we start there, using existing Civ2 data
     740        if exist('ncfile','var')
     741            CivFile=ncfile;
     742            [Data,tild,tild,errormsg]=nc2struct(CivFile);%read civ1 and fix1 data in the existing netcdf file
     743            if ~isempty(errormsg)
     744                disp_uvmat('ERROR',errormsg,checkrun)
     745                return
     746            end         
     747        elseif isfield(Param,'Civ2_X')% use Civ2 data as input in Param (test mode)
     748            Data.ListGlobalAttribute={};
     749            Data.ListVarName={};
     750            Data.VarDimName={};
     751            Data.Civ2_X=Param.Civ2_X;
     752            Data.Civ2_Y=Param.Civ2_Y;
     753            Data.Civ2_U=Param.Civ2_U;
     754            Data.Civ2_V=Param.Civ2_V;
     755            Data.Civ2_FF=Param.Civ2_FF;
     756        end
    739757    end
    740758   
     
    786804        Data.ListGlobalAttribute=[Data.ListGlobalAttribute Patch2_param];
    787805       
    788        
    789         %         Data.ListGlobalAttribute=[Data.ListGlobalAttribute {'Patch2_FieldSmooth','Patch2_MaxDiff','Patch2_SubDomainSize'}];
    790         %         Data.Patch2_FieldSmooth=Param.ActionInput.Patch2.FieldSmooth;
    791         %         Data.Patch2_MaxDiff=Param.ActionInput.Patch2.MaxDiff;
    792         %         Data.Patch2_SubDomainSize=Param.ActionInput.Patch2.SubDomainSize;
    793806        nbvar=length(Data.ListVarName);
    794807        Data.ListVarName=[Data.ListVarName {'Civ2_U_smooth','Civ2_V_smooth','Civ2_SubRange','Civ2_NbCentres','Civ2_Coord_tps','Civ2_U_tps','Civ2_V_tps'}];
     
    801814        Data.VarAttribute{nbvar+6}.Role='vector_x';
    802815        Data.VarAttribute{nbvar+7}.Role='vector_y';
    803         Data.Civ2_U_smooth=zeros(size(Data.Civ2_X));
    804         Data.Civ2_V_smooth=zeros(size(Data.Civ2_X));
     816        Data.Civ2_U_smooth=Data.Civ2_U; % zeros(size(Data.Civ2_X));
     817        Data.Civ2_V_smooth=Data.Civ2_V; %zeros(size(Data.Civ2_X));
    805818        if isfield(Data,'Civ2_FF')
    806819            ind_good=find(Data.Civ2_FF==0);
Note: See TracChangeset for help on using the changeset viewer.