- Timestamp:
- Jan 7, 2022, 10:55:01 AM (3 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/angle2normal.m
r1080 r1108 1 1 %calculate the components of the unit vector norm_plane normal to the plane 2 2 %defined by the rotation vector PlaneAngle (in degree) 3 % this gives the equation of the plane as norm_plane(1)x + norm_plane(2)y + norm_plane(2)z = 03 % this gives the equation of the plane as norm_plane(1)x + norm_plane(2)y +norm_plane(3)z = cte 4 4 5 5 function norm_plane=rotate(PlaneAngle) -
trunk/src/phys_XYZ.m
r1107 r1108 4 4 % 5 5 %OUTPUT: 6 % 6 % Xphys,Yphys,Zphys: vector of phys coordinates corresponding to the input vector of image coordinates 7 7 %INPUT: 8 %Z: index of plane 8 % Calib: Matlab structure containing the calibration parameters (pinhole camera model, see 9 % http://servforge.legi.grenoble-inp.fr/projects/soft-uvmat/wiki/UvmatHelp#GeometryCalib) and the 10 % parameters describing the illumination plane(s) 11 % .Tx_Ty_Tz: translation (3 phys coordinates) defining the origine of the camera frame 12 % .R : rotation matrix from phys to camera frame 13 % .fx_fy: focal length along each direction of the image 14 % X, Y: vectors of X and Y image coordinates 15 % ZIndex: index defining the current illumination plane in a volume scan 9 16 10 17 %======================================================================= … … 28 35 function [Xphys,Yphys,Zphys]=phys_XYZ(Calib,X,Y,Zindex) 29 36 %------------------------------------------------------------------------ 30 testangle=0; 31 test_refraction=0; 37 testangle=0;% =1 if the illumination plane is tilted with respect to the horizontal plane Xphys Yphys 38 test_refraction=0;% =1 if the considered points are viewed through an horizontal interface (located at z=Calib.InterfaceCoord(3)') 32 39 Zphys=0; %default output 33 40 if exist('Zindex','var')&& isequal(Zindex,round(Zindex))&& Zindex>0 && isfield(Calib,'SliceCoord')&&size(Calib.SliceCoord,1)>=Zindex 34 41 if isfield(Calib, 'SliceAngle') && size(Calib.SliceAngle,1)>=Zindex && ~isequal(Calib.SliceAngle(Zindex,:),[0 0 0]) 35 42 testangle=1; 36 norm_plane=angle2normal(Calib.SliceAngle(Zindex,:)); 43 norm_plane=angle2normal(Calib.SliceAngle(Zindex,:));% coordinates of the unit vector normal to the current illumination plane 37 44 end 38 45 Z0=Calib.SliceCoord(Zindex,3);%horizontal plane z=cte 39 46 Z0virt=Z0; 40 47 if isfield(Calib,'InterfaceCoord') && isfield(Calib,'RefractionIndex') 41 H=Calib.InterfaceCoord(3); 48 H=Calib.InterfaceCoord(3);% z position of the water surface 42 49 if H>Z0 43 50 Z0virt=H-(H-Z0)/Calib.RefractionIndex; %corrected z (virtual object) … … 69 76 if isfield(Calib,'R') 70 77 R=(Calib.R)'; 78 c=Z0virt; 71 79 if testangle 80 % equation of the illumination plane: z=ax+by+c 72 81 a=-norm_plane(1)/norm_plane(3); 73 82 b=-norm_plane(2)/norm_plane(3); 74 83 if test_refraction 75 a =a/Calib.RefractionIndex;76 b =b/Calib.RefractionIndex;84 avirt=a/Calib.RefractionIndex; 85 bvirt=b/Calib.RefractionIndex; 77 86 end 78 R(1)=R(1)+a*R(3); 79 R(2)=R(2)+b*R(3); 80 R(4)=R(4)+a*R(6); 81 R(5)=R(5)+b*R(6); 82 R(7)=R(7)+a*R(9); 83 R(8)=R(8)+b*R(9); 87 c=Z0virt-avirt*Calib.SliceCoord(Zindex,1)-bvirt*Calib.SliceCoord(Zindex,2);% Z0 = (virtual) z coordinate on the rotation axis (assumed horizontal) 88 % c=z coordinate at (x,y)=(0,0) 89 R(1)=R(1)+avirt*R(3); 90 R(2)=R(2)+bvirt*R(3); 91 R(4)=R(4)+avirt*R(6); 92 R(5)=R(5)+bvirt*R(6); 93 R(7)=R(7)+avirt*R(9); 94 R(8)=R(8)+bvirt*R(9); 84 95 end 85 96 Tx=Calib.Tx_Ty_Tz(1); … … 93 104 Z21=R(4)*R(9)-R(6)*R(7); 94 105 Z22=R(3)*R(7)-R(1)*R(9); 95 Zx0=R(3)*R(5)-R(2)*R(6);96 Zy0=R(1)*R(6)-R(3)*R(4);97 A11=R(8)*Ty-R(5)*Tz+Z11*Z0virt;98 A12=R(2)*Tz-R(8)*Tx+Z12*Z0virt;99 A21=-R(7)*Ty+R(4)*Tz+Z21*Z0virt;100 A22=-R(1)*Tz+R(7)*Tx+Z22*Z0virt;101 X0=(R(5)*Tx-R(2)*Ty+Zx0* Z0virt);102 Y0=(-R(4)*Tx+R(1)*Ty+Zy0* Z0virt);106 Zx0=R(3)*R(5)-R(2)*R(6); 107 Zy0=R(1)*R(6)-R(3)*R(4); 108 B11=R(8)*Ty-R(5)*Tz+Z11*c; 109 B12=R(2)*Tz-R(8)*Tx+Z12*c; 110 B21=-R(7)*Ty+R(4)*Tz+Z21*c; 111 B22=-R(1)*Tz+R(7)*Tx+Z22*c; 112 X0=(R(5)*Tx-R(2)*Ty+Zx0*c); 113 Y0=(-R(4)*Tx+R(1)*Ty+Zy0*c); 103 114 %px to camera: 104 115 Xd=(X-Calib.Cx_Cy(1))/Calib.fx_fy(1); % sensor coordinates … … 116 127 end 117 128 denom=Dx*Xu+Dy*Yu+D0; 118 Xphys=( A11.*Xu+A12.*Yu+X0)./denom;%world coordinates119 Yphys=( A21.*Xu+A22.*Yu+Y0)./denom;129 Xphys=(B11.*Xu+B12.*Yu+X0)./denom;%world coordinates 130 Yphys=(B21.*Xu+B22.*Yu+Y0)./denom; 120 131 if testangle 121 132 Zphys=Z0+a*Xphys+b*Yphys; -
trunk/src/series.m
r1107 r1108 1057 1057 if ~isempty(VideoObject)% case of movies 1058 1058 imainfo=get(VideoObject); 1059 if isfield(imainfo,'NumFrames') 1060 imainfo.NumberOfFrames=imainfo.NumFrames; 1061 end 1059 1062 if isempty(j1_series) % frame index along i 1060 1063 Time=zeros(imainfo.NumberOfFrames+1,2); … … 1707 1710 OutputDir=''; 1708 1711 answer=''; 1709 if isfield(Param,'OutputSubDir') % possibly update the output dir if it already exists1712 if isfield(Param,'OutputSubDir')&& isfield(Param,'OutputDirExt')% possibly update the output dir if it already exists 1710 1713 PathOut=get(handles.OutputPath,'String'); 1711 1714 if ~exist(PathOut,'dir') % test if the dir already exist … … 1734 1737 end 1735 1738 end 1739 1736 1740 SubDirOut=[Param.OutputSubDir Param.OutputDirExt]; 1737 1741 SubDirOutNew=SubDirOut; … … 1782 1786 OutputDir=Param.ActionInput.LogPath; 1783 1787 end 1784 if isfield(Param,'OutputSubDir') 1785 set(handles.OutputSubDir,'String',Param.OutputSubDir)1786 set(handles.OutputDirExt,'String',Param.OutputDirExt)1787 drawnow1788 if isfield(Param,'OutputSubDir')&& isfield(Param,'OutputDirExt') 1789 set(handles.OutputSubDir,'String',Param.OutputSubDir) 1790 set(handles.OutputDirExt,'String',Param.OutputDirExt) 1791 drawnow 1788 1792 end 1789 1793 if get(handles.Replicate,'Value') … … 2551 2555 end 2552 2556 Coord_z=get(handles.Coord_z,'String'); 2553 if ~isempty(Coord_z) && isempty(find(strcmp(Coord_z,ListVarName))) 2557 if ~isempty(Coord_z) && isempty(find(strcmp(Coord_z,ListVarName)))REFRESH 2554 2558 FieldList={}; 2555 2559 set(handles.Coord_z,'String','') -
trunk/src/uvmat.m
r1107 r1108 1374 1374 Angle_1=linspace(SliceData.SliceAngle_1(1),SliceData.SliceAngle_1(2),SliceData.NbSlice); 1375 1375 Angle_2=linspace(SliceData.SliceAngle_2(1),SliceData.SliceAngle_2(2),SliceData.NbSlice); 1376 GeometryCalib.SliceAngle(:,1)=Angle_1';%rotation a round x axis (to generalise)1377 GeometryCalib.SliceAngle(:,2)=Angle_2';%rotation a round y axis (to generalise)1376 GeometryCalib.SliceAngle(:,1)=Angle_1';%rotation angle around x axis 1377 GeometryCalib.SliceAngle(:,2)=Angle_2';%rotation angle around y axis 1378 1378 GeometryCalib.SliceAngle(:,3)=0; 1379 1379 if SliceData.CheckRefraction … … 1435 1435 else 1436 1436 if check_update 1437 display([XmlName ' updated with calibration parameters'])1437 display([XmlName ' updated with slice positions']) 1438 1438 else 1439 display([XmlName ' created with calibration parameters'])1439 display([XmlName ' created with slice positions']) 1440 1440 end 1441 1441 end
Note: See TracChangeset
for help on using the changeset viewer.