Index: trunk/src/transform_field/px.m
===================================================================
--- trunk/src/transform_field/px.m	(revision 40)
+++ trunk/src/transform_field/px.m	(revision 116)
@@ -18,5 +18,5 @@
 %      DataIn.A, AX, AY : image or scalar input -> EMPTY  CORRESPONDING OUTPUT (A REVOIR)
 %      Other fields in DataIn: copied to DataOut without modification
-% Calib: structure containing the calibration parameters (Tsai) or containing a subtree Calib.GeometryCalib with these parameters
+% Calib: structure containing the  substructure Calib.GeometryCalib with the calibration parameters
 %
 % call the function  px_XYZ (case of images) for pointwise coordinate transforms
@@ -36,5 +36,8 @@
     DataOut=px_1(Data,CalibData.GeometryCalib);
 end
-if exist('Data_1','var')
+if isfield(DataOut,'Z')
+    DataOut=rmfield(DataOut,'Z');
+end
+if exist('Data_1','var')% if there is a second input field, it is also transformed
     if ~(exist('CalibData_1','var') && isfield(CalibData_1,'GeometryCalib'))
         DataOut_1=Data_1;
@@ -42,5 +45,8 @@
         DataOut_1=px_1(Data_1,CalibData_1.GeometryCalib);
     end
-else
+    if isfield(DataOut_1,'Z')
+        DataOut_1=rmfield(DataOut_1,'Z');
+    end
+else % no second input field then empty second output field
     DataOut_1=[];
 end
@@ -52,9 +58,9 @@
 
 %Act only if .CoordType=phys, and Calib defined
-if isfield(Data,'CoordType')& isequal(Data.CoordType,'phys')& ~isempty(Calib)
+if isfield(Data,'CoordType')&& isequal(Data.CoordType,'phys')&& ~isempty(Calib)
     DataOut.CoordType='px'; %put flag for pixel coordinates
     DataOut.CoordUnit='px';
     %transform of X,Y coordinates
-    if isfield(Data,'Z')&~isempty(Data.Z)
+    if isfield(Data,'Z')&&~isempty(Data.Z)
         Z=Data.Z;
     else
@@ -97,41 +103,41 @@
 % [Zphys]: corresponding array of z physical coordinates (0 by default)
 
-
-function [X,Y]=px_XYZ(Calib,Xphys,Yphys,Zphys)
-X=[];%default
-Y=[];
-% if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'PlanePos')&length(Calib.PlanePos)>=Z
-%     Zindex=Z;
-%     planepos=Calib.PlanePos{Zindex};
-%     zphys=planepos(3);%A GENERALISER CAS AVEC ANGLE
-% else
-%     zphys=0;
+% 
+% function [X,Y]=px_XYZ(Calib,Xphys,Yphys,Zphys)
+% X=[];%default
+% Y=[];
+% % if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'PlanePos')&length(Calib.PlanePos)>=Z
+% %     Zindex=Z;
+% %     planepos=Calib.PlanePos{Zindex};
+% %     zphys=planepos(3);%A GENERALISER CAS AVEC ANGLE
+% % else
+% %     zphys=0;
+% % end
+% if ~exist('Zphys','var')
+%     Zphys=0;
 % end
-if ~exist('Zphys','var')
-    Zphys=0;
-end
-
-%%%%%%%%%%%%%
-if isfield(Calib,'R')
-    R=(Calib.R)';
-    xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx;
-    yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Ty;
-    zc=R(7)*Xphys+R(8)*Yphys+R(9)*Zphys+Calib.Tz;
-%undistorted image coordinates
-    Xu=Calib.f*xc./zc;
-    Yu=Calib.f*yc./zc;
-%distorted image coordinates
-    distortion=(Calib.kappa1)*(Xu.*Xu+Yu.*Yu)+1; %A REVOIR
-% distortion=1;
-    Xd=Xu./distortion;
-    Yd=Yu./distortion;
-%pixel coordinates
-    X=Xd*Calib.sx/Calib.dpx+Calib.Cx;
-    Y=Yd/Calib.dpy+Calib.Cy;
-
-elseif isfield(Calib,'Pxcmx')&isfield(Calib,'Pxcmy')%old calib  
-        X=Xphys*Calib.Pxcmx;
-        Y=Yphys*Calib.Pxcmy;
-end
+% 
+% %%%%%%%%%%%%%
+% if isfield(Calib,'R')
+%     R=(Calib.R)';
+%     xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx;
+%     yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Ty;
+%     zc=R(7)*Xphys+R(8)*Yphys+R(9)*Zphys+Calib.Tz;
+% %undistorted image coordinates
+%     Xu=Calib.f*xc./zc;
+%     Yu=Calib.f*yc./zc;
+% %distorted image coordinates
+%     distortion=(Calib.kappa1)*(Xu.*Xu+Yu.*Yu)+1; %A REVOIR
+% % distortion=1;
+%     Xd=Xu./distortion;
+%     Yd=Yu./distortion;
+% %pixel coordinates
+%     X=Xd*Calib.sx/Calib.dpx+Calib.Cx;
+%     Y=Yd/Calib.dpy+Calib.Cy;
+% 
+% elseif isfield(Calib,'Pxcmx')&isfield(Calib,'Pxcmy')%old calib  
+%         X=Xphys*Calib.Pxcmx;
+%         Y=Yphys*Calib.Pxcmy;
+% end
 
 
