source: trunk/src/px_XYZ.m @ 84

Last change on this file since 84 was 84, checked in by sommeria, 14 years ago

-update_imadoc: copy the timing information of the movie file avi in the new xml file when a geometry_calibration is performed
-set_grid: modified to produce grids in px coordiantes and to display the produced grid
-geometry_calib: display the point with max error
-civ: bug corrected for copying avi movies to png files
-uvmat: small bug fixes
-px_XYZ: introduce default values for Calib parameters

File size: 1.3 KB
Line 
1
2function [X,Y]=px_XYZ(Calib,Xphys,Yphys,Zphys)
3X=[];%default
4Y=[];
5% if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'PlanePos')&length(Calib.PlanePos)>=Z
6%     Zindex=Z;
7%     planepos=Calib.PlanePos{Zindex};
8%     zphys=planepos(3);%A GENERALISER CAS AVEC ANGLE
9% else
10%     zphys=0;
11% end
12if ~exist('Zphys','var')
13    Zphys=0;
14end
15if ~isfield(Calib,'f')
16    Calib.f=1;
17end
18if ~isfield(Calib,'kappa1')
19    Calib.kappa1=0;
20end
21if ~isfield(Calib,'sx')
22    Calib.sx=1;
23end
24if ~isfield(Calib,'dpx')
25    Calib.dpx=1;
26end
27if ~isfield(Calib,'dpy')
28    Calib.dpy=1;
29end
30if ~isfield(Calib,'Cx')
31    Calib.Cx=0;
32end
33if ~isfield(Calib,'Cy')
34    Calib.Cy=0;
35end
36%%%%%%%%%%%%%
37if isfield(Calib,'R')
38    R=(Calib.R)';
39    xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx;
40    yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Ty;
41    zc=R(7)*Xphys+R(8)*Yphys+R(9)*Zphys+Calib.Tz;
42%undistorted image coordinates
43    Xu=Calib.f*xc./zc;
44    Yu=Calib.f*yc./zc;
45%distorted image coordinates
46    distortion=(Calib.kappa1)*(Xu.*Xu+Yu.*Yu)+1; %A REVOIR
47% distortion=1;
48    Xd=Xu./distortion;
49    Yd=Yu./distortion;
50%pixel coordinates
51    X=Xd*Calib.sx/Calib.dpx+Calib.Cx;
52    Y=Yd/Calib.dpy+Calib.Cy;
53
54elseif isfield(Calib,'Pxcmx')&isfield(Calib,'Pxcmy')%old calib 
55        X=Xphys*Calib.Pxcmx;
56        Y=Yphys*Calib.Pxcmy;
57end
Note: See TracBrowser for help on using the repository browser.