Changeset 542


Ignore:
Timestamp:
Sep 15, 2012, 7:04:56 PM (12 years ago)
Author:
sommeria
Message:

bugs repaired for mask display in phys coord, display of circles in geometry_calib, introduction of x,y,z initial in proj_field/proj_plane

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/geometry_calib.m

    r541 r542  
    861861%------------------------------------------------------------------------
    862862huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
    863 hplot=findobj(huvmat,'Tag','axes3');%main plotting axis of uvmat
     863hplot=findobj(huvmat,'Tag','PlotAxes');%main plotting axis of uvmat
    864864hhh=findobj(hplot,'Tag','calib_marker');
    865865Coord_cell=get(handles.ListCoord,'String');
     
    876876    return
    877877end
    878 %fill the edit boxex
     878%fill the edit boxe
    879879set(handles.XObject,'String',coord_str(1:k(1)-1))
    880880set(handles.YObject,'String',coord_str(k(1)+3:k(2)-1))
  • trunk/src/mouse_motion.m

    r537 r542  
    104104                    text_displ_3='';
    105105                    text_displ_4='';
     106                    text_displ_5='';
    106107                    ivec=[];
    107108                    xName='';
     
    140141                                        elseif (isfield(CellInfo{icell},'VarIndex_vector_x') && isequal(ivar,CellInfo{icell}.VarIndex_vector_x))||isequal(ivar,CellInfo{icell}.VarIndex_vector_y)||...
    141142                                                (isfield(CellInfo{icell},'VarIndex_vector_z') && isequal(ivar,CellInfo{icell}.VarIndex_vector_z))
    142                                             text_displ_3=[text_displ_3 var_text];
     143                                            text_displ_4=[text_displ_4 var_text];
    143144                                        else
    144                                             text_displ_4=[text_displ_4 var_text];
     145                                            text_displ_5=[text_displ_5 var_text];
    145146                                        end
    146147                                    end
     
    168169                                            VarVal=Field.(VarName)(indy0,indx0,:);
    169170                                            var_text=[VarName '=' num2str(VarVal) ','];
    170                                             text_displ_2=[text_displ_2 var_text];
     171                                            text_displ_4=[text_displ_4 var_text];
    171172                                        end
    172173                                    end
     
    175176                        end
    176177                    end
    177               % display the current x,y coordinates in the absence of detected vector
     178              % display the current x,y plot coordinates in the absence of detected vector
    178179                    if isempty(ivec)
    179180                        if isempty(xName)
     
    183184                        text_displ_1=[xName '=' num2str(xy(1,1),4) ', ' yName '=' num2str(xy(1,2),4) ','];
    184185                    end
    185               %display the z coordinate if defined by the projection plane
    186                     if isfield(Field,'PlaneCoord')
    187 %                             ZIndex=Field.ZIndex;
    188                         if size(Field.PlaneCoord)>=[1 3]
    189                             z=Field.PlaneCoord(1,3);
    190                             if isfield(Field,'PlaneAngle')&&~isequal(Field.PlaneAngle,[0 0 0])
    191                                 om=norm(Field.PlaneAngle);%norm of rotation angle in radians
    192                                 OmAxis=Field.PlaneAngle/om; %unit vector marking the rotation axis
    193                                 cos_om=cos(pi*om/180);
    194                                 sin_om=sin(pi*om/180);
    195                                 coeff=OmAxis(3)*(1-cos_om);
    196                                 norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om;
    197                                 norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om;
    198                                 norm_plane(3)=OmAxis(3)*coeff+cos_om;
    199                                 Z0=norm_plane*Field.PlaneCoord'/norm_plane(3);
    200                                 z=Z0-norm_plane(1)*xy(1,1)/norm_plane(3)-norm_plane(2)*xy(1,2)/norm_plane(3);
    201                             end
     186                    %display the z coordinate if defined by the projection plane
     187                    if isfield(Field,'ObjectCoord') && length(Field.ObjectCoord)>=3
     188                        pos=[xy(1,1) xy(1,2) 0];
     189                        if isfield(Field,'ObjectAngle')&&~isequal(Field.ObjectAngle,[0 0 0])
     190                            om=norm(Field.ObjectAngle);%norm of rotation angle in radians
     191                            OmAxis=Field.ObjectAngle/om; %unit vector marking the rotation axis
     192                            cos_om=cos(pi*om/180);
     193                            sin_om=sin(pi*om/180);
     194                            pos=[xy(1,1) xy(1,2) 0];
     195                            pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis;
    202196                        end
     197                        pos=pos+Field.ObjectCoord;
     198                        text_displ_3=[text_displ_3 'x,y,z=' num2str(pos,4)];
    203199                    end
    204                     if ~isempty(z)
    205                         text_displ_1=[text_displ_1 ' z=' num2str(z,4)];
    206                     end
     200%                     if ~isempty(z)
     201%                         text_displ_1=[text_displ_1 ' z=' num2str(z,4)];
     202%                     end
    207203               % case of PIV correlation display
    208204                    if test_piv
     
    242238                        [Data,errormsg,result_conv]= civ_matlab(Param);
    243239                        if ~isempty(errormsg)
    244                             text_displ_4=errormsg;
     240                            text_displ_5=errormsg;
    245241                        else
    246242                            rangx(1)=-(isx2-ibx2)+shiftx;
     
    281277end
    282278if ~isempty(text_displ_1)
    283 set(handles.text_display,'String',[{text_displ_1};{text_displ_2};{text_displ_3};{text_displ_4}])
     279    text_displ=[{text_displ_1};{text_displ_2};{text_displ_3};{text_displ_4};{text_displ_5}];
     280    ind_blank=find(strcmp('',text_displ));
     281    if ~isempty(ind_blank)
     282        text_displ(ind_blank)=[];
     283    end
     284    set(handles.text_display,'String',text_displ)
    284285else
    285286   set(handles.text_display,'String',get(handles.text_display,'UserData'))
  • trunk/src/proj_field.m

    r537 r542  
    9494if ~isfield(ObjectData,'Coord')||isempty(ObjectData.Coord)
    9595    if strcmp(ObjectData.Type,'plane')
    96         ObjectData.Coord=[0 0 0];%default
     96        ObjectData.Coord=[0 0];%default
    9797    else
    9898        return
     
    948948%% initiate Matlab  structure for physical field
    949949[ProjData,errormsg]=proj_heading(FieldData,ObjectData);
     950
     951%% reproduce initial plane position and angle
     952if isfield(FieldData,'PlaneCoord')&&length(FieldData.PlaneCoord)==3
     953   if length(ProjData.ObjectCoord)==3% if the projection plane has a z coordinate
     954       if ~isequal(ProjData.PlaneCoord(3),ProjData.ObjectCoord) %check the consistency with the z coordinate of the field plane (set by calibration)
     955           errormsg='inconsistent z position for field and projection plane';
     956           return
     957       end
     958   else % the z coordinate is set only by the field plane (by calibration)
     959       ProjData.ObjectCoord(3)=FieldData.PlaneCoord(3);
     960   end
     961   if isfield(FieldData,'PlaneAngle')
     962       if isfield(ProjData,'ObjectAngle')
     963           if ~isequal(FieldData.PlaneAngle,ProjData.ObjectAngle) %check the consistency with the z coordinate of the field plane (set by calibration)
     964           errormsg='inconsistent plane angle for field and projection plane';
     965           return
     966           end
     967       else
     968        ProjData.ObjectAngle=FieldData.PlaneAngle;
     969       end
     970    end
     971end
    950972ProjData.NbDim=2;
    951973ProjData.ListVarName={};
     
    22062228    AttrName=ProjData.ListGlobalAttribute{iattr};
    22072229    if isfield(FieldData,AttrName)
    2208         eval(['ProjData.' AttrName '=FieldData.' AttrName ';']);
     2230        ProjData.(AttrName)=FieldData.(AttrName);
    22092231    end
    22102232end
     
    22242246for ilist=1:length(ListObject)
    22252247    if isfield(ObjectData,ListObject{ilist})
    2226         eval(['val=ObjectData.' ListObject{ilist} ';'])
     2248        val=ObjectData.(ListObject{ilist});
    22272249        if ~isempty(val)
    2228             eval(['ProjData.Object' ListObject{ilist} '=val;']);
     2250            ProjData.(['Object' ListObject{ilist}])=val;
    22292251            ProjData.ListGlobalAttribute=[ProjData.ListGlobalAttribute {['Object' ListObject{ilist}]}];
    22302252        end
    22312253    end   
    22322254end
     2255
  • trunk/src/px_XYZ.m

    r114 r542  
    1111
    1212function [X,Y]=px_XYZ(Calib,Xphys,Yphys,Zphys)
    13 % if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'PlanePos')&length(Calib.PlanePos)>=Z
    14 %     Zindex=Z;
    15 %     planepos=Calib.PlanePos{Zindex};
    16 %     zphys=planepos(3);%A GENERALISER CAS AVEC ANGLE
    17 % else
    18 %     zphys=0;
    19 % end
    2013if ~exist('Zphys','var')
    2114    Zphys=0;
     
    2720     Calib.Tx_Ty_Tz=[0 0 1];
    2821end
    29 % if ~isfield(Calib,'kappa1')
    30 %     Calib.kappa1=0;
    31 % end
    32 % if ~isfield(Calib,'sx')
    33 %     Calib.sx=1;
    34 % end
    35 % if ~isfield(Calib,'dpx')
    36 %     Calib.dpx=1;
    37 % end
    38 % if ~isfield(Calib,'dpy')
    39 %     Calib.dpy=1;
    40 % end
    4122
    4223%%%%%%%%%%%%%
     24% general case
    4325if isfield(Calib,'R')
    4426    R=(Calib.R)';
     27    %correct z for refraction if needed
     28    if isfield(Calib,'InterfaceCoord') && isfield(Calib,'RefractionIndex')
     29        H=Calib.InterfaceCoord(3);
     30        if H>Zphys
     31            Zphys=H-(H-Zphys)/Calib.RefractionIndex; %corrected z (virtual object)
     32            test_refraction=1;
     33        end
     34    end
     35   
    4536    %camera coordinates
    4637    xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx_Ty_Tz(1);
    4738    yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Tx_Ty_Tz(2);
    4839    zc=R(7)*Xphys+R(8)*Yphys+R(9)*Zphys+Calib.Tx_Ty_Tz(3);
    49 %undistorted image coordinates
     40   
     41    %undistorted image coordinates
    5042    Xu=xc./zc;
    5143    Yu=yc./zc;
    52 %radial quadratic correction factor
     44   
     45    %radial quadratic correction factor
    5346    if ~isfield(Calib,'kc')
    5447        r2=1; %no quadratic distortion
     
    5649        r2=1+Calib.kc*(Xu.*Xu+Yu.*Yu);
    5750    end
    58 %pixel coordinates
     51   
     52    %pixel coordinates
    5953    if ~isfield(Calib,'Cx_Cy')
    6054        Calib.Cx_Cy=[0 0];%default value
    6155    end
    6256    X=Calib.fx_fy(1)*Xu.*r2+Calib.Cx_Cy(1);
    63     Y=Calib.fx_fy(2)*Yu.*r2+Calib.Cx_Cy(2);   
    64 %OLD CONVENTION (Wilson)undistorted image coordinates
    65 %     Xu=Calib.f*xc./zc;
    66 %     Yu=Calib.f*yc./zc;   
    67 % %distorted image coordinates
    68 %     distortion=(Calib.kappa1)*(Xu.*Xu+Yu.*Yu)+1; %A REVOIR
    69 % % distortion=1;
    70 %     Xd=Xu./distortion;
    71 %     Yd=Yu./distortion;
    72 % %pixel coordinates
    73 %     X=Xd*Calib.sx/Calib.dpx+Calib.Cx;
    74 %     Y=Yd/Calib.dpy+Calib.Cy;
    75 else %case 'rescale'
     57    Y=Calib.fx_fy(2)*Yu.*r2+Calib.Cx_Cy(2); 
     58   
     59%case 'rescale'   
     60else
    7661    X=Calib.fx_fy(1)*(Xphys+Calib.Tx_Ty_Tz(1));
    7762    Y=Calib.fx_fy(2)*(Yphys+Calib.Tx_Ty_Tz(2)); 
  • trunk/src/uvmat.m

    r541 r542  
    13321332    else
    13331333        %read mask image
    1334         Mask.AName='image';
    1335         Mask.A=imread(MaskName);
     1334        [Mask,tild,errormsg] = read_field(MaskName,'image');
     1335%         Mask.AName='image';
     1336%         Mask.A=imread(MaskName);
     1337        if ~isempty(errormsg)
     1338            return
     1339        end
    13361340        npxy=size(Mask.A);
    1337         test_error=0;
    13381341        if length(npxy)>2
    13391342            errormsg=[MaskName ' is not a grey scale image'];
     
    13431346            return
    13441347        end
    1345         Mask.AX=[0.5 npxy(2)-0.5];
    1346         Mask.AY=[npxy(1)-0.5 0.5 ];
    1347         Mask.CoordUnit='pixel';
     1348%         Mask.AX=[0.5 npxy(2)-0.5];
     1349%         Mask.AY=[npxy(1)-0.5 0.5 ];
     1350%         Mask.CoordUnit='pixel';
    13481351        if isequal(get(handles.slices,'Value'),1)
    13491352           NbSlice=str2num(get(handles.num_NbSlice,'String'));
     
    46094612    return
    46104613else
    4611 %     set(handles.ListObject,'Max',2);%allow multiple selection
    46124614    set(handles.ListObject,'Value',val);
    46134615    flag=1;
     
    46344636                        Y=ObjectData.Coord(:,2);
    46354637                        if testphys
    4636                             [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases
     4638                            pos=[X Y zeros(size(X))];
     4639                            if isfield(Calib,'SliceCoord') && length(Calib.SliceCoord)>=3
     4640                                if isfield(Calib,'SliceAngle')&&~isequal(Calib.SliceAngle,[0 0 0])
     4641                                    om=norm(Calib.SliceAngle);%norm of rotation angle in radians
     4642                                    OmAxis=Calib.SliceAngle/om; %unit vector marking the rotation axis
     4643                                    cos_om=cos(pi*om/180);
     4644                                    sin_om=sin(pi*om/180);
     4645                                    pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis;
     4646                                end
     4647                                pos(:,1)=pos(:,1)+Calib.SliceCoord(1);
     4648                                pos(:,2)=pos(:,2)+Calib.SliceCoord(2);
     4649                                pos(:,3)=pos(:,3)+Calib.SliceCoord(3);
     4650                            end                           
     4651                            [X,Y]=px_XYZ(Calib,pos(:,1),pos(:,2),pos(:,3));
    46374652                        end
    46384653                        flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside
     
    46714686        RootFile(1)=[];
    46724687    end
    4673    % filebase=fullfile(RootPath,RootFile);
    46744688    list=get(handles.masklevel,'String');
    46754689    masknumber=num2str(length(list));
Note: See TracChangeset for help on using the changeset viewer.