[37] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
---|
| 2 | "http://www.w3.org/TR/REC-html40/loose.dtd"> |
---|
| 3 | <html> |
---|
| 4 | <head> |
---|
| 5 | <title>Description of phys_polar</title> |
---|
| 6 | <meta name="keywords" content="phys_polar"> |
---|
| 7 | <meta name="description" content="transform image coordinates (px) to physical coordinates"> |
---|
| 8 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
---|
| 9 | <meta name="generator" content="m2html © 2003 Guillaume Flandin"> |
---|
| 10 | <meta name="robots" content="index, follow"> |
---|
| 11 | <link type="text/css" rel="stylesheet" href="../m2html.css"> |
---|
| 12 | </head> |
---|
| 13 | <body> |
---|
| 14 | <a name="_top"></a> |
---|
| 15 | <div><a href="../index.html">Home</a> > <a href="index.html">.</a> > phys_polar.m</div> |
---|
| 16 | |
---|
| 17 | <!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td> |
---|
| 18 | <td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>--> |
---|
| 19 | |
---|
| 20 | <h1>phys_polar |
---|
| 21 | </h1> |
---|
| 22 | |
---|
| 23 | <h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
| 24 | <div class="box"><strong>transform image coordinates (px) to physical coordinates</strong></div> |
---|
| 25 | |
---|
| 26 | <h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
| 27 | <div class="box"><strong>function [DataOut,DataOut_1]=phys_polar(varargin) </strong></div> |
---|
| 28 | |
---|
| 29 | <h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
| 30 | <div class="fragment"><pre class="comment">transform image coordinates (px) to physical coordinates |
---|
| 31 | then transform to polar coordinates: |
---|
| 32 | [DataOut,DataOut_1]=phys_polar(varargin) |
---|
| 33 | |
---|
| 34 | OUTPUT: |
---|
| 35 | DataOut: structure of modified data field: .X=radius, .Y=azimuth angle, .U, .V are radial and azimuthal velocity components |
---|
| 36 | DataOut_1: second data field (if two fields are in input) |
---|
| 37 | |
---|
| 38 | INPUT: |
---|
| 39 | Data: structure of input data (like UvData) |
---|
| 40 | CalibData= structure containing the field .GeometryCalib with calibration parameters |
---|
| 41 | Data_1: second input field (not mandatory) |
---|
| 42 | CalibData_1= calibration parameters for the second field</pre></div> |
---|
| 43 | |
---|
| 44 | <!-- crossreference --> |
---|
| 45 | <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
| 46 | This function calls: |
---|
| 47 | <ul style="list-style-image:url(../matlabicon.gif)"> |
---|
| 48 | <li><a href="phys_XYZ.html" class="code" title="function [Xphys,Yphys,Zphys]=phys_XYZ(Calib,X,Y,Z)">phys_XYZ</a> 'phys_XYZ':transforms image (px) to real world (phys) coordinates using geometric calibration parameters</li><li><a href="px_XYZ.html" class="code" title="function [X,Y]=px_XYZ(Calib,Xphys,Yphys,Zphys)">px_XYZ</a> 'px_XYZ': transform phys coordinates to image coordinates (px)</li></ul> |
---|
| 49 | This function is called by: |
---|
| 50 | <ul style="list-style-image:url(../matlabicon.gif)"> |
---|
| 51 | </ul> |
---|
| 52 | <!-- crossreference --> |
---|
| 53 | |
---|
| 54 | <h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
| 55 | <ul style="list-style-image:url(../matlabicon.gif)"> |
---|
| 56 | <li><a href="#_sub1" class="code">function DataOut=phys_1(Data,Calib,origin_xy,radius_offset,angle_offset,angle_scale)</a></li><li><a href="#_sub2" class="code">function [A_out,Rangx,Rangy]=phys_Ima(A,CalibIn,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale)</a></li></ul> |
---|
| 57 | <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2> |
---|
| 58 | <div class="fragment"><pre>0001 <span class="comment">%transform image coordinates (px) to physical coordinates</span> |
---|
| 59 | 0002 <span class="comment">% then transform to polar coordinates:</span> |
---|
| 60 | 0003 <span class="comment">%[DataOut,DataOut_1]=phys_polar(varargin)</span> |
---|
| 61 | 0004 <span class="comment">%</span> |
---|
| 62 | 0005 <span class="comment">% OUTPUT:</span> |
---|
| 63 | 0006 <span class="comment">% DataOut: structure of modified data field: .X=radius, .Y=azimuth angle, .U, .V are radial and azimuthal velocity components</span> |
---|
| 64 | 0007 <span class="comment">% DataOut_1: second data field (if two fields are in input)</span> |
---|
| 65 | 0008 <span class="comment">%</span> |
---|
| 66 | 0009 <span class="comment">%INPUT:</span> |
---|
| 67 | 0010 <span class="comment">% Data: structure of input data (like UvData)</span> |
---|
| 68 | 0011 <span class="comment">% CalibData= structure containing the field .GeometryCalib with calibration parameters</span> |
---|
| 69 | 0012 <span class="comment">% Data_1: second input field (not mandatory)</span> |
---|
| 70 | 0013 <span class="comment">% CalibData_1= calibration parameters for the second field</span> |
---|
| 71 | 0014 |
---|
| 72 | 0015 <a name="_sub0" href="#_subfunctions" class="code">function [DataOut,DataOut_1]=phys_polar(varargin)</a> |
---|
| 73 | 0016 Calib{1}=[]; |
---|
| 74 | 0017 <span class="keyword">if</span> nargin==2||nargin==4 |
---|
| 75 | 0018 Data=varargin{1}; |
---|
| 76 | 0019 DataOut=Data;<span class="comment">%default</span> |
---|
| 77 | 0020 DataOut_1=[];<span class="comment">%default</span> |
---|
| 78 | 0021 CalibData=varargin{2}; |
---|
| 79 | 0022 <span class="keyword">if</span> isfield(CalibData,<span class="string">'GeometryCalib'</span>) |
---|
| 80 | 0023 Calib{1}=CalibData.GeometryCalib; |
---|
| 81 | 0024 <span class="keyword">end</span> |
---|
| 82 | 0025 Calib{2}=Calib{1}; |
---|
| 83 | 0026 <span class="keyword">else</span> |
---|
| 84 | 0027 DataOut.Txt=<span class="string">'wrong input: need two or four structures'</span>; |
---|
| 85 | 0028 <span class="keyword">end</span> |
---|
| 86 | 0029 test_1=0; |
---|
| 87 | 0030 <span class="keyword">if</span> nargin==4 |
---|
| 88 | 0031 test_1=1; |
---|
| 89 | 0032 Data_1=varargin{3}; |
---|
| 90 | 0033 DataOut_1=Data_1;<span class="comment">%default</span> |
---|
| 91 | 0034 CalibData_1=varargin{4}; |
---|
| 92 | 0035 <span class="keyword">if</span> isfield(CalibData_1,<span class="string">'GeometryCalib'</span>) |
---|
| 93 | 0036 Calib{2}=CalibData_1.GeometryCalib; |
---|
| 94 | 0037 <span class="keyword">end</span> |
---|
| 95 | 0038 <span class="keyword">end</span> |
---|
| 96 | 0039 |
---|
| 97 | 0040 <span class="comment">%parameters for polar coordinates (taken from the calibration data of the first field)</span> |
---|
| 98 | 0041 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span> |
---|
| 99 | 0042 origin_xy=[0 0];<span class="comment">%center for the polar coordinates in the original x,y coordinates</span> |
---|
| 100 | 0043 <span class="keyword">if</span> isfield(Calib{1},<span class="string">'PolarCentre'</span>) && isnumeric(Calib{1}.PolarCentre) |
---|
| 101 | 0044 <span class="keyword">if</span> isequal(length(Calib{1}.PolarCentre),2); |
---|
| 102 | 0045 origin_xy= Calib{1}.PolarCentre; |
---|
| 103 | 0046 <span class="keyword">end</span> |
---|
| 104 | 0047 <span class="keyword">end</span> |
---|
| 105 | 0048 radius_offset=0;<span class="comment">%reference radius used to offset the radial coordinate r</span> |
---|
| 106 | 0049 angle_offset=0; <span class="comment">%reference angle used as new origin of the polar angle (= axis Ox by default)</span> |
---|
| 107 | 0050 <span class="keyword">if</span> isfield(Calib{1},<span class="string">'PolarReferenceRadius'</span>) && isnumeric(Calib{1}.PolarReferenceRadius) |
---|
| 108 | 0051 radius_offset=Calib{1}.PolarReferenceRadius; |
---|
| 109 | 0052 <span class="keyword">end</span> |
---|
| 110 | 0053 <span class="keyword">if</span> radius_offset > 0 |
---|
| 111 | 0054 angle_scale=radius_offset; <span class="comment">%the azimuth is rescale in terms of the length along the reference radius</span> |
---|
| 112 | 0055 <span class="keyword">else</span> |
---|
| 113 | 0056 angle_scale=180/pi; <span class="comment">%polar angle in degrees</span> |
---|
| 114 | 0057 <span class="keyword">end</span> |
---|
| 115 | 0058 <span class="keyword">if</span> isfield(Calib{1},<span class="string">'PolarReferenceAngle'</span>) && isnumeric(Calib{1}.PolarReferenceAngle) |
---|
| 116 | 0059 angle_offset=Calib{1}.PolarReferenceAngle; <span class="comment">%offset angle (in unit of the final angle, degrees or arc length along the reference radius))</span> |
---|
| 117 | 0060 <span class="keyword">end</span> |
---|
| 118 | 0061 <span class="comment">% new x coordinate = radius-radius_offset;</span> |
---|
| 119 | 0062 <span class="comment">% new y coordinate = theta*angle_scale-angle_offset</span> |
---|
| 120 | 0063 |
---|
| 121 | 0064 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span> |
---|
| 122 | 0065 |
---|
| 123 | 0066 iscalar=0; |
---|
| 124 | 0067 <span class="keyword">if</span> ~isempty(Calib{1}) |
---|
| 125 | 0068 DataOut=<a href="#_sub1" class="code" title="subfunction DataOut=phys_1(Data,Calib,origin_xy,radius_offset,angle_offset,angle_scale)">phys_1</a>(Data,Calib{1},origin_xy,radius_offset,angle_offset,angle_scale); |
---|
| 126 | 0069 <span class="comment">%case of images or scalar</span> |
---|
| 127 | 0070 <span class="keyword">if</span> isfield(Data,<span class="string">'A'</span>)&isfield(Data,<span class="string">'AX'</span>)&~isempty(Data.AX) & isfield(Data,<span class="string">'AY'</span>)&<span class="keyword">...</span> |
---|
| 128 | 0071 ~isempty(Data.AY)&length(Data.A)>1 |
---|
| 129 | 0072 iscalar=1; |
---|
| 130 | 0073 A{1}=Data.A; |
---|
| 131 | 0074 <span class="keyword">end</span> |
---|
| 132 | 0075 <span class="comment">%transform of X,Y coordinates for vector fields</span> |
---|
| 133 | 0076 <span class="keyword">if</span> isfield(Data,<span class="string">'ZIndex'</span>)&~isempty(Data.ZIndex) |
---|
| 134 | 0077 ZIndex=Data.ZIndex; |
---|
| 135 | 0078 <span class="keyword">else</span> |
---|
| 136 | 0079 ZIndex=0; |
---|
| 137 | 0080 <span class="keyword">end</span> |
---|
| 138 | 0081 <span class="keyword">end</span> |
---|
| 139 | 0082 |
---|
| 140 | 0083 <span class="keyword">if</span> test_1 |
---|
| 141 | 0084 DataOut_1=<a href="#_sub1" class="code" title="subfunction DataOut=phys_1(Data,Calib,origin_xy,radius_offset,angle_offset,angle_scale)">phys_1</a>(Data_1,Calib{2},origin_xy,radius_offset,angle_offset,angle_scale); |
---|
| 142 | 0085 <span class="keyword">if</span> isfield(Data_1,<span class="string">'A'</span>)&isfield(Data_1,<span class="string">'AX'</span>)&~isempty(Data_1.AX) & isfield(Data_1,<span class="string">'AY'</span>)&<span class="keyword">...</span> |
---|
| 143 | 0086 ~isempty(Data_1.AY)&length(Data_1.A)>1 |
---|
| 144 | 0087 iscalar=iscalar+1; |
---|
| 145 | 0088 Calib{iscalar}=Calib{2}; |
---|
| 146 | 0089 A{iscalar}=Data_1.A; |
---|
| 147 | 0090 <span class="keyword">if</span> isfield(Data_1,<span class="string">'ZIndex'</span>)&~isequal(Data_1.ZIndex,ZIndex) |
---|
| 148 | 0091 DataOut.Txt=<span class="string">'inconsistent plane indexes in the two input fields'</span>; |
---|
| 149 | 0092 <span class="keyword">end</span> |
---|
| 150 | 0093 <span class="keyword">if</span> iscalar==1<span class="comment">% case for which only the second field is a scalar</span> |
---|
| 151 | 0094 [A,AX,AY]=<a href="#_sub2" class="code" title="subfunction [A_out,Rangx,Rangy]=phys_Ima(A,CalibIn,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale)">phys_Ima</a>(A,Calib,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale); |
---|
| 152 | 0095 DataOut_1.A=A{1}; |
---|
| 153 | 0096 DataOut_1.AX=AX; |
---|
| 154 | 0097 DataOut_1.AY=AY; |
---|
| 155 | 0098 <span class="keyword">return</span> |
---|
| 156 | 0099 <span class="keyword">end</span> |
---|
| 157 | 0100 <span class="keyword">end</span> |
---|
| 158 | 0101 <span class="keyword">end</span> |
---|
| 159 | 0102 <span class="keyword">if</span> iscalar~=0 |
---|
| 160 | 0103 [A,AX,AY]=<a href="#_sub2" class="code" title="subfunction [A_out,Rangx,Rangy]=phys_Ima(A,CalibIn,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale)">phys_Ima</a>(A,Calib,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale);<span class="comment">%</span> |
---|
| 161 | 0104 DataOut.A=A{1}; |
---|
| 162 | 0105 DataOut.AX=AX; |
---|
| 163 | 0106 DataOut.AY=AY; |
---|
| 164 | 0107 <span class="keyword">if</span> iscalar==2 |
---|
| 165 | 0108 DataOut_1.A=A{2}; |
---|
| 166 | 0109 DataOut_1.AX=AX; |
---|
| 167 | 0110 DataOut_1.AY=AY; |
---|
| 168 | 0111 <span class="keyword">end</span> |
---|
| 169 | 0112 <span class="keyword">end</span> |
---|
| 170 | 0113 |
---|
| 171 | 0114 <span class="comment">%------------------------------------------------</span> |
---|
| 172 | 0115 <a name="_sub1" href="#_subfunctions" class="code">function DataOut=phys_1(Data,Calib,origin_xy,radius_offset,angle_offset,angle_scale)</a> |
---|
| 173 | 0116 |
---|
| 174 | 0117 DataOut=Data; |
---|
| 175 | 0118 DataOut.CoordType=<span class="string">'phys'</span>; <span class="comment">%put flag for physical coordinates</span> |
---|
| 176 | 0119 <span class="keyword">if</span> isfield(Calib,<span class="string">'CoordUnit'</span>) |
---|
| 177 | 0120 DataOut.CoordUnit=Calib.CoordUnit; |
---|
| 178 | 0121 <span class="keyword">else</span> |
---|
| 179 | 0122 DataOut.CoordUnit=<span class="string">'cm'</span>; <span class="comment">%default</span> |
---|
| 180 | 0123 <span class="keyword">end</span> |
---|
| 181 | 0124 DataOut.TimeUnit=<span class="string">'s'</span>; |
---|
| 182 | 0125 <span class="comment">%perform a geometry transform if Calib contains a field .GeometryCalib</span> |
---|
| 183 | 0126 <span class="keyword">if</span> isfield(Data,<span class="string">'CoordType'</span>) && isequal(Data.CoordType,<span class="string">'px'</span>) && ~isempty(Calib) |
---|
| 184 | 0127 <span class="keyword">if</span> isfield(Data,<span class="string">'CoordUnit'</span>) |
---|
| 185 | 0128 DataOut=rmfield(DataOut,<span class="string">'CoordUnit'</span>); |
---|
| 186 | 0129 <span class="keyword">end</span> |
---|
| 187 | 0130 <span class="comment">%transform of X,Y coordinates for vector fields</span> |
---|
| 188 | 0131 <span class="keyword">if</span> isfield(Data,<span class="string">'ZIndex'</span>)&~isempty(Data.ZIndex) |
---|
| 189 | 0132 Z=Data.ZIndex; |
---|
| 190 | 0133 <span class="keyword">else</span> |
---|
| 191 | 0134 Z=0; |
---|
| 192 | 0135 <span class="keyword">end</span> |
---|
| 193 | 0136 <span class="keyword">if</span> isfield(Data,<span class="string">'X'</span>) &isfield(Data,<span class="string">'Y'</span>)&~isempty(Data.X) & ~isempty(Data.Y) |
---|
| 194 | 0137 [DataOut.X,DataOut.Y,DataOut.Z]=<a href="phys_XYZ.html" class="code" title="function [Xphys,Yphys,Zphys]=phys_XYZ(Calib,X,Y,Z)">phys_XYZ</a>(Calib,Data.X,Data.Y,Z); <span class="comment">%transform from pixels to physical</span> |
---|
| 195 | 0138 DataOut.X=DataOut.X-origin_xy(1);<span class="comment">%origin of coordinates at the tank center</span> |
---|
| 196 | 0139 DataOut.Y=DataOut.Y-origin_xy(2);<span class="comment">%origin of coordinates at the tank center</span> |
---|
| 197 | 0140 [theta,DataOut.X] = cart2pol(DataOut.X,DataOut.Y);<span class="comment">%theta and X are the polar coordinates angle and radius</span> |
---|
| 198 | 0141 <span class="comment">%shift and renormalize the polar coordinates</span> |
---|
| 199 | 0142 DataOut.X=DataOut.X-radius_offset;<span class="comment">%</span> |
---|
| 200 | 0143 DataOut.Y=theta*angle_scale-angle_offset;<span class="comment">% normalized angle: distance along reference radius</span> |
---|
| 201 | 0144 <span class="comment">%transform velocity field if exists</span> |
---|
| 202 | 0145 <span class="keyword">if</span> isfield(Data,<span class="string">'U'</span>)&isfield(Data,<span class="string">'V'</span>)&~isempty(Data.U) & ~isempty(Data.V)& isfield(Data,<span class="string">'dt'</span>) |
---|
| 203 | 0146 <span class="keyword">if</span> ~isempty(Data.dt) |
---|
| 204 | 0147 [XOut_1,YOut_1]=<a href="phys_XYZ.html" class="code" title="function [Xphys,Yphys,Zphys]=phys_XYZ(Calib,X,Y,Z)">phys_XYZ</a>(Calib,Data.X-Data.U/2,Data.Y-Data.V/2,Z); |
---|
| 205 | 0148 [XOut_2,YOut_2]=<a href="phys_XYZ.html" class="code" title="function [Xphys,Yphys,Zphys]=phys_XYZ(Calib,X,Y,Z)">phys_XYZ</a>(Calib,Data.X+Data.U/2,Data.Y+Data.V/2,Z); |
---|
| 206 | 0149 UX=(XOut_2-XOut_1)/Data.dt; |
---|
| 207 | 0150 VY=(YOut_2-YOut_1)/Data.dt; |
---|
| 208 | 0151 <span class="comment">%transform u,v into polar coordiantes</span> |
---|
| 209 | 0152 DataOut.U=UX.*cos(theta)+VY.*sin(theta);<span class="comment">%radial velocity</span> |
---|
| 210 | 0153 DataOut.V=(-UX.*sin(theta)+VY.*cos(theta));<span class="comment">%./(DataOut.X)%+radius_ref);%angular velocity calculated</span> |
---|
| 211 | 0154 <span class="comment">%shift and renormalize the angular velocity</span> |
---|
| 212 | 0155 <span class="keyword">end</span> |
---|
| 213 | 0156 <span class="keyword">end</span> |
---|
| 214 | 0157 <span class="keyword">end</span> |
---|
| 215 | 0158 <span class="keyword">end</span> |
---|
| 216 | 0159 |
---|
| 217 | 0160 |
---|
| 218 | 0161 <span class="comment">%%%%%%%%%%%%%%%%%%%%</span> |
---|
| 219 | 0162 <a name="_sub2" href="#_subfunctions" class="code">function [A_out,Rangx,Rangy]=phys_Ima(A,CalibIn,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale)</a> |
---|
| 220 | 0163 xcorner=[]; |
---|
| 221 | 0164 ycorner=[]; |
---|
| 222 | 0165 npx=[]; |
---|
| 223 | 0166 npy=[]; |
---|
| 224 | 0167 |
---|
| 225 | 0168 <span class="keyword">for</span> icell=1:length(A) |
---|
| 226 | 0169 siz=size(A{icell}); |
---|
| 227 | 0170 npx=[npx siz(2)]; |
---|
| 228 | 0171 npy=[npy siz(1)]; |
---|
| 229 | 0172 zphys=0; <span class="comment">%default</span> |
---|
| 230 | 0173 <span class="keyword">if</span> isfield(CalibIn{icell},<span class="string">'SliceCoord'</span>) <span class="comment">%.Z= index of plane</span> |
---|
| 231 | 0174 SliceCoord=CalibIn{icell}.SliceCoord(ZIndex,:); |
---|
| 232 | 0175 zphys=SliceCoord(3); <span class="comment">%to generalize for non-parallel planes</span> |
---|
| 233 | 0176 <span class="keyword">end</span> |
---|
| 234 | 0177 xima=[0.5 siz(2)-0.5 0.5 siz(2)-0.5];<span class="comment">%image coordiantes of corners</span> |
---|
| 235 | 0178 yima=[0.5 0.5 siz(1)-0.5 siz(1)-0.5]; |
---|
| 236 | 0179 [xcorner_new,ycorner_new]=<a href="phys_XYZ.html" class="code" title="function [Xphys,Yphys,Zphys]=phys_XYZ(Calib,X,Y,Z)">phys_XYZ</a>(CalibIn{icell},xima,yima,ZIndex);<span class="comment">%corresponding physical coordinates</span> |
---|
| 237 | 0180 <span class="comment">%transform the corner coordinates into polar ones</span> |
---|
| 238 | 0181 xcorner_new=xcorner_new-origin_xy(1);<span class="comment">%shift to the origin of the polar coordinates</span> |
---|
| 239 | 0182 ycorner_new=ycorner_new-origin_xy(2);<span class="comment">%shift to the origin of the polar coordinates</span> |
---|
| 240 | 0183 [theta,xcorner_new] = cart2pol(xcorner_new,ycorner_new);<span class="comment">%theta and X are the polar coordinates angle and radius</span> |
---|
| 241 | 0184 <span class="keyword">if</span> (max(theta)-min(theta))>pi <span class="comment">%if the polar origin is inside the image</span> |
---|
| 242 | 0185 xcorner_new=[0 max(xcorner_new)]; |
---|
| 243 | 0186 theta=[-pi pi]; |
---|
| 244 | 0187 <span class="keyword">end</span> |
---|
| 245 | 0188 <span class="comment">%shift and renormalize the polar coordinates</span> |
---|
| 246 | 0189 xcorner_new=xcorner_new-radius_offset;<span class="comment">%</span> |
---|
| 247 | 0190 ycorner_new=theta*angle_scale-angle_offset;<span class="comment">% normalized angle: distance along reference radius</span> |
---|
| 248 | 0191 xcorner=[xcorner xcorner_new]; |
---|
| 249 | 0192 ycorner=[ycorner ycorner_new]; |
---|
| 250 | 0193 <span class="keyword">end</span> |
---|
| 251 | 0194 Rangx(1)=min(xcorner); |
---|
| 252 | 0195 Rangx(2)=max(xcorner); |
---|
| 253 | 0196 Rangy(2)=min(ycorner); |
---|
| 254 | 0197 Rangy(1)=max(ycorner); |
---|
| 255 | 0198 <span class="comment">% test_multi=(max(npx)~=min(npx)) | (max(npy)~=min(npy));</span> |
---|
| 256 | 0199 npx=max(npx); |
---|
| 257 | 0200 npy=max(npy); |
---|
| 258 | 0201 x=linspace(Rangx(1),Rangx(2),npx); |
---|
| 259 | 0202 y=linspace(Rangy(1),Rangy(2),npy); |
---|
| 260 | 0203 [X,Y]=meshgrid(x,y);<span class="comment">%grid in physical coordinates</span> |
---|
| 261 | 0204 <span class="comment">%transform X, Y in cartesian</span> |
---|
| 262 | 0205 X=X+radius_offset;<span class="comment">%</span> |
---|
| 263 | 0206 Y=(Y+angle_offset)/angle_scale;<span class="comment">% normalized angle: distance along reference radius</span> |
---|
| 264 | 0207 [X,Y] = pol2cart(Y,X); |
---|
| 265 | 0208 X=X+origin_xy(1);<span class="comment">%shift to the origin of the polar coordinates</span> |
---|
| 266 | 0209 Y=Y+origin_xy(2);<span class="comment">%shift to the origin of the polar coordinates</span> |
---|
| 267 | 0210 <span class="keyword">for</span> icell=1:length(A) |
---|
| 268 | 0211 [XIMA,YIMA]=<a href="px_XYZ.html" class="code" title="function [X,Y]=px_XYZ(Calib,Xphys,Yphys,Zphys)">px_XYZ</a>(CalibIn{icell},X,Y,zphys);<span class="comment">%corresponding image indices for each point in the real space grid</span> |
---|
| 269 | 0212 XIMA=reshape(round(XIMA),1,npx*npy);<span class="comment">%indices reorganized in 'line'</span> |
---|
| 270 | 0213 YIMA=reshape(round(YIMA),1,npx*npy); |
---|
| 271 | 0214 flagin=XIMA>=1 & XIMA<=npx & YIMA >=1 & YIMA<=npy;<span class="comment">%flagin=1 inside the original image</span> |
---|
| 272 | 0215 vec_A=reshape(A{icell}(:,:,1),1,npx*npy);<span class="comment">%put the original image in line</span> |
---|
| 273 | 0216 ind_in=find(flagin); |
---|
| 274 | 0217 ind_out=find(~flagin); |
---|
| 275 | 0218 ICOMB=((XIMA-1)*npy+(npy+1-YIMA)); |
---|
| 276 | 0219 ICOMB=ICOMB(flagin);<span class="comment">%index corresponding to XIMA and YIMA in the aligned original image vec_A</span> |
---|
| 277 | 0220 vec_B(ind_in)=vec_A(ICOMB); |
---|
| 278 | 0221 vec_B(ind_out)=zeros(size(ind_out)); |
---|
| 279 | 0222 A_out{icell}=reshape(vec_B,npy,npx);<span class="comment">%new image in real coordinates</span> |
---|
| 280 | 0223 <span class="keyword">end</span> |
---|
| 281 | 0224 <span class="comment">%Rangx=Rangx-radius_offset;</span> |
---|
| 282 | 0225 |
---|
| 283 | 0226</pre></div> |
---|
| 284 | <hr><address>Generated on Fri 13-Nov-2009 11:17:03 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address> |
---|
| 285 | </body> |
---|
| 286 | </html> |
---|