Changeset 1112 for trunk/src/phys_ima.m
- Timestamp:
- Jan 26, 2022, 7:37:21 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/phys_ima.m
r1085 r1112 27 27 npx=[npx siz(2)]; 28 28 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 30 34 coord_x=[0.5 siz(2)-0.5]; 31 35 coord_y=[0.5 siz(1)-0.5]; … … 34 38 y_edge=[coord_y(1)*ones(1,npx(icell)) linspace(coord_y(1),coord_y(end),npy(icell))... 35 39 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 coordinates40 [xcorner_new,ycorner_new]=phys_XYZ(Calib{icell},Slice{icell},x_edge,y_edge,ZIndex);%corresponding physical coordinates 37 41 dx(icell)=(max(xcorner_new)-min(xcorner_new))/(siz(2)-1); 38 42 dy(icell)=(max(ycorner_new)-min(ycorner_new))/(siz(1)-1); … … 54 58 A_out=cell(1,numel(A)); 55 59 56 for icell=1:length(A) 57 Calib=XmlData{icell}.GeometryCalib; 60 for icell=1:numel(A) 58 61 % 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) 60 63 A_out{icell}=A{icell};%no transform 61 64 Rangx=[0.5 npx-0.5];%image coordiantes of corners 62 65 Rangy=[npy-0.5 0.5]; 63 [Rangx]=phys_XYZ(Calib ,Rangx,[0.5 0.5],ZIndex);%case of translations without rotation and quadratic deformation64 [~,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); 65 68 else 66 69 % the image needs to be interpolated to the new coordinates 67 70 Z=0; %default 68 if isfield( Calib,'SliceCoord')&& size(Calib.SliceCoord,1)>=ZIndex %.Z= index of plane69 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,:); 70 73 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,:)); 73 76 Z=Z-(norm_plane(1)*(X-SliceCoord(1))+norm_plane(2)*(Y-SliceCoord(2)))/norm_plane(3); 74 77 end … … 77 80 yima=npy(icell)-0.5:-1:0.5; 78 81 [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 real82 [XIMA,YIMA]=px_XYZ(Calib{icell},Slice{icell},X,Y,Z);% image coordinates for each point in the real 80 83 testuint8=isa(A{icell},'uint8'); 81 84 testuint16=isa(A{icell},'uint16');
Note: See TracChangeset
for help on using the changeset viewer.