Changeset 116 for trunk/src/transform_field/px.m
- Timestamp:
- Oct 16, 2010, 5:56:00 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/transform_field/px.m
r40 r116 18 18 % DataIn.A, AX, AY : image or scalar input -> EMPTY CORRESPONDING OUTPUT (A REVOIR) 19 19 % Other fields in DataIn: copied to DataOut without modification 20 % Calib: structure containing the calibration parameters (Tsai) or containing a subtree Calib.GeometryCalib with theseparameters20 % Calib: structure containing the substructure Calib.GeometryCalib with the calibration parameters 21 21 % 22 22 % call the function px_XYZ (case of images) for pointwise coordinate transforms … … 36 36 DataOut=px_1(Data,CalibData.GeometryCalib); 37 37 end 38 if exist('Data_1','var') 38 if isfield(DataOut,'Z') 39 DataOut=rmfield(DataOut,'Z'); 40 end 41 if exist('Data_1','var')% if there is a second input field, it is also transformed 39 42 if ~(exist('CalibData_1','var') && isfield(CalibData_1,'GeometryCalib')) 40 43 DataOut_1=Data_1; … … 42 45 DataOut_1=px_1(Data_1,CalibData_1.GeometryCalib); 43 46 end 44 else 47 if isfield(DataOut_1,'Z') 48 DataOut_1=rmfield(DataOut_1,'Z'); 49 end 50 else % no second input field then empty second output field 45 51 DataOut_1=[]; 46 52 end … … 52 58 53 59 %Act only if .CoordType=phys, and Calib defined 54 if isfield(Data,'CoordType')& isequal(Data.CoordType,'phys')& ~isempty(Calib)60 if isfield(Data,'CoordType')&& isequal(Data.CoordType,'phys')&& ~isempty(Calib) 55 61 DataOut.CoordType='px'; %put flag for pixel coordinates 56 62 DataOut.CoordUnit='px'; 57 63 %transform of X,Y coordinates 58 if isfield(Data,'Z')& ~isempty(Data.Z)64 if isfield(Data,'Z')&&~isempty(Data.Z) 59 65 Z=Data.Z; 60 66 else … … 97 103 % [Zphys]: corresponding array of z physical coordinates (0 by default) 98 104 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; 109 118 % 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 136 142 137 143
Note: See TracChangeset
for help on using the changeset viewer.