Ignore:
Timestamp:
Oct 16, 2010, 5:56:00 PM (14 years ago)
Author:
sommeria
Message:

geometry_calib is now updated when a new image is viewed by uvmat
imadoc2struct corrected for time reading

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/transform_field/px.m

    r40 r116  
    1818%      DataIn.A, AX, AY : image or scalar input -> EMPTY  CORRESPONDING OUTPUT (A REVOIR)
    1919%      Other fields in DataIn: copied to DataOut without modification
    20 % Calib: structure containing the calibration parameters (Tsai) or containing a subtree Calib.GeometryCalib with these parameters
     20% Calib: structure containing the  substructure Calib.GeometryCalib with the calibration parameters
    2121%
    2222% call the function  px_XYZ (case of images) for pointwise coordinate transforms
     
    3636    DataOut=px_1(Data,CalibData.GeometryCalib);
    3737end
    38 if exist('Data_1','var')
     38if isfield(DataOut,'Z')
     39    DataOut=rmfield(DataOut,'Z');
     40end
     41if exist('Data_1','var')% if there is a second input field, it is also transformed
    3942    if ~(exist('CalibData_1','var') && isfield(CalibData_1,'GeometryCalib'))
    4043        DataOut_1=Data_1;
     
    4245        DataOut_1=px_1(Data_1,CalibData_1.GeometryCalib);
    4346    end
    44 else
     47    if isfield(DataOut_1,'Z')
     48        DataOut_1=rmfield(DataOut_1,'Z');
     49    end
     50else % no second input field then empty second output field
    4551    DataOut_1=[];
    4652end
     
    5258
    5359%Act only if .CoordType=phys, and Calib defined
    54 if isfield(Data,'CoordType')& isequal(Data.CoordType,'phys')& ~isempty(Calib)
     60if isfield(Data,'CoordType')&& isequal(Data.CoordType,'phys')&& ~isempty(Calib)
    5561    DataOut.CoordType='px'; %put flag for pixel coordinates
    5662    DataOut.CoordUnit='px';
    5763    %transform of X,Y coordinates
    58     if isfield(Data,'Z')&~isempty(Data.Z)
     64    if isfield(Data,'Z')&&~isempty(Data.Z)
    5965        Z=Data.Z;
    6066    else
     
    97103% [Zphys]: corresponding array of z physical coordinates (0 by default)
    98104
    99 
    100 function [X,Y]=px_XYZ(Calib,Xphys,Yphys,Zphys)
    101 X=[];%default
    102 Y=[];
    103 % if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'PlanePos')&length(Calib.PlanePos)>=Z
    104 %     Zindex=Z;
    105 %     planepos=Calib.PlanePos{Zindex};
    106 %     zphys=planepos(3);%A GENERALISER CAS AVEC ANGLE
    107 % else
    108 %     zphys=0;
     105%
     106% function [X,Y]=px_XYZ(Calib,Xphys,Yphys,Zphys)
     107% X=[];%default
     108% Y=[];
     109% % if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'PlanePos')&length(Calib.PlanePos)>=Z
     110% %     Zindex=Z;
     111% %     planepos=Calib.PlanePos{Zindex};
     112% %     zphys=planepos(3);%A GENERALISER CAS AVEC ANGLE
     113% % else
     114% %     zphys=0;
     115% % end
     116% if ~exist('Zphys','var')
     117%     Zphys=0;
    109118% end
    110 if ~exist('Zphys','var')
    111     Zphys=0;
    112 end
    113 
    114 %%%%%%%%%%%%%
    115 if isfield(Calib,'R')
    116     R=(Calib.R)';
    117     xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx;
    118     yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Ty;
    119     zc=R(7)*Xphys+R(8)*Yphys+R(9)*Zphys+Calib.Tz;
    120 %undistorted image coordinates
    121     Xu=Calib.f*xc./zc;
    122     Yu=Calib.f*yc./zc;
    123 %distorted image coordinates
    124     distortion=(Calib.kappa1)*(Xu.*Xu+Yu.*Yu)+1; %A REVOIR
    125 % distortion=1;
    126     Xd=Xu./distortion;
    127     Yd=Yu./distortion;
    128 %pixel coordinates
    129     X=Xd*Calib.sx/Calib.dpx+Calib.Cx;
    130     Y=Yd/Calib.dpy+Calib.Cy;
    131 
    132 elseif isfield(Calib,'Pxcmx')&isfield(Calib,'Pxcmy')%old calib 
    133         X=Xphys*Calib.Pxcmx;
    134         Y=Yphys*Calib.Pxcmy;
    135 end
     119%
     120% %%%%%%%%%%%%%
     121% if isfield(Calib,'R')
     122%     R=(Calib.R)';
     123%     xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx;
     124%     yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Ty;
     125%     zc=R(7)*Xphys+R(8)*Yphys+R(9)*Zphys+Calib.Tz;
     126% %undistorted image coordinates
     127%     Xu=Calib.f*xc./zc;
     128%     Yu=Calib.f*yc./zc;
     129% %distorted image coordinates
     130%     distortion=(Calib.kappa1)*(Xu.*Xu+Yu.*Yu)+1; %A REVOIR
     131% % distortion=1;
     132%     Xd=Xu./distortion;
     133%     Yd=Yu./distortion;
     134% %pixel coordinates
     135%     X=Xd*Calib.sx/Calib.dpx+Calib.Cx;
     136%     Y=Yd/Calib.dpy+Calib.Cy;
     137%
     138% elseif isfield(Calib,'Pxcmx')&isfield(Calib,'Pxcmy')%old calib 
     139%         X=Xphys*Calib.Pxcmx;
     140%         Y=Yphys*Calib.Pxcmy;
     141% end
    136142
    137143
Note: See TracChangeset for help on using the changeset viewer.