Changeset 542 for trunk/src/px_XYZ.m


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

File:
1 edited

Legend:

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