Changeset 1112 for trunk/src/phys_ima.m


Ignore:
Timestamp:
Jan 26, 2022, 7:37:21 PM (2 years ago)
Author:
sommeria
Message:

set_slice separated from geometrey_calib

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/phys_ima.m

    r1085 r1112  
    2727    npx=[npx siz(2)];
    2828    npy=[npy siz(1)];
    29     Calib=XmlData{icell}.GeometryCalib;
     29    Calib{icell}=XmlData{icell}.GeometryCalib;
     30    Slice{icell}=Calib{icell};
     31    if isfield(XmlData{icell},'Slice')
     32    Slice{icell}=XmlData{icell}.Slice;
     33    end
    3034    coord_x=[0.5 siz(2)-0.5];
    3135    coord_y=[0.5 siz(1)-0.5];
     
    3438    y_edge=[coord_y(1)*ones(1,npx(icell)) linspace(coord_y(1),coord_y(end),npy(icell))...
    3539        coord_y(end)*ones(1,npx(icell)) linspace(coord_y(end),coord_y(1),npy(icell))];%y coordinates of the image edge(four sides)
    36     [xcorner_new,ycorner_new]=phys_XYZ(Calib,x_edge,y_edge,ZIndex);%corresponding physical coordinates
     40    [xcorner_new,ycorner_new]=phys_XYZ(Calib{icell},Slice{icell},x_edge,y_edge,ZIndex);%corresponding physical coordinates
    3741    dx(icell)=(max(xcorner_new)-min(xcorner_new))/(siz(2)-1);
    3842    dy(icell)=(max(ycorner_new)-min(ycorner_new))/(siz(1)-1);
     
    5458A_out=cell(1,numel(A));
    5559
    56 for icell=1:length(A)
    57     Calib=XmlData{icell}.GeometryCalib;
     60for icell=1:numel(A)
    5861    % rescaling of the image coordinates without change of the image array
    59     if strcmp(Calib.CalibrationType,'rescale') && isequal(Calib,XmlData{1}.GeometryCalib)
     62    if strcmp(Calib{icell}.CalibrationType,'rescale') && isequal(Calib,XmlData{1}.GeometryCalib)
    6063        A_out{icell}=A{icell};%no transform
    6164        Rangx=[0.5 npx-0.5];%image coordiantes of corners
    6265        Rangy=[npy-0.5 0.5];
    63         [Rangx]=phys_XYZ(Calib,Rangx,[0.5 0.5],ZIndex);%case of translations without rotation and quadratic deformation
    64         [~,Rangy]=phys_XYZ(Calib,[0.5 0.5],Rangy,ZIndex);
     66        [Rangx]=phys_XYZ(Calib{icell},[],Rangx,[0.5 0.5],ZIndex);%case of translations without rotation and quadratic deformation
     67        [~,Rangy]=phys_XYZ(Calib{icell},[],[0.5 0.5],Rangy,ZIndex);
    6568    else
    6669        % the image needs to be interpolated to the new coordinates
    6770        Z=0; %default
    68         if isfield(Calib,'SliceCoord')&& size(Calib.SliceCoord,1)>=ZIndex %.Z= index of plane
    69             SliceCoord=Calib.SliceCoord(ZIndex,:);
     71        if isfield(Slice{icell},'SliceCoord')&& size(Slice{icell}.SliceCoord,1)>=ZIndex %.Z= index of plane
     72            SliceCoord=Slice{icell}.SliceCoord(ZIndex,:);
    7073            Z=SliceCoord(3);
    71             if isfield(Calib, 'SliceAngle') && size(Calib.SliceAngle,1)>=ZIndex && ~isequal(Calib.SliceAngle(ZIndex,:),[0 0 0])
    72                 norm_plane=angle2normal(Calib.SliceAngle(ZIndex,:));
     74            if isfield(Slice{icell}, 'SliceAngle') && size(Slice{icell}.SliceAngle,1)>=ZIndex && ~isequal(Slice{icell}.SliceAngle(ZIndex,:),[0 0 0])
     75                norm_plane=angle2normal(Slice{icell}.SliceAngle(ZIndex,:));
    7376                Z=Z-(norm_plane(1)*(X-SliceCoord(1))+norm_plane(2)*(Y-SliceCoord(2)))/norm_plane(3);
    7477            end
     
    7780        yima=npy(icell)-0.5:-1:0.5;
    7881        [XIMA_init,YIMA_init]=meshgrid(xima,yima);%grid of initial image in px coordinates
    79         [XIMA,YIMA]=px_XYZ(XmlData{icell}.GeometryCalib,X,Y,Z);% image coordinates for each point in the real
     82        [XIMA,YIMA]=px_XYZ(Calib{icell},Slice{icell},X,Y,Z);% image coordinates for each point in the real
    8083        testuint8=isa(A{icell},'uint8');
    8184        testuint16=isa(A{icell},'uint16');
Note: See TracChangeset for help on using the changeset viewer.