Changeset 1078 for trunk/src/phys_XYZ.m


Ignore:
Timestamp:
Mar 30, 2020, 3:48:19 PM (5 years ago)
Author:
sommeria
Message:

various updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/phys_XYZ.m

    r1071 r1078  
    11%------------------------------------------------------------------------
    22%'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)
    44%
    55%OUTPUT:
     
    3030testangle=0;
    3131test_refraction=0;
     32Zphys=0; %default output
    3233if 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])
    3435        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,:));
    4437    end
    4538    Z0=Calib.SliceCoord(Zindex,3);%horizontal plane z=cte
    46 %     end
    4739    Z0virt=Z0;
    4840    if isfield(Calib,'InterfaceCoord') && isfield(Calib,'RefractionIndex')
     
    134126end
    135127
    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 positions
    140 %                    (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 coordinates
    145 % [Z0]: corresponding array of z physical coordinates (0 by default)
Note: See TracChangeset for help on using the changeset viewer.