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

interactive test for piv introduced various bug corrections

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.