Changeset 695
 Timestamp:
 Nov 4, 2013, 9:34:47 PM (10 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/transform_field/phys.m
r631 r695 226 226 npx=[]; 227 227 npy=[]; 228 dx=ones(1, length(A));229 dy=ones(1, length(A));230 for icell=1: length(A)228 dx=ones(1,numel(A)); 229 dy=ones(1,numel(A)); 230 for icell=1:numel(A) 231 231 siz=size(A{icell}); 232 232 npx=[npx siz(2)]; … … 251 251 y=linspace(Rangy(1),Rangy(2),npY); 252 252 [X,Y]=meshgrid(x,y);%grid in physical coordiantes 253 vec_B=[];254 A_out= {};253 %vec_B=[]; 254 A_out=cell(1,numel(A)); 255 255 for icell=1:length(A) 256 256 Calib=CalibIn{icell}; … … 275 275 end 276 276 end 277 [XIMA,YIMA]=px_XYZ(CalibIn{icell},X,Y,zphys);% image coordinates for each point in the real space grid 278 XIMA=reshape(round(XIMA),1,npX*npY);%indices reorganized in 'line' 279 YIMA=reshape(round(YIMA),1,npX*npY); 280 flagin=XIMA>=1 & XIMA<=npx(icell) & YIMA >=1 & YIMA<=npy(icell);%flagin=1 inside the original image 281 testuint8=isa(A{icell},'uint8'); 282 testuint16=isa(A{icell},'uint16'); 283 if numel(siz)==2 %(B/W images) 284 vec_A=reshape(A{icell},1,npx(icell)*npy(icell));%put the original image in line 285 %ind_in=find(flagin); 286 ind_out=find(~flagin); 287 ICOMB=((XIMA1)*npy(icell)+(npy(icell)+1YIMA)); 288 ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A 289 %vec_B(ind_in)=vec_A(ICOMB); 290 vec_B(flagin)=vec_A(ICOMB); 291 vec_B(~flagin)=zeros(size(ind_out)); 292 % vec_B(ind_out)=zeros(size(ind_out)); 293 A_out{icell}=reshape(vec_B,npY,npX);%new image in real coordinates 294 elseif numel(siz)==3 295 for icolor=1:siz(3) 296 vec_A=reshape(A{icell}(:,:,icolor),1,npx*npy);%put the original image in line 297 % ind_in=find(flagin); 298 ind_out=find(~flagin); 299 ICOMB=((XIMA1)*npy+(npy+1YIMA)); 300 ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A 301 vec_B(flagin)=vec_A(ICOMB); 302 vec_B(~flagin)=zeros(size(ind_out)); 303 A_out{icell}(:,:,icolor)=reshape(vec_B,npy,npx);%new image in real coordinates 304 end 305 end 277 xima=[0.5:npx0.5];%image coordiantes of corners 278 yima=npy0.5:1:0.5; 279 [XIMA_init,YIMA_init]=meshgrid(xima,yima);%grid of initial image in px coordiantes 280 [XIMA,YIMA]=px_XYZ(CalibIn{icell},X,Y,zphys);% image coordinates for each point in the real 281 %[XPHYS_init,YPHYS_init]=phys_XYZ(Calib,XIMA_init,YIMA_init,ZIndex); 282 testuint8=isa(A{icell},'uint8'); 283 testuint16=isa(A{icell},'uint16'); 284 if ndims(A{icell})==2 %(B/W images) 285 A_out{icell}=interp2(XIMA_init,YIMA_init,double(A{icell}),XIMA,YIMA); 286 % [Rangx]=phys_XYZ(Calib,Rangx,[0.5 0.5],ZIndex);%case of translations without rotation and quadratic deformation 287 % [XIMA_init,YIMA_init]=px_XYZ(CalibIn{icell},X,Y,zphys);% image coordinates for each point in the real space grid 288 % 289 % XIMA=reshape(round(XIMA),1,npX*npY);%indices reorganized in 'line' 290 % YIMA=reshape(round(YIMA),1,npX*npY); 291 % flagin=XIMA>=1 & XIMA<=npx(icell) & YIMA >=1 & YIMA<=npy(icell);%flagin=1 inside the original image 292 293 % if numel(siz)==2 %(B/W images) 294 % vec_A=reshape(A{icell},1,npx(icell)*npy(icell));%put the original image in line 295 % %ind_in=find(flagin); 296 % ind_out=find(~flagin); 297 % ICOMB=((XIMA1)*npy(icell)+(npy(icell)+1YIMA)); 298 % ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A 299 % %vec_B(ind_in)=vec_A(ICOMB); 300 % vec_B(flagin)=vec_A(ICOMB); 301 % vec_B(~flagin)=zeros(size(ind_out)); 302 % % vec_B(ind_out)=zeros(size(ind_out)); 303 % A_out{icell}=reshape(vec_B,npY,npX);%new image in real coordinates 304 elseif ndims(A{icell})==3 305 for icolor=1:size(A{icell},3) 306 A{icell}=double(A{icell}); 307 A_out{icell}(:,:,icolor)=interp2(XIMA_init,YIMA_init,A{icell}(:,:,icolor),XIMA,YIMA); 308 % vec_A=reshape(A{icell}(:,:,icolor),1,npx*npy);%put the original image in line 309 % % ind_in=find(flagin); 310 % ind_out=find(~flagin); 311 % ICOMB=((XIMA1)*npy+(npy+1YIMA)); 312 % ICOMB=ICOMB(flagin);%index corresponding to XIMA and YIMA in the aligned original image vec_A 313 % vec_B(flagin)=vec_A(ICOMB); 314 % vec_B(~flagin)=zeros(size(ind_out)); 315 % A_out{icell}(:,:,icolor)=reshape(vec_B,npy,npx);%new image in real coordinates 316 end 317 end 306 318 if testuint8 307 319 A_out{icell}=uint8(A_out{icell});
Note: See TracChangeset
for help on using the changeset viewer.