Last change
on this file since 102 was
92,
checked in by gostiaux, 15 years ago
|
Plotting vectors centered on the middle of the arrow. Apparently this does not create any bug.
|
File size:
1.3 KB
|
Rev | Line | |
---|
[40] | 1 | |
---|
| 2 | function [X,Y]=px_XYZ(Calib,Xphys,Yphys,Zphys) |
---|
| 3 | X=[];%default |
---|
| 4 | Y=[]; |
---|
| 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 |
---|
| 12 | if ~exist('Zphys','var') |
---|
| 13 | Zphys=0; |
---|
| 14 | end |
---|
[84] | 15 | if ~isfield(Calib,'f') |
---|
| 16 | Calib.f=1; |
---|
| 17 | end |
---|
| 18 | if ~isfield(Calib,'kappa1') |
---|
| 19 | Calib.kappa1=0; |
---|
| 20 | end |
---|
| 21 | if ~isfield(Calib,'sx') |
---|
| 22 | Calib.sx=1; |
---|
| 23 | end |
---|
| 24 | if ~isfield(Calib,'dpx') |
---|
| 25 | Calib.dpx=1; |
---|
| 26 | end |
---|
| 27 | if ~isfield(Calib,'dpy') |
---|
| 28 | Calib.dpy=1; |
---|
| 29 | end |
---|
| 30 | if ~isfield(Calib,'Cx') |
---|
| 31 | Calib.Cx=0; |
---|
| 32 | end |
---|
| 33 | if ~isfield(Calib,'Cy') |
---|
| 34 | Calib.Cy=0; |
---|
| 35 | end |
---|
[40] | 36 | %%%%%%%%%%%%% |
---|
| 37 | if 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 | |
---|
| 54 | elseif isfield(Calib,'Pxcmx')&isfield(Calib,'Pxcmy')%old calib |
---|
| 55 | X=Xphys*Calib.Pxcmx; |
---|
| 56 | Y=Yphys*Calib.Pxcmy; |
---|
[92] | 57 | end |
---|
| 58 | |
---|
| 59 | |
---|
| 60 | |
---|
Note: See
TracBrowser
for help on using the repository browser.