Changeset 231


Ignore:
Timestamp:
Apr 5, 2011, 12:46:34 AM (13 years ago)
Author:
sommeria
Message:

interactive test for piv introduced various bug corrections

Location:
trunk/src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r230 r231  
    21192119            disp(cmd_str);
    21202120        else       %run PIVlab if selected
    2121             image1=imread(par_civ1.filename_ima_a);
    2122             image2=imread(par_civ1.filename_ima_b);     
    2123             stepx=str2num(par_civ1.dx);
    2124             stepy=str2num(par_civ1.dy);
    2125             ibx2=ceil(str2num(par_civ1.ibx)/2);
    2126             iby2=ceil(str2num(par_civ1.iby)/2);
    2127             isx2=ceil(str2num(par_civ1.isx)/2);
    2128             isy2=ceil(str2num(par_civ1.isy)/2);
    2129             shiftx=str2num(par_civ1.shiftx);
    2130             shifty=str2num(par_civ1.shifty);
    2131 %             ibx=2*ibx2-1;%ibx and iby odd, reduced by 1 if even
    2132 %             iby=2*iby2-1;
    2133             miniy=max(1+isy2-shifty,1+iby2);
    2134             minix=max(1+isx2-shiftx,1+ibx2);
    2135             maxiy=min(size(image1,1)-isy2-shifty,size(image1,1)-iby2);
    2136             maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2);
    2137 %             maxix=stepx*(floor(size(image1_roi,2)/stepx))-(2*ibx2-2)+ibx2;
    2138             [GridX,GridY]=meshgrid(miniy:stepy:maxiy,minix:stepx:maxix);
    2139             PointCoord(:,1)=reshape(GridX,[],1);
    2140             PointCoord(:,2)=reshape(GridY,[],1);
    2141                [xtable ytable utable vtable ctable typevector] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty,PointCoord, 1, []);
    2142                Data.ListGlobalAttribute={'title','Time','Dt'};
    2143                Data.title='PIVlab';
    2144                Data.Time=str2double(par_civ1.T0);
    2145                Data.Dt=str2double(par_civ1.Dt);
    2146                Data.ListVarName={'X','Y','U','V','C','FF'};%  cell array containing the names of the fields to record
    2147                Data.VarDimName={'nbvec','nbvec','nbvec','nbvec','nbvec','nbvec'};
    2148                 Data.VarAttribute{1}.Role='coord_x';
    2149             Data.VarAttribute{2}.Role='coord_y';
    2150             Data.VarAttribute{3}.Role='vector_x';
    2151             Data.VarAttribute{4}.Role='vector_y';
    2152             Data.VarAttribute{5}.Role='errorflag';
    2153             Data.X=reshape(xtable,[],1);
    2154             Data.Y=reshape(ytable,[],1);
    2155             Data.U=reshape(utable,[],1);
    2156             Data.V=reshape(vtable,[],1);
    2157             Data.C=reshape(ctable,[],1);
    2158             Data.FF=reshape(~typevector,[],1);
     2121            Data=civ_uvmat(par_civ1);
     2122%             image1=imread(par_civ1.filename_ima_a);
     2123%             image2=imread(par_civ1.filename_ima_b);     
     2124%             stepx=str2num(par_civ1.dx);
     2125%             stepy=str2num(par_civ1.dy);
     2126%             ibx2=ceil(str2num(par_civ1.ibx)/2);
     2127%             iby2=ceil(str2num(par_civ1.iby)/2);
     2128%             isx2=ceil(str2num(par_civ1.isx)/2);
     2129%             isy2=ceil(str2num(par_civ1.isy)/2);
     2130%             shiftx=str2num(par_civ1.shiftx);
     2131%             shifty=str2num(par_civ1.shifty);
     2132% %             ibx=2*ibx2-1;%ibx and iby odd, reduced by 1 if even
     2133% %             iby=2*iby2-1;
     2134%             miniy=max(1+isy2-shifty,1+iby2);
     2135%             minix=max(1+isx2-shiftx,1+ibx2);
     2136%             maxiy=min(size(image1,1)-isy2-shifty,size(image1,1)-iby2);
     2137%             maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2);
     2138%             [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy);
     2139%             PointCoord(:,1)=reshape(GridX,[],1);
     2140%             PointCoord(:,2)=reshape(GridY,[],1);
     2141%             % caluclate velocity data (y and v in indices, reverse to y component)
     2142%             [xtable ytable utable vtable ctable typevector] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty,PointCoord, 1, []);
     2143%                Data.ListGlobalAttribute={'title','Time','Dt'};
     2144%                Data.title='PIVlab';
     2145%                Data.Time=str2double(par_civ1.T0);
     2146%                Data.Dt=str2double(par_civ1.Dt);
     2147%                Data.ListVarName={'X','Y','U','V','C','FF'};%  cell array containing the names of the fields to record
     2148%                Data.VarDimName={'nbvec','nbvec','nbvec','nbvec','nbvec','nbvec'};
     2149%                 Data.VarAttribute{1}.Role='coord_x';
     2150%             Data.VarAttribute{2}.Role='coord_y';
     2151%             Data.VarAttribute{3}.Role='vector_x';
     2152%             Data.VarAttribute{4}.Role='vector_y';
     2153%             Data.VarAttribute{5}.Role='errorflag';
     2154%             Data.X=reshape(xtable,[],1);
     2155%             Data.Y=reshape(size(image1,1)-ytable+1,[],1);
     2156%             Data.U=reshape(utable,[],1);
     2157%             Data.V=reshape(-vtable,[],1);
     2158%             Data.C=reshape(ctable,[],1);
     2159%             Data.FF=reshape(~typevector,[],1);
    21592160            errormsg=struct2nc(filecell.nc.civ1{ifile,j},Data);
    21602161            if isempty(errormsg)
     
    42894290end
    42904291
    4291 
     4292%------------------------------------------------------------------------
     4293% --- civ using pivlab
     4294function Data=civ_uvmat(par_civ1)
     4295%------------------------------------------------------------------------
     4296image1=imread(par_civ1.filename_ima_a);
     4297image2=imread(par_civ1.filename_ima_b);
     4298stepx=str2num(par_civ1.dx);
     4299stepy=str2num(par_civ1.dy);
     4300ibx2=ceil(str2num(par_civ1.ibx)/2);
     4301iby2=ceil(str2num(par_civ1.iby)/2);
     4302isx2=ceil(str2num(par_civ1.isx)/2);
     4303isy2=ceil(str2num(par_civ1.isy)/2);
     4304shiftx=str2num(par_civ1.shiftx);
     4305shifty=str2num(par_civ1.shifty);
     4306miniy=max(1+isy2-shifty,1+iby2);
     4307minix=max(1+isx2-shiftx,1+ibx2);
     4308maxiy=min(size(image1,1)-isy2-shifty,size(image1,1)-iby2);
     4309maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2);
     4310[GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy);
     4311PointCoord(:,1)=reshape(GridX,[],1);
     4312PointCoord(:,2)=reshape(GridY,[],1);
     4313
     4314% caluclate velocity data (y and v in indices, reverse to y component)
     4315[xtable ytable utable vtable ctable typevector] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty,PointCoord, 1, []);
     4316Data.ListGlobalAttribute={'title','Time','Dt'};
     4317Data.title='PIVlab';
     4318Data.Time=str2double(par_civ1.T0);
     4319Data.Dt=str2double(par_civ1.Dt);
     4320Data.ListVarName={'X','Y','U','V','C','FF'};%  cell array containing the names of the fields to record
     4321Data.VarDimName={'nbvec','nbvec','nbvec','nbvec','nbvec','nbvec'};
     4322Data.VarAttribute{1}.Role='coord_x';
     4323Data.VarAttribute{2}.Role='coord_y';
     4324Data.VarAttribute{3}.Role='vector_x';
     4325Data.VarAttribute{4}.Role='vector_y';
     4326Data.VarAttribute{5}.Role='errorflag';
     4327Data.X=reshape(xtable,[],1);
     4328Data.Y=reshape(size(image1,1)-ytable+1,[],1);
     4329Data.U=reshape(utable,[],1);
     4330Data.V=reshape(-vtable,[],1);
     4331Data.C=reshape(ctable,[],1);
     4332Data.FF=reshape(~typevector,[],1);
    42924333
    42934334%------------------------------------------------------------------------
     
    46384679    Data.nx=[1 size(Data.A,2)];
    46394680    par_civ1=read_param_civ1(handles,filecell.ima1.civ1{1});
    4640    
    4641             stepx=str2num(par_civ1.dx);
    4642             stepy=str2num(par_civ1.dy);
    4643             ibx2=ceil(str2num(par_civ1.ibx)/2);
    4644             iby2=ceil(str2num(par_civ1.iby)/2);
    4645             isx2=ceil(str2num(par_civ1.isx)/2);
    4646             isy2=ceil(str2num(par_civ1.isy)/2);
    4647             shiftx=str2num(par_civ1.shiftx);
    4648             shifty=str2num(par_civ1.shifty);
    4649 %             ibx=2*ibx2-1;%ibx and iby odd, reduced by 1 if even
    4650 %             iby=2*iby2-1;
    4651             miniy=max(1+isy2-shifty,1+iby2);
    4652             minix=max(1+isx2-shiftx,1+ibx2);
    4653             maxiy=min(size(image1,1)-isy2-shifty,size(image1,1)-iby2);
    4654             maxix=min(size(image1,2)-isx2-shiftx,size(image1,2)-ibx2);
    4655 %             maxix=stepx*(floor(size(image1_roi,2)/stepx))-(2*ibx2-2)+ibx2;
    4656             [GridX,GridY]=meshgrid(miniy:stepy:maxiy,minix:stepx:maxix);
    4657             PointCoord(:,1)=reshape(GridX,[],1);
    4658             PointCoord(:,2)=reshape(GridY,[],1);
    4659     hh=view_field(Data);
    4660     set(0,'CurrentFigure',hh)
    4661     plot(PointCoord(:,2),PointCoord(:,1),'+')
    4662     ViewData=get(hh,'UserData');
     4681    par_civ1.filename_ima_a=filecell.ima1.civ1{1};
     4682    par_civ1.filename_ima_b=filecell.ima2.civ1{1};
     4683    par_civ1.T0=0;
     4684    par_civ1.Dt=1;
     4685    Data=civ_uvmat(par_civ1);
     4686%     stepx=str2num(par_civ1.dx);
     4687%     stepy=str2num(par_civ1.dy);
     4688%     ibx2=ceil(str2num(par_civ1.ibx)/2);
     4689%     iby2=ceil(str2num(par_civ1.iby)/2);
     4690%     isx2=ceil(str2num(par_civ1.isx)/2);
     4691%     isy2=ceil(str2num(par_civ1.isy)/2);
     4692%     shiftx=str2num(par_civ1.shiftx);
     4693%     shifty=str2num(par_civ1.shifty);
     4694% %             ibx=2*ibx2-1;%ibx and iby odd, reduced by 1 if even
     4695% %             iby=2*iby2-1;
     4696%     miniy=max(1+isy2-shifty,1+iby2)
     4697%     minix=max(1+isx2-shiftx,1+ibx2)
     4698%     maxiy=min(size(Data.A,1)-isy2-shifty,size(Data.A,1)-iby2)
     4699%     maxix=min(size(Data.A,2)-isx2-shiftx,size(Data.A,2)-ibx2)
     4700% %             maxix=stepx*(floor(size(image1_roi,2)/stepx))-(2*ibx2-2)+ibx2;
     4701%     [GridX,GridY]=meshgrid(minix:stepx:maxix,miniy:stepy:maxiy);
     4702%     PointCoord(:,1)=reshape(GridX,[],1);
     4703%     PointCoord(:,2)=reshape(GridY,[],1);
     4704    Data.ListVarName=[Data.ListVarName {'ny','nx','A'}];
     4705    Data.VarDimName=[Data.VarDimName {'ny','nx',{'ny','nx'}}];
     4706    Data.A=imread(filecell.ima1.civ1{1});
     4707    Data.ny=[size(Data.A,1) 1];
     4708    Data.nx=[1 size(Data.A,2)];
     4709    hview_field=view_field(Data);
     4710    set(0,'CurrentFigure',hview_field)
     4711    hhview_field=guihandles(hview_field);
     4712    set(hview_field,'CurrentAxes',hhview_field.axes3)
     4713    %hpoints=line(PointCoord(:,1),PointCoord(:,2),'Color','y','LineStyle','.','Marker','*','LineWidth',4,'Tag','grid_points');
     4714    ViewData=get(hview_field,'UserData');
     4715    ViewData.CivHandle=handles.civ;% indicate the handle of the civ GUI in view_field
    46634716    ViewData.axes3.B=imread(filecell.ima2.civ1{1});%store the second image in the UserData of the GUI view_field
     4717    ViewData.axes3.X=Data.X; %keep the set of points in memeory
     4718    ViewData.axes3.Y=Data.Y;
     4719    set(hview_field,'UserData',ViewData)
    46644720    corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
    46654721    if isempty(corrfig)
     
    46694725        set(corrfig,'DeleteFcn',{@closeview_field})%
    46704726    end
    4671     set(hh,'UserData',ViewData)
    46724727else
    46734728    corrfig=findobj(allchild(0),'tag','corrfig');% look for a current figure for image correlation display
  • trunk/src/geometry_calib.m

    r227 r231  
    10721072    end
    10731073end
    1074 axes(hhuvmat.axes3)
     1074%axes(hhuvmat.axes3)
     1075set(0,'CurrentFigure',huvmat)
     1076set(huvmat,'CurrentAxes',hhuvmat.axes3)
    10751077hh=findobj('Tag','calib_points');
    10761078if  ~isempty(ObjectData.Coord) && isempty(hh)
  • trunk/src/get_field.m

    r227 r231  
    168168inputfile=get(handles.inputfile,'String');
    169169Field=nc2struct(inputfile,[]);% reads the  field description, without data
    170 Field.ListGlobalAttribute
    171170if isfield(Field,'Txt')
    172171    msgbox_uvmat('ERROR',Field.Txt)
     
    835834    huvmat=findobj(allchild(0),'tag','uvmat');
    836835    if isempty(huvmat)
    837         uvmat(inputfile)
     836        input.InputFile=inputfile;
     837        input.FieldsString={'get_field...'};
     838        uvmat(input)
    838839    else
    839840        set(huvmat,'Visible','on')%make uvmat visible (bugs can hide it in some cases)
  • trunk/src/mouse_down.m

    r210 r231  
    239239        if ~isempty(hset_object)
    240240            sethandles=guidata(hset_object);
    241             ObjectData=read_set_object(sethandles);
     241            ObjectData=read_set_object(sethandles); %read object features in the GUI set_object
    242242            ObjectData.Coord=[]; %reset previous object coordinates
    243243            ObjectData.Coord(1,1)=xy(1,1);
     
    263263            end
    264264            set(hhuvmat.list_object_1,'String',list_str)
    265             list_str{end+1}='...';
     265            %list_str{end+1}='...';
    266266            set(hhuvmat.list_object_2,'String',list_str)
    267267            if strcmp(fig_tag,'view_field')%we are in view_field plot
  • trunk/src/mouse_motion.m

    r225 r231  
    2929end
    3030FigData=get(hObject,'UserData');
     31
    3132if ishandle(FigData)% case of a zoom plot, the handle of the parent rectangle is stored in UserData, its parent is the plotting axes of the rectangle
    3233    currentfig=get(get(FigData,'parent'),'parent');
     
    4849    test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on');
    4950end
    50 hciv=findobj(allchild(0),'tag','civ');%find the civ interface handle
    51 if ~isempty(hciv) && strcmp(get(currentfig,'tag'),'view_field')
    52     hhciv=guidata(hciv);
    53     test_piv =get(hhciv.TestCiv1,'Value');
    54 end
     51test_piv=0;
     52if isfield(FigData,'CivHandle')
     53    if ~ishandle(FigData.CivHandle)
     54        delete(hObject)
     55        return
     56    end
     57    hhciv=guidata(FigData.CivHandle);
     58    test_piv=1;
     59end
     60% hciv=findobj(allchild(0),'tag','civ');%find the civ interface handle
     61% if ~isempty(hciv) && strcmp(get(currentfig,'tag'),'view_field')
     62%     hhciv=guidata(hciv);
     63%     test_piv =get(hhciv.TestCiv1,'Value');
     64% end
    5565
    5666%find the current axe 'haxes' and display the current mouse position or uicontrol tag
     
    209219                    if test_piv
    210220                       par=civ('read_param_civ1',hhciv);
    211                         if isfield(Field,'A')
    212                             dx=str2double(par.dx);
    213                             dy=str2double(par.dy);
    214                             xround=x(1)+dx*round((xy(1,1)-x(1))/dx);% index x of pixel
    215                             yround=y(1)+dy*round((xy(1,2)-y(1))/dy);% index y of pixel
    216                         end
     221%                        PointCoord=Field.X;
     222                       [dd,ind_pt]=min(abs(Field.X-xy(1,1))+abs(Field.Y-xy(1,2)));
     223%                        [dd,ind_y]=min(abs(Field.Y-xy(1,2)));
     224                       xround=Field.X(ind_pt);
     225                       yround=Field.Y(ind_pt);
     226%                         if isfield(Field,'A')
     227%                             dx=str2double(par.dx);
     228%                             dy=str2double(par.dy);
     229%                             xround=x(1)+dx*round((xy(1,1)-x(1))/dx);% index x of pixel
     230%                             yround=y(1)+dy*round((xy(1,2)-y(1))/dy);% index y of pixel
     231%                         end
    217232                        % mark the correlation box with a rectangle
    218233                        ibx2=floor((str2double(par.ibx)-1)/2);
     
    238253                            set(hhhh,'Position',[xround-isx2+shiftx yround-isy2+shifty 2*isx2 2*isy2])
    239254                        end
    240                         Asub=Field.A(yround-iby2:yround+iby2,xround-ibx2:xround+ibx2);%first sub-image
    241                         Asub=reshape(Asub,[],1);%first sub-image reshaped as matlab vector
    242                         rangx(1)=-(isx2-ibx2)+shiftx;
    243                         rangx(2)=isx2-ibx2+shiftx;
    244                         rangy(1)=-(isy2-iby2)-shifty;
    245                         rangy(2)=(isy2-iby2)-shifty
    246                         correl=zeros(rangy(2)-rangy(1)+1,rangx(2)-rangx(1)+1);
    247                         for id=rangx(1):rangx(2)
    248                             for jd=rangy(1):rangy(2)
    249                                 Bsub=Field.B(yround-iby2+jd:yround+iby2+jd,xround-ibx2+id:xround+ibx2+id);
    250                                 Bsub=reshape(Bsub,[],1);
    251                                 correl(jd-rangy(1)+1,id-rangx(1)+1)=corr(double(Asub),double(Bsub));
    252                             end
    253                         end
     255                        [xtable ytable utable vtable ctable typevector result_conv] = pivlab (Field.A,Field.B,ibx2,iby2,isx2,isy2,shiftx,shifty,[xround yround], 1, []);
     256%                         Asub=Field.A(yround-iby2:yround+iby2,xround-ibx2:xround+ibx2);%first sub-image
     257%                         Asub=reshape(Asub,[],1);%first sub-image reshaped as matlab vector
     258                         rangx(1)=-(isx2-ibx2)+shiftx;
     259                         rangx(2)=isx2-ibx2+shiftx;
     260                         rangy(1)=-(isy2-iby2)-shifty;
     261                         rangy(2)=(isy2-iby2)-shifty;
     262%                         correl=zeros(rangy(2)-rangy(1)+1,rangx(2)-rangx(1)+1);
     263%                         for id=rangx(1):rangx(2)
     264%                             for jd=rangy(1):rangy(2)
     265%                                 Bsub=Field.B(yround-iby2+jd:yround+iby2+jd,xround-ibx2+id:xround+ibx2+id);
     266%                                 Bsub=reshape(Bsub,[],1);
     267%                                 correl(jd-rangy(1)+1,id-rangx(1)+1)=corr(double(Asub),double(Bsub));
     268%                             end
     269%                         end
    254270                        %correl=uint8(63.5*correl+63.5);
    255271                        hcorr=[];
     
    264280                            if ~isempty(corrfig)
    265281                                set(0,'CurrentFigure',corrfig(1))
    266                                 AxeData.CurrentCorrImage=imagesc(rangx,-rangy,correl,[0 1]);
     282                                AxeData.CurrentCorrImage=imagesc(rangx,-rangy,result_conv,[0 1]);
     283                                AxeData.CurrentVector=line([0 utable],[0 vtable],'Tag','vector');
     284                               
    267285                                colorbar
    268286                                set(haxes,'UserData',AxeData)
     
    270288                            end
    271289                        else
    272                             set(AxeData.CurrentCorrImage,'CData',correl)
     290                           % set(AxeData.CurrentCorrImage,'CData',correl)
     291                            set(AxeData.CurrentCorrImage,'CData',result_conv)
    273292                            set(AxeData.CurrentCorrImage,'XData',rangx)
    274293                            set(AxeData.CurrentCorrImage,'YData',-rangy)
     294                            set(AxeData.CurrentVector,'XData',[0 utable],'YData',[0 -vtable])
    275295                        end       
    276296                    end
  • trunk/src/pivlab.m

    r227 r231  
    1919% mask: =[] for no mask
    2020% roi: 4 element vector defining a region of interest: x position, y position, width, height, (in image indices), for the whole image, roi=[];
    21 function [xtable ytable utable vtable ctable typevector] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty, PointCoord, subpixfinder,mask)
     21function [xtable ytable utable vtable ctable typevector result_conv errormsg] = pivlab (image1,image2,ibx2,iby2,isx2,isy2,shiftx,shifty, GridIndices, subpixfinder,mask)
    2222%this funtion performs the DCC PIV analysis. Recent window-deformation
    2323%methods perform better and will maybe be implemented in the future.
     24errormsg='';
    2425warning off %MATLAB:log:logOfZero
    25 % if numel(roi)>0
    26 %     xroi=roi(1);
    27 %     yroi=roi(2);
    28 %     widthroi=roi(3);
    29 %     heightroi=roi(4);
    30 %     image1_roi=double(image1(yroi:yroi+heightroi,xroi:xroi+widthroi));
    31 %     image2_roi=double(image2(yroi:yroi+heightroi,xroi:xroi+widthroi));
    32 % else
     26[npy_ima npx_ima]=size(image1);
     27if ~isequal(size(image1),size(image2))
     28    errormsg='image pair with unequal size';
     29    return
     30end
    3331    xroi=0;
    3432    yroi=0;
    3533    image1_roi=double(image1);
    3634    image2_roi=double(image2);
    37 % end
    3835if numel(mask)>0
    3936    cellmask=mask;
    40     mask=zeros(size(image1_roi));
     37    mask=zeros(size(image1));
    4138    for i=1:size(cellmask,1);
    4239        masklayerx=cellmask{i,1};
    4340        masklayery=cellmask{i,2};
    44         mask = mask + poly2mask(masklayerx-xroi,masklayery-yroi,size(image1_roi,1),size(image1_roi,2)); %kleineres eingangsbild und maske geshiftet
     41        mask = mask + poly2mask(masklayerx-xroi,masklayery-yroi,npy_ima,npx_ima); %kleineres eingangsbild und maske geshiftet
    4542    end
    4643else
    47     mask=zeros(size(image1_roi));
     44    mask=zeros(size(image1));
    4845end
    4946mask(mask>1)=1;
    50 % ibx=2*ibx2-1%ibx and iby odd, reduced by 1 if even
    51 % iby=2*iby2-1
     47
     48% ibx=2*ibx2-1;%ibx and iby odd, reduced by 1 if even
     49% iby=2*iby2-1;
    5250% miniy=1+iby2
    5351% minix=1+ibx2
     
    7775image2_roi=padarray(image2_roi,[iby2 ibx2], min(min(image1_roi)));
    7876mask=padarray(mask,[iby2 ibx2],0);
    79 SubPixOffset=0.5;%odd values chosen for ibx and iby
    80 
    81 nbvec=size(PointCoord,1);
     77%SubPixOffset=0.5;%odd values chosen for ibx and iby
     78
     79nbvec=size(GridIndices,1);
    8280xtable=zeros(nbvec,1);
    8381ytable=xtable;
     
    9694%% MAINLOOP
    9795for ivec=1:nbvec
    98     iref=PointCoord(ivec,1);
    99     jref=PointCoord(ivec,2);
     96    iref=GridIndices(ivec,1);
     97    jref=GridIndices(ivec,2);
     98    %jref=npy_ima-PointCoord(ivec,2)+1;
    10099    image1_crop=image1_roi(jref-iby2:jref+iby2,iref-ibx2:iref+ibx2);
    101100    image2_crop=image2_roi(jref+shifty-isy2:jref+shifty+isy2,iref+shiftx-isx2:iref+shiftx+isx2);
    102 %     n=round((j-miniy)/maxiy*100);
    103 %     for i = minix:step:maxix % horizontal loop
    104 %         nrx=nrx+1;%used to determine the pos of the vector in resulting matrix
    105 %         if nrxreal < numelementsx
    106 %             nrxreal=nrxreal+1;
    107 %         else
    108 %             nrxreal=1;
    109 %         end
    110 %         startpoint=[i j];
    111 %         image1_crop=image1_roi(j:j+iby-1, i:i+ibx-1);
    112 %         image2_crop=image2_roi(ceil(j-iby/2):ceil(j+1.5*iby-1), ceil(i-ibx/2):ceil(i+1.5*ibx-1));
    113 %         corrmax=0;
    114101        if mask(jref,iref)==0
    115102           %reference: Oliver Pust, PIV: Direct Cross-Correlation
     
    121108            corrmax= max(max(result_conv));
    122109            result_conv=(result_conv/corrmax)*255; %normalize, peak=always 255
     110           % result_conv=flipdim(result_conv,2);%reverse x direction
    123111            %Find the 255 peak
    124112            [y,x] = find(result_conv==255);
     
    126114                try
    127115                    if subpixfinder==1
    128                         [vector] = SUBPIXGAUSS (result_conv,ibx,iby,x,y,SubPixOffset);
     116                        [vector] = SUBPIXGAUSS (result_conv,x,y);
    129117                    elseif subpixfinder==2
    130                         [vector] = SUBPIX2DGAUSS (result_conv,ibx,iby,x,y,SubPixOffset);
     118                        [vector] = SUBPIX2DGAUSS (result_conv,x,y);
    131119                    end
    132                 catch
    133                     vector=[NaN NaN]; %if something goes wrong with cross correlation.....
     120                catch ME
     121                    errormsg=ME.message
     122                    vector=[0 0]; %if something goes wrong with cross correlation.....
    134123                end
    135124            else
    136                 vector=[NaN NaN]; %if something goes wrong with cross correlation.....
     125                vector=[0 0]; %if something goes wrong with cross correlation.....
    137126            end
    138127        else %if mask was not 0 then
    139             vector=[NaN NaN];
     128            vector=[0 0];
    140129            typevector(ivec)=0;
    141130        end
    142131
    143132        %Create the vector matrix x, y, u, v
    144         xtable(ivec)=PointCoord(ivec,2);
    145         ytable(ivec)=PointCoord(ivec,1);
     133        xtable(ivec)=GridIndices(ivec,1);
     134        ytable(ivec)=GridIndices(ivec,2);
    146135        utable(ivec)=vector(1);
    147136        vtable(ivec)=vector(2);
    148         ctable(ivec)=corrmax/sum(sum(image1_crop.*image1_crop));
    149 end
    150 % xtable=xtable-ibx2;
    151 % ytable=ytable-iby2;
    152 %
    153 % xtable=xtable+xroi;
    154 % ytable=ytable+yroi;
    155 %
    156 % utable(utable>ibx/1.5)=NaN;
    157 % vtable(utable>ibx/1.5)=NaN;
    158 % vtable(vtable>iby/1.5)=NaN;
    159 % utable(vtable>iby/1.5)=NaN;
    160 
    161 function [vector] = SUBPIXGAUSS (result_conv,ibx,iby,x,y,SubPixOffset)
     137        sum_square=sum(sum(image1_crop.*image1_crop));
     138        ctable(ivec)=corrmax/sum_square;
     139end
     140result_conv=result_conv/255;
     141
     142
     143function [vector] = SUBPIXGAUSS (result_conv,x,y)
     144
    162145if size(x,1)>1 %if there are more than 1 peaks just take the first
    163146    x=x(1:1);
     
    177160    f2 = log(result_conv(y,x+1));
    178161    peakx = x+ (f1-f2)/(2*f1-4*f0+2*f2);
    179     %
    180     SubpixelX=peakx-(ibx/2)-SubPixOffset;
    181     SubpixelY=peaky-(iby/2)-SubPixOffset;
    182     vector=[SubpixelX, SubpixelY];
     162    [npy,npx]=size(result_conv);
     163    vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1];
    183164else
    184165    vector=[NaN NaN];
    185166end
    186167
    187 function [vector] = SUBPIX2DGAUSS (result_conv,ibx,iby,x,y,SubPixOffset)
     168function [vector] = SUBPIX2DGAUSS (result_conv,x,y)
    188169if size(x,1)>1 %if there are more than 1 peaks just take the first
    189170    x=x(1:1);
     
    213194    c11=(1/4)*sum(sum(c11));
    214195    c20=(1/6)*sum(sum(c20));
    215     c02=(1/6)*sum(sum(c02));
    216     %c00=(1/9)*sum(sum(c00));
    217 
     196    c02=(1/6)*sum(sum(c02));
    218197    deltax=(c11*c01-2*c10*c02)/(4*c20*c02-c11^2);
    219198    deltay=(c11*c10-2*c01*c20)/(4*c20*c02-c11^2);
    220199    peakx=x+deltax;
    221200    peaky=y+deltay;
    222 
    223     SubpixelX=peakx-(ibx/2)-SubPixOffset;
    224     SubpixelY=peaky-(iby/2)-SubPixOffset;
    225     vector=[SubpixelX, SubpixelY];
     201   
     202    [npy,npx]=size(result_conv);
     203    vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1];
     204%     SubpixelX=peakx-(ibx/2)-SubPixOffset;
     205%     SubpixelY=peaky-(iby/2)-SubPixOffset;
     206%     vector=[SubpixelX, SubpixelY];
    226207else
    227208    vector=[NaN NaN];
  • trunk/src/plot_field.m

    r227 r231  
    10931093        end
    10941094        if test_vec
    1095             XMin=[XMin min(vec_X)];
    1096             XMax=[XMax max(vec_X)];
    1097             YMin=[YMin min(vec_Y)];
    1098             YMax=[YMax max(vec_Y)];
    1099         end
    1100         PlotParamOut.RangeX=[min(XMin) max(XMax)]; %range of x, to be stored in the user data of the plot axes
    1101         PlotParamOut.RangeY=[min(YMin) max(YMax)]; %range of x, to be stored in the user data of the plot axes
     1095            XMin=min(XMin,min(vec_X));
     1096            XMax=max(XMax,max(vec_X));
     1097            YMin=min(YMin,min(vec_Y));
     1098            YMax=max(YMax,max(vec_Y));
     1099        end
     1100        PlotParamOut.RangeX=[XMin XMax]; %range of x, to be stored in the user data of the plot axes
     1101        PlotParamOut.RangeY=[YMin YMax]; %range of x, to be stored in the user data of the plot axes
    11021102    if ~fix_lim
    1103         PlotParamOut.MinX=min(XMin);
    1104         PlotParamOut.MaxX=max(XMax);
    1105         PlotParamOut.MinY=min(YMin);
    1106         PlotParamOut.MaxY=max(YMax);
     1103        PlotParamOut.MinX=XMin;
     1104        PlotParamOut.MaxX=XMax;
     1105        PlotParamOut.MinY=YMin;
     1106        PlotParamOut.MaxY=YMax;
    11071107        if XMax>XMin
    11081108            set(haxes,'XLim',[XMin XMax]);% set x limits of frame in axes coordinates
  • trunk/src/plot_object.m

    r187 r231  
    7070        test_newobj=0;
    7171        haxes=get(hplot,'parent');
     72        currentfig=get(haxes,'parent');
    7273    elseif isequal(get(hplot,'Type'),'axes')% hplot is the handle of an axis
     74        haxes=hplot;
    7375        currentfig=get(hplot,'parent');
    74         set(0,'CurrentFigure',currentfig)
    75         haxes=hplot;
    76         set(currentfig,'CurrentAxes',haxes);
     76%         set(0,'CurrentFigure',currentfig)
     77     
     78%         set(currentfig,'CurrentAxes',haxes);
    7779    elseif isequal(get(hplot,'Type'),'figure')% hplot is the handle of a figure
    7880        set(0,'CurrentFigure',hplot);%set the input figure as the current one
    7981        haxes=findobj(hplot,'Type','axes');%look for axes in the figure
    8082        haxes=haxes(1);
    81         set(hplot,'CurrentAxes',haxes);%set the first found axis as the current one
     83        currentfig=hplot;
     84       % set(hplot,'CurrentAxes',haxes);%set the first found axis as the current one
    8285    else
    83         figure; %create new figure
     86        currentfig=figure; %create new figure
    8487        hplot=axes;%create new axes
    8588        haxes=hplot;
    8689    end
    8790else
    88     figure; %create new figure
     91    currentfig=figure; %create new figure
    8992    hplot=axes;%create new axes
    9093    haxes=hplot;
    9194end
     95set(0,'CurrentFigure',currentfig)%set the currentfigure as the current one
     96set(currentfig,'CurrentAxes',haxes);%set the current axes in the current figure
    9297
    9398%% default input parameters
     
    333338%% create the object
    334339if test_newobj
    335     axes(haxes)
     340%     axes(haxes)
    336341    hother=findobj('Tag','proj_object');%find all the proj objects
    337342    for iobj=1:length(hother)
  • trunk/src/proj_field.m

    r227 r231  
    12561256        %% case of input fields defined on a structured  grid
    12571257    else
    1258         'TESTproj'
    1259         VarName=FieldData.ListVarName{VarIndex(1)}%get the first variable of the cell to get the input matrix dimensions
     1258        VarName=FieldData.ListVarName{VarIndex(1)};%get the first variable of the cell to get the input matrix dimensions
    12601259        eval(['DimValue=size(FieldData.' VarName ');'])%input matrix dimensions
    12611260        DimValue(DimValue==1)=[];%remove singleton dimensions
     
    12671266                return
    12681267            else
    1269                 VarType.coord
    12701268                if numel(find(VarType.coord))==2% the third matrix dimension does not correspond to a space coordinate
    12711269                    nbcolor=DimValue(3);
     
    12751273            end
    12761274        end
    1277         testangle
     1275        AYName=FieldData.ListVarName{VarType.coord(NbDim-1)};%name of input x coordinate (name preserved on projection)
     1276        AXName=FieldData.ListVarName{VarType.coord(NbDim)};%name of input y coordinate (name preserved on projection)
    12781277        if testangle% TODO modify name also in case of origin shift in x or y
    1279             AYName='Y';
    1280             AXName='X';
     1278            AYProjName='Y';
     1279            AXProjName='X';
    12811280            count=0;
    12821281            %modify coordinate names if they are already used
    12831282            while ~(isempty(find(strcmp('AXName',ProjData.ListVarName),1)) && isempty(find(strcmp('AYName',ProjData.ListVarName),1)))
    12841283                count=count+1;
    1285                 AYName=[AYName '_' num2str(count)];
    1286                 AXName=[AXName '_' num2str(count)];
     1284                AYProjName=[AYProjName '_' num2str(count)];
     1285                AXProjName=[AXProjName '_' num2str(count)];
    12871286            end
    12881287        else
    1289             AYName=FieldData.ListVarName{VarType.coord(NbDim-1)}%name of input x coordinate (name preserved on projection)
    1290             AXName=FieldData.ListVarName{VarType.coord(NbDim)}%name of input y coordinate (name preserved on projection)
    1291         end
    1292         eval(['AX=FieldData.' AXName ';'])
    1293         eval(['AY=FieldData.' AYName ';'])
     1288            AYProjName=AYName;% (name preserved on projection)
     1289            AXProjName=AXName;%name of input y coordinate (name preserved on projection)
     1290        end
    12941291        ListDimName=FieldData.VarDimName{VarIndex(1)};
    1295             ProjData.ListVarName=[ProjData.ListVarName {AYName} {AXName}]; %TODO: check if it already exists in Projdata (several cells)
    1296             ProjData.VarDimName=[ProjData.VarDimName {AYName} {AXName}];
     1292        ProjData.ListVarName=[ProjData.ListVarName {AYProjName} {AXProjName}]; %TODO: check if it already exists in Projdata (several cells)
     1293        ProjData.VarDimName=[ProjData.VarDimName {AYProjName} {AXProjName}];
    12971294        Coord_z=[];
    12981295        Coord_y=[];
     
    13921389            coord_x_proj=linspace(XMax,XMin,npX);%abscissa of the new pixels along the line
    13931390        end
    1394         % case with no rotation and interpolation
    1395         if isequal(ProjMode,'projection') && ~testangle
    1396             if ~testXMin && ~testXMax && ~testYMin && ~testYMax && NbDim==2
    1397                 ProjData=FieldData;
     1391        % case with no interpolation
     1392        if isequal(ProjMode,'projection') && (~testangle || test90y || test90x)
     1393            if  NbDim==2 && ~testXMin && ~testXMax && ~testYMin && ~testYMax
     1394                ProjData=FieldData;% no change by projection
    13981395            else
    1399                 indY=NbDim-1;
     1396                test_direct
     1397                indY=NbDim-1
    14001398                if test_direct(indY)
    14011399                    min_indy=ceil((YMin-Coord{indY}(1))/DYinit)+1;
     
    14041402                    Ybound(2)=Coord{indY}(1)+DYinit*(max_indy-1);
    14051403                else
    1406                     min_indy=ceil((Coord{indY}(1)-YMax)/DYinit)+1;
    1407                     max_indy=floor((Coord{indY}(1)-YMin)/DYinit)+1;
    1408                     Ybound(2)=Coord{indY}(1)-DYinit*(max_indy-1);
    1409                     Ybound(1)=Coord{indY}(1)-DYinit*(min_indy-1);
     1404                    min_indy=ceil((Coord{indY}(1)-YMax)/DYinit)+1
     1405                    max_indy=floor((Coord{indY}(1)-YMin)/DYinit)+1
     1406                    Ybound(2)=Coord{indY}(1)-DYinit*(max_indy-1)
     1407                    Ybound(1)=Coord{indY}(1)-DYinit*(min_indy-1)
    14101408                end
    14111409                if test_direct(NbDim)==1
     
    14171415                    min_indx=ceil((Coord{NbDim}(1)-XMax)/DXinit)+1;
    14181416                    max_indx=floor((Coord{NbDim}(1)-XMin)/DXinit)+1;
    1419                     Xbound(2)=Coord{NbDim}(1)+DXinit*(max_indx-1);
    1420                    
    1421                    
     1417                    Xbound(2)=Coord{NbDim}(1)+DXinit*(max_indx-1);                         
    14221418                    Xbound(1)=Coord{NbDim}(1)+DXinit*(min_indx-1);
    14231419                end
     
    14261422
    14271423                if test90y
    1428                     'TEST3D'
    14291424                    ind_new=[3 2 1];
    1430                     DimCell=DimCell(ind_new);
    1431                     DimValue=DimValue(ind_new);
    1432                     DimCell(1)=[]; %suppress x variable
    1433                     DimValue(1)=[];
     1425                    DimCell={AYProjName,AXProjName}
     1426%                     DimValue=DimValue(ind_new);
    14341427                    iz=ceil((ObjectData.Coord(1,1)-Coord{3}(1))/DX)+1;
    14351428                    for ivar=VarIndex
     
    14381431                        ProjData.VarDimName=[ProjData.VarDimName {DimCell}];
    14391432                        ProjData.VarAttribute{length(ProjData.ListVarName)}=FieldData.VarAttribute{ivar}; %reproduce the variable attributes
    1440                         eval(['size(FieldData.' VarName ')'])
    1441                         eval(['ProjData.' VarName '=permute(FieldData.' VarName ',ind_new)'])% permute x and z indices for 90 degree rotation
    1442                         eval(['size(ProjData.' VarName ')'])
    1443                         eval(['ProjData.' VarName '=squeeze(FieldData.' VarName '(iz,:,:));'])% select the z index iz
    1444                     end
    1445                     eval(['ProjData.' AYName '=[Ybound(1) Ybound(2)];']) %record the new (projected ) y coordinates
    1446                     eval(['ProjData.' AXName '=[Coord{1}(end),Coord{1}(1)];']) %record the new (projected ) x coordinates
     1433                        eval(['ProjData.' VarName '=permute(FieldData.' VarName ',ind_new);'])% permute x and z indices for 90 degree rotation
     1434                        eval(['ProjData.' VarName '=squeeze(ProjData.' VarName '(iz,:,:));'])% select the z index iz
     1435                    end
     1436                    eval(['ProjData.' AYProjName '=[Ybound(1) Ybound(2)];']) %record the new (projected ) y coordinates
     1437                    eval(['ProjData.' AXProjName '=[Coord{1}(end),Coord{1}(1)];']) %record the new (projected ) x coordinates
    14471438                else
    14481439                    if NbDim==3
     
    14701461                        end
    14711462                    end
    1472                     eval(['ProjData.' AYName '=[Ybound(1) Ybound(2)];']) %record the new (projected ) y coordinates
    1473                     eval(['ProjData.' AXName '=[Xbound(1) Xbound(2)];']) %record the new (projected ) x coordinates
     1463                    eval(['ProjData.' AYProjName '=[Ybound(1) Ybound(2)];']) %record the new (projected ) y coordinates
     1464                    eval(['ProjData.' AXProjName '=[Xbound(1) Xbound(2)];']) %record the new (projected ) x coordinates
    14741465                end
    14751466            end
     
    15751566    end
    15761567end
    1577 
     1568ProjData
     1569ProjData.VarDimName{3}
    15781570%-----------------------------------------------------------------
    15791571%projection in a volume
  • trunk/src/read_get_field.m

    r227 r231  
    597597        end
    598598        if empty_coord_y
     599            if numel(DimCellA)<2
     600                errormsg=['coordinates need to be defined for the scalar ' VarNameA];
     601                return
     602            end
    599603            coord_y_name=DimCellA{NbDim-1};
    600604            SubField.ListVarName=[{coord_y_name} SubField.ListVarName];
  • trunk/src/set_object.m

    r227 r231  
    652652if ~isempty(huvmat)
    653653    hhuvmat=guidata(huvmat);
    654 %     set(hhuvmat.create,'Value',0)
    655 %     set(hhuvmat.create,'BackgroundColor',[0 1 0])%put unactivated buttons to green
    656 %     set(hhuvmat.LINE,'Value',0)
    657 %     set(hhuvmat.LINE,'BackgroundColor',[0 1 0])%put unactivated buttons to green
    658 %     set(hhuvmat.PATCH,'Value',0)
    659 %     set(hhuvmat.PATCH,'BackgroundColor',[0 1 0])%put unactivated buttons to green
    660 %     set(hhuvmat.PLANE,'Value',0)
    661 %     set(hhuvmat.PLANE,'BackgroundColor',[0 1 0])%put unactivated buttons to green
    662 %     set(hhuvmat.VOLUME,'Value',0)
    663 %     set(hhuvmat.VOLUME,'BackgroundColor',[0 1 0])%put unactivated buttons to green
    664654    set(hhuvmat.edit,'Value',0)
    665655    set(hhuvmat.edit,'BackgroundColor',[0.7 0.7 0.7])%put unactivated buttons to gree
     
    686676    IndexObj_2=get(hhuvmat.list_object_2,'Value');
    687677    List2=get(hhuvmat.list_object_2,'String');
    688     if IndexObj_2==length(List2)
    689         IndexObj_2=[];% '...' selected
    690     end
    691678else
    692679    IndexObj_2=[];
     
    709696    if isempty(hview_field)
    710697        hview_field=view_field;
    711 %     elseif strcmp(ObjectData.ProjMode,'none')||strcmp(ObjectData.ProjMode,'mask_inside')||strcmp(ObjectData.ProjMode,'mask_outside')
    712698    end
    713699    PlotHandles=guidata(hview_field);
     
    716702    PlotHandles=hhuvmat;
    717703    plotaxes=hhuvmat.axes3;%handle of axes3 in view_field
     704
    718705end   
    719706
     
    742729ListObject{IndexObj,1}=ObjectName;
    743730set(hhuvmat.list_object_1,'String',ListObject)
    744 set(hhuvmat.list_object_2,'String',[ListObject;{'...'}])
     731set(hhuvmat.list_object_2,'String',ListObject)
    745732
    746733%% update the object plot and projection field
  • trunk/src/uvmat.m

    r227 r231  
    302302set(handles.transform_fct,'String',menu_str)
    303303set(handles.transform_fct,'UserData',fct_handle)% store the list of path in UserData of ACTION
    304 set(handles.uvmat,'UserData',UvData)
     304
    305305
    306306%% check the path and date of modification of all functions in uvmat
     
    324324            inputfile=input.InputFile;
    325325        end
    326         if isfield(Field,'TimeIndex')
    327             set(handles.i1,num2str(Field.TimeIndex))
     326        if isfield(input,'TimeIndex')
     327            set(handles.i1,num2str(input.TimeIndex))
     328        end
     329        if isfield(input,'FieldsString')
     330%             set(handles.Fields,'Value',1)
     331            UvData.FieldsString=input.FieldsString;
    328332        end
    329333    elseif ischar(input)% file name introduced as input
     
    335339            return
    336340        end
    337         Field.ListVarName={'A','coord_y','coord_x'};
    338         Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'};
    339         Field.A=input;
    340         Field.coord_x=[0.5 size(input,2)-0.5];
    341         Field.coord_y=[size(input,1)-0.5 0.5];
    342     end
    343     if ~isempty(inputfile)
    344         %%%%% display the input field %%%%%%%
    345         display_file_name(hObject, eventdata, handles,inputfile)
    346         %%%%%%%
     341        UvData.Field.ListVarName={'A','coord_y','coord_x'};
     342        UvData.Field.VarDimName={{'coord_y','coord_x'},'cord_y','coord_x'};
     343        UvData.Field.A=input;
     344        UvData.Field.coord_x=[0.5 size(input,2)-0.5];
     345        UvData.Field.coord_y=[size(input,1)-0.5 0.5];
    347346        testinputfield=1;
    348347    end
     
    360359       end
    361360   end
     361end
     362set(handles.uvmat,'UserData',UvData)
     363if ~isempty(inputfile)
     364    %%%%% display the input field %%%%%%%
     365    display_file_name(hObject, eventdata, handles,inputfile)
     366    %%%%%%%
     367    testinputfield=1;
    362368end
    363369
     
    856862UvData.XmlData=XmlData;
    857863UvData.NewSeries=1;
    858 set(handles.uvmat,'UserData',UvData)
     864
    859865
    860866%display warning message
     
    867873if ~testima
    868874    testcivx=0;
    869     hget_field=findobj('Name','get_field');
    870 %     if isequal(FileExt,'.nc')||isequal(FileExt,'.cdf')
    871     if isempty(hget_field)
     875    % hget_field=findobj('Name','get_field');
     876    %     if isequal(FileExt,'.nc')||isequal(FileExt,'.cdf')
     877    if isfield(UvData,'FieldsString') && isequal(UvData.FieldsString,{'get_field...'})% field menu defined as input (from get_field)
     878        set(handles.Fields,'Value',1)
     879        set(handles.Fields,'String',{'get_field...'})
     880        UvData=rmfield(UvData,'FieldsString');
     881    else
     882        %if isempty(hget_field)
    872883        Data=nc2struct(FileName,'ListGlobalAttribute','absolut_time_T0','civ');
    873884        if ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0)%if the new input is Civx
     
    878889            col_vec(1)=[];%remove 'velocity' option for vector color (must be a scalar)
    879890            testcivx=1;
    880         end 
    881     else
    882         hhget_field=guidata(hget_field);
    883         if ~strcmp(get(hhget_field.inputfile,'String'),FileName)%delete any existing get_field GUI with file name different than the input
    884             delete(hget_field)
    885         end
    886     end
    887     if ~testcivx
     891        end
     892        %     else
     893        %          hhget_field=guidata(hget_field);
     894        %         if ~strcmp(get(hhget_field.inputfile,'String'),FileName)%delete any existing get_field GUI with file name different than the input
     895        %             delete(hget_field)
     896        %         end
     897        %     end
     898        if ~testcivx
    888899            set(handles.Fields,'Value',1) % set menu to 'get_field...
    889900            set(handles.Fields,'String',{'get_field...'})
    890             col_vec={'get_field...'};
    891     end       
    892     set(handles.col_vec,'String',col_vec)
    893 %     else
    894 %         msgbox_uvmat('ERROR',['invalid input file extension ' FileExt])
    895 %         return
    896 %     end
    897 end
     901            col_vec={'get_field...'};
     902        end
     903        set(handles.col_vec,'String',col_vec)
     904        %     else
     905        %         msgbox_uvmat('ERROR',['invalid input file extension ' FileExt])
     906        %         return
     907        %     end
     908    end
     909end
     910set(handles.uvmat,'UserData',UvData)
    898911
    899912%% set index navigation options and refresh plots
     
    25332546    end
    25342547else
    2535     % create a default projection menuplane
    2536     %UvData.Object{1}.Style='none';%main plotting plane
    2537     UvData.Object{1}.ProjMode='projection';%main plotting plane
    2538     UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
    2539     set(handles.list_object_1,'Value',1);
    2540     set(handles.list_object_1,'String',{''});
     2548    % create a default projection
     2549%     UvData.Object{1}.ProjMode='projection';%main plotting plane
     2550%     UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
     2551%     set(handles.list_object_1,'Value',1);
     2552%     set(handles.list_object_1,'String',{''});
    25412553end
    25422554% if ~isfield(UvData.Object{1},'plotaxes')
     
    25732585% second projection object (view_field display)
    25742586IndexObj_2=get(handles.list_object_2,'Value');%selected projection object for the second view
     2587if IndexObj_2==0
     2588    IndexObj_2=1;
     2589end
    25752590if isequal(get(handles.list_object_2,'Visible'),'on') && IndexObj_2 <= numel(UvData.Object)&& ~isempty(UvData.Object{IndexObj_2})
    25762591    IndexObj(2)=IndexObj_2;
     
    39493964list_object=get(handles.list_object_1,'String');
    39503965set(handles.list_object_1,'Value',1)
    3951 set(handles.list_object_1,'String',list_object(1))
     3966set(handles.list_object_1,'String',{''})
    39523967set(handles.list_object_2,'Value',2)
    3953 set(handles.list_object_2,'String',[list_object(1);{'...'}])
     3968set(handles.list_object_2,'String',{''})
    39543969list_object_2_Callback(hObject, eventdata, handles)
    39553970
     
    43174332IndexObj=get(handles.list_object_1,'Value');
    43184333str_1=list_str{IndexObj};
    4319 val_2=get(handles.list_object_2,'Value');
    4320 str_2=get(handles.list_object_2,'String');
    4321 if isequal(val_2,IndexObj)% if the first selection is equal to the second, it will suppress the second
    4322     set(handles.list_object_2,'Value',numel(str_2))%select the end of the list ('...')
    4323     list_object_2_Callback(hObject, eventdata, handles)
    4324 end
     4334% val_2=get(handles.list_object_2,'Value');
     4335% str_2=get(handles.list_object_2,'String');
     4336% if isequal(val_2,IndexObj)% if the first selection is equal to the second, it will suppress the second
     4337%     set(handles.list_object_2,'Value',numel(str_2))%select the end of the list ('...')
     4338%     list_object_2_Callback(hObject, eventdata, handles)
     4339% end
    43254340update_object(handles,IndexObj,1,str_1)
    43264341
     
    43314346list_str=get(handles.list_object_2,'String');
    43324347IndexObj=get(handles.list_object_2,'Value');
    4333 if ischar(list_str) || strcmp(list_str{IndexObj},'...')
     4348if ischar(list_str) || isempty(list_str{IndexObj})% || strcmp(list_str{IndexObj},'...')
    43344349    hview_field=findobj(allchild(0),'Tag','view_field');
    43354350    if ~isempty(hview_field)
     
    43864401    PlotHandles=guidata(hview_field);
    43874402end
    4388 plot_field(ProjData,PlotHandles.axes3,PlotHandles);
     4403%plot_field(ProjData,PlotHandles.axes3,PlotHandles);
    43894404set(handles.uvmat,'UserData',UvData)
    43904405hother=findobj('Tag','proj_object');%find all the proj objects
     
    46704685            end
    46714686        end
    4672     end
    4673    
     4687    end
    46744688    %mask name
    46754689    RootPath=get(handles.RootPath,'String');
     
    46874701
    46884702    %display the mask
    4689     figure;
     4703    hfigmask=figure;
     4704    set(hfigmask,'Name','mask image')
    46904705    vec=linspace(0,1,256);%define a linear greyscale colormap
    46914706    map=[vec' vec' vec'];
  • trunk/src/view_field.m

    r220 r231  
    733733hhuvmat=guidata(huvmat);
    734734list_object_2=get(hhuvmat.list_object_2,'String');
    735 set(hhuvmat.list_object_2,'Value',numel(list_object_2))%select the last value ('...')
     735set(hhuvmat.list_object_2,'Value',1)%select the last value ('...')
    736736end
    737737delete(hObject)
Note: See TracChangeset for help on using the changeset viewer.