'px': transform fields from physical coordinates (phys) to image (px) coordinates
0001 %'px': transform fields from physical coordinates (phys) to image (px) coordinates 0002 0003 % OUTPUT: 0004 % DataOut: structure of modified data (transforms DataIn) 0005 % DataOut.CoordType='px': labels image coordinates 0006 % DataOut.CoordUnit= 'px' : units of output coordinates 0007 % DataOut.X and .Y arrays of image coordinates X, Y 0008 % DataOut.U, .V velocity in pixel displacement on the image (unit=px), if velocity exists as input 0009 % 0010 %INPUT: 0011 % DataIn: structure of possible input data (like UvData) or cell of structures (several fields): 0012 % DataIn.CoordType='phys': allows transform to px, else no transform (DataOut=DataIn) 0013 % DataIn.X and .Y arrays of physical coordinates X, Y 0014 % DataIn.Z corresponding array of Z coordinates (=0 by default) 0015 % DataIn.U, V corresponding array of velocity components 0016 % DataIn.W corresponding array of the third velocity component in 3D case 0017 % DataIn.dt: time interval of the image pair used for velocity measurement (NEEDED TO GET OUTPUT RESULT)) 0018 % DataIn.A, AX, AY : image or scalar input -> EMPTY CORRESPONDING OUTPUT (A REVOIR) 0019 % Other fields in DataIn: copied to DataOut without modification 0020 % Calib: structure containing the calibration parameters (Tsai) or containing a subtree Calib.GeometryCalib with these parameters 0021 % 0022 % call the functions phys_XYZ or px_XYZ (case of images) for pointwise coordinate transforms 0023 0024 function [DataOut,DataOut_1]=px(Data,CalibData,Data_1,CalibData_1)%DataIn,Calib) 0025 % A FAIRE: 1- verifier si DataIn est une 'field structure'(.ListVarName'): 0026 % chercher ListVarAttribute, for each field (cell of variables): 0027 % .CoordType: 'phys' or 'px' (default==px, no transform) 0028 % .scale_factor: =dt (to transform displacement into velocity) default=1 0029 % .covariance: 'scalar', 'coord', 'D_i': covariant (like velocity), 'D^i': contravariant (like gradient), 'D^jD_i' (like strain tensor) 0030 % (default='coord' if .Role='coord_x,_y..., 0031 % 'D_i' if '.Role='vector_x,...', 0032 % 'scalar', else (thenno change except scale factor) 0033 if ~(exist('CalibData','var') && isfield(CalibData,'GeometryCalib')) 0034 DataOut=Data; 0035 else 0036 DataOut=px_1(Data,CalibData.GeometryCalib); 0037 end 0038 if exist('Data_1','var') 0039 if ~(exist('CalibData_1','var') && isfield(CalibData_1,'GeometryCalib')) 0040 DataOut_1=Data_1; 0041 else 0042 DataOut_1=px_1(Data_1,CalibData_1.GeometryCalib); 0043 end 0044 else 0045 DataOut_1=[]; 0046 end 0047 0048 0049 %------------------------------------------------ 0050 function DataOut=px_1(Data,Calib) 0051 DataOut=Data;%default 0052 0053 %Act only if .CoordType=phys, and Calib defined 0054 if isfield(Data,'CoordType')& isequal(Data.CoordType,'phys')& ~isempty(Calib) 0055 DataOut.CoordType='px'; %put flag for pixel coordinates 0056 DataOut.CoordUnit='px'; 0057 %transform of X,Y coordinates 0058 if isfield(Data,'Z')&~isempty(Data.Z) 0059 Z=Data.Z; 0060 else 0061 Z=0; 0062 end 0063 if isfield(Data,'X') & isfield(Data,'Y') 0064 [DataOut.X,DataOut.Y]=px_XYZ(Calib,Data.X,Data.Y,Z); 0065 if isfield(Data,'U')&isfield(Data,'V')& isfield(Data,'dt')& ~isequal(Data.dt,0) 0066 Data.U=Data.U*Data.dt; 0067 Data.V=Data.V*Data.dt; 0068 if isfield(Data,'W') 0069 W=Data.W*Data.dt; 0070 else 0071 W=0; 0072 end 0073 [XOut_1,YOut_1]=px_XYZ(Calib,Data.X-Data.U/2,Data.Y-Data.V/2,Z-W/2); 0074 [XOut_2,YOut_2]=px_XYZ(Calib,Data.X+Data.U/2,Data.Y+Data.V/2,Z+W/2); 0075 DataOut.U=XOut_2-XOut_1; 0076 DataOut.V=YOut_2-YOut_1; 0077 end 0078 end 0079 %transform of an image 0080 if isfield(Data,'A')&isfield(Data,'AX')&~isempty(Data.AX) & isfield(Data,'AY')&... 0081 isfield(Data,'AY')&~isempty(Data.AY)&length(Data.A)>1 0082 % if isfield(Data,'Field')&isequal(Data.Field,'images') 0083 %NO TRANSFORM FROM phys to px for images 0084 DataOut.A=[];% 0085 end 0086 end 0087