Changeset 164 for trunk/src/transform_field/phys_polar.m
 Timestamp:
 Jan 3, 2011, 8:15:05 PM (13 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/transform_field/phys_polar.m
r161 r164 93 93 end 94 94 if iscalar==1% case for which only the second field is a scalar 95 [A,AX,AY]=phys_Ima (A,Calib,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale);95 [A,AX,AY]=phys_Ima_polar(A,Calib,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale); 96 96 DataOut_1.A=A{1}; 97 97 DataOut_1.AX=AX; … … 102 102 end 103 103 if iscalar~=0 104 [A,AX,AY]=phys_Ima (A,Calib,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale);%104 [A,AX,AY]=phys_Ima_polar(A,Calib,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale);% 105 105 DataOut.A=A{1}; 106 106 DataOut.AX=AX; … … 184 184 end 185 185 186 186 187 % 187 188 %'phys_XYZ':transforms image (px) to real world (phys) coordinates using geometric calibration parameters … … 247 248 Yu=Yd./dist_fact; 248 249 denom=Dx*Xu+Dy*Yu+D0; 249 % denom2=denom.*denom;250 250 Xphys=(A11.*Xu+A12.*Yu+X0)./denom;%world coordinates 251 251 Yphys=(A21.*Xu+A22.*Yu+Y0)./denom; 252 % Xd=(XCalib.Cx_Cy(1))/Calib.fx_fy(1); % sensor coordinates253 % Yd=(YCalib.Cx_Cy(2))/Calib.fx_fy(2);254 % dist_fact=1+Calib.kc*(Xd.*Xd+Yd.*Yd); %distortion factor255 % Xu=Xd./dist_fact;%undistorted sensor coordinates256 % Yu=Yd./dist_fact;257 % A11=R(7)*XuR(1);258 % A12=R(8)*XuR(2);259 % A21=R(7)*YuR(4);260 % A22=R(8)*YuR(5);261 % B1=(R(3)R(9)*Xu)*ZphysTz*Xu+Tx;262 % B2=(R(6)R(9)*Yu)*ZphysTz*Yu+Ty;263 % deter=A12.*A21A11.*A22;264 % Xphys=(A21.*B1A11.*B2)./deter;265 % Yphys=(A22.*B1+A12.*B2)./deter;266 252 else 267 253 Xphys=Calib.Tx_Ty_Tz(1)+X/Calib.fx_fy(1); 268 254 Yphys=Calib.Tx_Ty_Tz(2)+Y/Calib.fx_fy(2); 269 255 end 256 270 257 %%%%%%%%%%%%%%%%%%%% 271 function [A_out,Rangx,Rangy]=phys_Ima (A,CalibIn,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale)258 function [A_out,Rangx,Rangy]=phys_Ima_polar(A,CalibIn,ZIndex,origin_xy,radius_offset,angle_offset,angle_scale) 272 259 xcorner=[]; 273 260 ycorner=[]; 274 261 npx=[]; 275 262 npy=[]; 276 277 263 for icell=1:length(A) 278 264 siz=size(A{icell}); … … 318 304 Y=Y+origin_xy(2);%shift to the origin of the polar coordinates 319 305 for icell=1:length(A) 306 siz=size(A{icell}); 320 307 [XIMA,YIMA]=px_XYZ(CalibIn{icell},X,Y,zphys);%corresponding image indices for each point in the real space grid 321 308 XIMA=reshape(round(XIMA),1,npx*npy);%indices reorganized in 'line' 322 309 YIMA=reshape(round(YIMA),1,npx*npy); 323 310 flagin=XIMA>=1 & XIMA<=npx & YIMA >=1 & YIMA<=npy;%flagin=1 inside the original image 324 vec_A=reshape(A{icell}(:,:,1),1,npx*npy);%put the original image in line 325 ind_in=find(flagin); 326 ind_out=find(~flagin); 327 ICOMB=((XIMA1)*npy+(npy+1YIMA)); 328 ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A 329 vec_B(ind_in)=vec_A(ICOMB); 330 vec_B(ind_out)=zeros(size(ind_out)); 331 A_out{icell}=reshape(vec_B,npy,npx);%new image in real coordinates 332 end 333 %Rangx=Rangxradius_offset; 334 335 336 337 % 338 % function [X,Y]=px_XYZ(Calib,Xphys,Yphys,Zphys) 339 % X=[];%default 340 % Y=[]; 341 % % if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'PlanePos')&length(Calib.PlanePos)>=Z 342 % % Zindex=Z; 343 % % planepos=Calib.PlanePos{Zindex}; 344 % % zphys=planepos(3);%A GENERALISER CAS AVEC ANGLE 345 % % else 346 % % zphys=0; 347 % % end 348 % if ~exist('Zphys','var') 349 % Zphys=0; 350 % end 351 % 352 % %%%%%%%%%%%%% 353 % if isfield(Calib,'R') 354 % R=(Calib.R)'; 355 % xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx; 356 % yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Ty; 357 % zc=R(7)*Xphys+R(8)*Yphys+R(9)*Zphys+Calib.Tz; 358 % %undistorted image coordinates 359 % Xu=Calib.f*xc./zc; 360 % Yu=Calib.f*yc./zc; 361 % %distorted image coordinates 362 % distortion=(Calib.kappa1)*(Xu.*Xu+Yu.*Yu)+1; %A REVOIR 363 % % distortion=1; 364 % Xd=Xu./distortion; 365 % Yd=Yu./distortion; 366 % %pixel coordinates 367 % X=Xd*Calib.sx/Calib.dpx+Calib.Cx; 368 % Y=Yd/Calib.dpy+Calib.Cy; 369 % 370 % elseif isfield(Calib,'Pxcmx')&isfield(Calib,'Pxcmy')%old calib 371 % X=Xphys*Calib.Pxcmx; 372 % Y=Yphys*Calib.Pxcmy; 373 % end 374 % 375 311 if numel(siz)==2 %(B/W images) 312 vec_A=reshape(A{icell}(:,:,1),1,npx*npy);%put the original image in line 313 ind_in=find(flagin); 314 ind_out=find(~flagin); 315 ICOMB=((XIMA1)*npy+(npy+1YIMA)); 316 ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A 317 vec_B(ind_in)=vec_A(ICOMB); 318 vec_B(ind_out)=zeros(size(ind_out)); 319 A_out{icell}=reshape(vec_B,npy,npx);%new image in real coordinates 320 else 321 for icolor=1:siz(3) 322 vec_A=reshape(A{icell}(:,:,icolor),1,npx*npy);%put the original image in line 323 ind_in=find(flagin); 324 ind_out=find(~flagin); 325 ICOMB=((XIMA1)*npy+(npy+1YIMA)); 326 ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A 327 vec_B(ind_in)=vec_A(ICOMB); 328 vec_B(ind_out)=zeros(size(ind_out)); 329 A_out{icell}(:,:,icolor)=reshape(vec_B,npy,npx);%new image in real coordinates 330 end 331 end 332 end 333
Note: See TracChangeset
for help on using the changeset viewer.