source: trunk/src/px.m @ 19

Last change on this file since 19 was 19, checked in by gostiaux, 14 years ago

the private files have been moved down to the root folder

File size: 3.9 KB
Line 
1%'px': transform fields from physical coordinates (phys) to image (px) coordinates
2
3% OUTPUT:
4% DataOut:   structure of modified data (transforms DataIn)
5%       DataOut.CoordType='px': labels image coordinates
6%       DataOut.CoordUnit= 'px' : units of output coordinates
7%       DataOut.X and .Y arrays of image coordinates X, Y
8%       DataOut.U, .V velocity in pixel displacement on the image (unit=px), if velocity exists as input
9%   
10%INPUT:
11% DataIn:  structure of possible input data (like UvData) or cell of structures (several fields):
12%      DataIn.CoordType='phys': allows transform to px, else no transform   (DataOut=DataIn)
13%      DataIn.X and .Y arrays of physical coordinates X, Y
14%      DataIn.Z corresponding array of Z coordinates (=0 by default)
15%      DataIn.U, V corresponding array of velocity components
16%      DataIn.W corresponding array of the third velocity component in 3D case
17%      DataIn.dt: time interval of the image pair used for velocity measurement (NEEDED TO GET OUTPUT RESULT))
18%      DataIn.A, AX, AY : image or scalar input -> EMPTY  CORRESPONDING OUTPUT (A REVOIR)
19%      Other fields in DataIn: copied to DataOut without modification
20% Calib: structure containing the calibration parameters (Tsai) or containing a subtree Calib.GeometryCalib with these parameters
21%
22% call the functions phys_XYZ or px_XYZ (case of images) for pointwise coordinate transforms
23
24function [DataOut,DataOut_1]=px(Data,CalibData,Data_1,CalibData_1)%DataIn,Calib)
25% A FAIRE: 1- verifier si DataIn est une 'field structure'(.ListVarName'):
26% chercher ListVarAttribute, for each field (cell of variables):
27%   .CoordType: 'phys' or 'px'   (default==px, no transform)
28%   .scale_factor: =dt (to transform displacement into velocity) default=1
29%   .covariance: 'scalar', 'coord', 'D_i': covariant (like velocity), 'D^i': contravariant (like gradient), 'D^jD_i' (like strain tensor)
30%   (default='coord' if .Role='coord_x,_y...,
31%            'D_i' if '.Role='vector_x,...',
32%              'scalar', else (thenno change except scale factor)
33if  ~(exist('CalibData','var') && isfield(CalibData,'GeometryCalib'))
34    DataOut=Data;
35else
36    DataOut=px_1(Data,CalibData.GeometryCalib);
37end
38if exist('Data_1','var')
39    if ~(exist('CalibData_1','var') && isfield(CalibData_1,'GeometryCalib'))
40        DataOut_1=Data_1;
41    else
42        DataOut_1=px_1(Data_1,CalibData_1.GeometryCalib);
43    end
44else
45    DataOut_1=[];
46end
47
48
49%------------------------------------------------
50function DataOut=px_1(Data,Calib)
51DataOut=Data;%default
52
53%Act only if .CoordType=phys, and Calib defined
54if isfield(Data,'CoordType')& isequal(Data.CoordType,'phys')& ~isempty(Calib)
55    DataOut.CoordType='px'; %put flag for pixel coordinates
56    DataOut.CoordUnit='px';
57    %transform of X,Y coordinates
58    if isfield(Data,'Z')&~isempty(Data.Z)
59        Z=Data.Z;
60    else
61        Z=0;
62    end
63    if isfield(Data,'X') & isfield(Data,'Y')
64        [DataOut.X,DataOut.Y]=px_XYZ(Calib,Data.X,Data.Y,Z);
65        if isfield(Data,'U')&isfield(Data,'V')& isfield(Data,'dt')& ~isequal(Data.dt,0)
66            Data.U=Data.U*Data.dt;
67            Data.V=Data.V*Data.dt;
68            if isfield(Data,'W')
69                W=Data.W*Data.dt;
70            else
71                W=0;
72            end
73            [XOut_1,YOut_1]=px_XYZ(Calib,Data.X-Data.U/2,Data.Y-Data.V/2,Z-W/2);
74            [XOut_2,YOut_2]=px_XYZ(Calib,Data.X+Data.U/2,Data.Y+Data.V/2,Z+W/2);
75            DataOut.U=XOut_2-XOut_1;
76            DataOut.V=YOut_2-YOut_1;
77        end
78    end
79    %transform of an image
80    if isfield(Data,'A')&isfield(Data,'AX')&~isempty(Data.AX) & isfield(Data,'AY')&...
81                                   isfield(Data,'AY')&~isempty(Data.AY)&length(Data.A)>1
82%         if isfield(Data,'Field')&isequal(Data.Field,'images')
83          %NO TRANSFORM FROM phys to px for images
84            DataOut.A=[];%
85    end
86end
87
Note: See TracBrowser for help on using the repository browser.