Changeset 1078 for trunk/src/phys_XYZ.m
- Timestamp:
- Mar 30, 2020, 3:48:19 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/phys_XYZ.m
r1071 r1078 1 1 %------------------------------------------------------------------------ 2 2 %'phys_XYZ':transforms image (px) to real world (phys) coordinates using geometric calibration parameters 3 % function [Xphys,Yphys ]=phys_XYZ(Calib,X,Y,Z)3 % function [Xphys,Yphys,Zphys]=phys_XYZ(Calib,X,Y,Zindex) 4 4 % 5 5 %OUTPUT: … … 30 30 testangle=0; 31 31 test_refraction=0; 32 Zphys=0; %default output 32 33 if exist('Zindex','var')&& isequal(Zindex,round(Zindex))&& Zindex>0 && isfield(Calib,'SliceCoord')&&size(Calib.SliceCoord,1)>=Zindex 33 if isfield(Calib, 'SliceAngle') && ~isequal(Calib.SliceAngle,[0 0 0])&& ~isequal(Calib.SliceAngle(Zindex,:),[0 0 0])34 if isfield(Calib, 'SliceAngle') && size(Calib.SliceAngle,1)>=Zindex && ~isequal(Calib.SliceAngle(Zindex,:),[0 0 0]) 34 35 testangle=1; 35 om=norm(Calib.SliceAngle(Zindex,:));%norm of rotation angle in radians 36 OmAxis=Calib.SliceAngle(Zindex,:)/om; %unit vector marking the rotation axis 37 cos_om=cos(pi*om/180); 38 sin_om=sin(pi*om/180); 39 coeff=OmAxis(3)*(1-cos_om); 40 norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om; 41 norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om; 42 norm_plane(3)=OmAxis(3)*coeff+cos_om; 43 % Z0=norm_plane*Calib.SliceCoord(Zindex,:)'/norm_plane(3); 36 norm_plane=angle2normal(Calib.SliceAngle(Zindex,:)); 44 37 end 45 38 Z0=Calib.SliceCoord(Zindex,3);%horizontal plane z=cte 46 % end47 39 Z0virt=Z0; 48 40 if isfield(Calib,'InterfaceCoord') && isfield(Calib,'RefractionIndex') … … 134 126 end 135 127 136 %'px_XYZ': transform phys coordinates to image coordinates (px)137 %138 % OUTPUT:139 % X,Y: array of coordinates in the image cooresponding to the input physical positions140 % (origin at lower leftcorner, unit=pixel)141 142 % INPUT:143 % Calib: structure containing the calibration parameters (read from the ImaDoc .xml file)144 % Xphys, Yphys: array of x,y physical coordinates145 % [Z0]: corresponding array of z physical coordinates (0 by default)
Note: See TracChangeset
for help on using the changeset viewer.