Changeset 542
- Timestamp:
- Sep 15, 2012, 7:04:56 PM (12 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/geometry_calib.m
r541 r542 861 861 %------------------------------------------------------------------------ 862 862 huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle 863 hplot=findobj(huvmat,'Tag',' axes3');%main plotting axis of uvmat863 hplot=findobj(huvmat,'Tag','PlotAxes');%main plotting axis of uvmat 864 864 hhh=findobj(hplot,'Tag','calib_marker'); 865 865 Coord_cell=get(handles.ListCoord,'String'); … … 876 876 return 877 877 end 878 %fill the edit boxe x878 %fill the edit boxe 879 879 set(handles.XObject,'String',coord_str(1:k(1)-1)) 880 880 set(handles.YObject,'String',coord_str(k(1)+3:k(2)-1)) -
trunk/src/mouse_motion.m
r537 r542 104 104 text_displ_3=''; 105 105 text_displ_4=''; 106 text_displ_5=''; 106 107 ivec=[]; 107 108 xName=''; … … 140 141 elseif (isfield(CellInfo{icell},'VarIndex_vector_x') && isequal(ivar,CellInfo{icell}.VarIndex_vector_x))||isequal(ivar,CellInfo{icell}.VarIndex_vector_y)||... 141 142 (isfield(CellInfo{icell},'VarIndex_vector_z') && isequal(ivar,CellInfo{icell}.VarIndex_vector_z)) 142 text_displ_ 3=[text_displ_3var_text];143 text_displ_4=[text_displ_4 var_text]; 143 144 else 144 text_displ_ 4=[text_displ_4var_text];145 text_displ_5=[text_displ_5 var_text]; 145 146 end 146 147 end … … 168 169 VarVal=Field.(VarName)(indy0,indx0,:); 169 170 var_text=[VarName '=' num2str(VarVal) ',']; 170 text_displ_ 2=[text_displ_2var_text];171 text_displ_4=[text_displ_4 var_text]; 171 172 end 172 173 end … … 175 176 end 176 177 end 177 % display the current x,y coordinates in the absence of detected vector178 % display the current x,y plot coordinates in the absence of detected vector 178 179 if isempty(ivec) 179 180 if isempty(xName) … … 183 184 text_displ_1=[xName '=' num2str(xy(1,1),4) ', ' yName '=' num2str(xy(1,2),4) ',']; 184 185 end 185 %display the z coordinate if defined by the projection plane 186 if isfield(Field,'PlaneCoord') 187 % ZIndex=Field.ZIndex; 188 if size(Field.PlaneCoord)>=[1 3] 189 z=Field.PlaneCoord(1,3); 190 if isfield(Field,'PlaneAngle')&&~isequal(Field.PlaneAngle,[0 0 0]) 191 om=norm(Field.PlaneAngle);%norm of rotation angle in radians 192 OmAxis=Field.PlaneAngle/om; %unit vector marking the rotation axis 193 cos_om=cos(pi*om/180); 194 sin_om=sin(pi*om/180); 195 coeff=OmAxis(3)*(1-cos_om); 196 norm_plane(1)=OmAxis(1)*coeff+OmAxis(2)*sin_om; 197 norm_plane(2)=OmAxis(2)*coeff-OmAxis(1)*sin_om; 198 norm_plane(3)=OmAxis(3)*coeff+cos_om; 199 Z0=norm_plane*Field.PlaneCoord'/norm_plane(3); 200 z=Z0-norm_plane(1)*xy(1,1)/norm_plane(3)-norm_plane(2)*xy(1,2)/norm_plane(3); 201 end 186 %display the z coordinate if defined by the projection plane 187 if isfield(Field,'ObjectCoord') && length(Field.ObjectCoord)>=3 188 pos=[xy(1,1) xy(1,2) 0]; 189 if isfield(Field,'ObjectAngle')&&~isequal(Field.ObjectAngle,[0 0 0]) 190 om=norm(Field.ObjectAngle);%norm of rotation angle in radians 191 OmAxis=Field.ObjectAngle/om; %unit vector marking the rotation axis 192 cos_om=cos(pi*om/180); 193 sin_om=sin(pi*om/180); 194 pos=[xy(1,1) xy(1,2) 0]; 195 pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis; 202 196 end 197 pos=pos+Field.ObjectCoord; 198 text_displ_3=[text_displ_3 'x,y,z=' num2str(pos,4)]; 203 199 end 204 if ~isempty(z)205 text_displ_1=[text_displ_1 ' z=' num2str(z,4)];206 end200 % if ~isempty(z) 201 % text_displ_1=[text_displ_1 ' z=' num2str(z,4)]; 202 % end 207 203 % case of PIV correlation display 208 204 if test_piv … … 242 238 [Data,errormsg,result_conv]= civ_matlab(Param); 243 239 if ~isempty(errormsg) 244 text_displ_ 4=errormsg;240 text_displ_5=errormsg; 245 241 else 246 242 rangx(1)=-(isx2-ibx2)+shiftx; … … 281 277 end 282 278 if ~isempty(text_displ_1) 283 set(handles.text_display,'String',[{text_displ_1};{text_displ_2};{text_displ_3};{text_displ_4}]) 279 text_displ=[{text_displ_1};{text_displ_2};{text_displ_3};{text_displ_4};{text_displ_5}]; 280 ind_blank=find(strcmp('',text_displ)); 281 if ~isempty(ind_blank) 282 text_displ(ind_blank)=[]; 283 end 284 set(handles.text_display,'String',text_displ) 284 285 else 285 286 set(handles.text_display,'String',get(handles.text_display,'UserData')) -
trunk/src/proj_field.m
r537 r542 94 94 if ~isfield(ObjectData,'Coord')||isempty(ObjectData.Coord) 95 95 if strcmp(ObjectData.Type,'plane') 96 ObjectData.Coord=[0 0 0];%default96 ObjectData.Coord=[0 0];%default 97 97 else 98 98 return … … 948 948 %% initiate Matlab structure for physical field 949 949 [ProjData,errormsg]=proj_heading(FieldData,ObjectData); 950 951 %% reproduce initial plane position and angle 952 if isfield(FieldData,'PlaneCoord')&&length(FieldData.PlaneCoord)==3 953 if length(ProjData.ObjectCoord)==3% if the projection plane has a z coordinate 954 if ~isequal(ProjData.PlaneCoord(3),ProjData.ObjectCoord) %check the consistency with the z coordinate of the field plane (set by calibration) 955 errormsg='inconsistent z position for field and projection plane'; 956 return 957 end 958 else % the z coordinate is set only by the field plane (by calibration) 959 ProjData.ObjectCoord(3)=FieldData.PlaneCoord(3); 960 end 961 if isfield(FieldData,'PlaneAngle') 962 if isfield(ProjData,'ObjectAngle') 963 if ~isequal(FieldData.PlaneAngle,ProjData.ObjectAngle) %check the consistency with the z coordinate of the field plane (set by calibration) 964 errormsg='inconsistent plane angle for field and projection plane'; 965 return 966 end 967 else 968 ProjData.ObjectAngle=FieldData.PlaneAngle; 969 end 970 end 971 end 950 972 ProjData.NbDim=2; 951 973 ProjData.ListVarName={}; … … 2206 2228 AttrName=ProjData.ListGlobalAttribute{iattr}; 2207 2229 if isfield(FieldData,AttrName) 2208 eval(['ProjData.' AttrName '=FieldData.' AttrName ';']);2230 ProjData.(AttrName)=FieldData.(AttrName); 2209 2231 end 2210 2232 end … … 2224 2246 for ilist=1:length(ListObject) 2225 2247 if isfield(ObjectData,ListObject{ilist}) 2226 eval(['val=ObjectData.' ListObject{ilist} ';'])2248 val=ObjectData.(ListObject{ilist}); 2227 2249 if ~isempty(val) 2228 eval(['ProjData.Object' ListObject{ilist} '=val;']);2250 ProjData.(['Object' ListObject{ilist}])=val; 2229 2251 ProjData.ListGlobalAttribute=[ProjData.ListGlobalAttribute {['Object' ListObject{ilist}]}]; 2230 2252 end 2231 2253 end 2232 2254 end 2255 -
trunk/src/px_XYZ.m
r114 r542 11 11 12 12 function [X,Y]=px_XYZ(Calib,Xphys,Yphys,Zphys) 13 % if exist('Z','var')& isequal(Z,round(Z))& Z>0 & isfield(Calib,'PlanePos')&length(Calib.PlanePos)>=Z14 % Zindex=Z;15 % planepos=Calib.PlanePos{Zindex};16 % zphys=planepos(3);%A GENERALISER CAS AVEC ANGLE17 % else18 % zphys=0;19 % end20 13 if ~exist('Zphys','var') 21 14 Zphys=0; … … 27 20 Calib.Tx_Ty_Tz=[0 0 1]; 28 21 end 29 % if ~isfield(Calib,'kappa1')30 % Calib.kappa1=0;31 % end32 % if ~isfield(Calib,'sx')33 % Calib.sx=1;34 % end35 % if ~isfield(Calib,'dpx')36 % Calib.dpx=1;37 % end38 % if ~isfield(Calib,'dpy')39 % Calib.dpy=1;40 % end41 22 42 23 %%%%%%%%%%%%% 24 % general case 43 25 if isfield(Calib,'R') 44 26 R=(Calib.R)'; 27 %correct z for refraction if needed 28 if isfield(Calib,'InterfaceCoord') && isfield(Calib,'RefractionIndex') 29 H=Calib.InterfaceCoord(3); 30 if H>Zphys 31 Zphys=H-(H-Zphys)/Calib.RefractionIndex; %corrected z (virtual object) 32 test_refraction=1; 33 end 34 end 35 45 36 %camera coordinates 46 37 xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx_Ty_Tz(1); 47 38 yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Tx_Ty_Tz(2); 48 39 zc=R(7)*Xphys+R(8)*Yphys+R(9)*Zphys+Calib.Tx_Ty_Tz(3); 49 %undistorted image coordinates 40 41 %undistorted image coordinates 50 42 Xu=xc./zc; 51 43 Yu=yc./zc; 52 %radial quadratic correction factor 44 45 %radial quadratic correction factor 53 46 if ~isfield(Calib,'kc') 54 47 r2=1; %no quadratic distortion … … 56 49 r2=1+Calib.kc*(Xu.*Xu+Yu.*Yu); 57 50 end 58 %pixel coordinates 51 52 %pixel coordinates 59 53 if ~isfield(Calib,'Cx_Cy') 60 54 Calib.Cx_Cy=[0 0];%default value 61 55 end 62 56 X=Calib.fx_fy(1)*Xu.*r2+Calib.Cx_Cy(1); 63 Y=Calib.fx_fy(2)*Yu.*r2+Calib.Cx_Cy(2); 64 %OLD CONVENTION (Wilson)undistorted image coordinates 65 % Xu=Calib.f*xc./zc; 66 % Yu=Calib.f*yc./zc; 67 % %distorted image coordinates 68 % distortion=(Calib.kappa1)*(Xu.*Xu+Yu.*Yu)+1; %A REVOIR 69 % % distortion=1; 70 % Xd=Xu./distortion; 71 % Yd=Yu./distortion; 72 % %pixel coordinates 73 % X=Xd*Calib.sx/Calib.dpx+Calib.Cx; 74 % Y=Yd/Calib.dpy+Calib.Cy; 75 else %case 'rescale' 57 Y=Calib.fx_fy(2)*Yu.*r2+Calib.Cx_Cy(2); 58 59 %case 'rescale' 60 else 76 61 X=Calib.fx_fy(1)*(Xphys+Calib.Tx_Ty_Tz(1)); 77 62 Y=Calib.fx_fy(2)*(Yphys+Calib.Tx_Ty_Tz(2)); -
trunk/src/uvmat.m
r541 r542 1332 1332 else 1333 1333 %read mask image 1334 Mask.AName='image'; 1335 Mask.A=imread(MaskName); 1334 [Mask,tild,errormsg] = read_field(MaskName,'image'); 1335 % Mask.AName='image'; 1336 % Mask.A=imread(MaskName); 1337 if ~isempty(errormsg) 1338 return 1339 end 1336 1340 npxy=size(Mask.A); 1337 test_error=0;1338 1341 if length(npxy)>2 1339 1342 errormsg=[MaskName ' is not a grey scale image']; … … 1343 1346 return 1344 1347 end 1345 Mask.AX=[0.5 npxy(2)-0.5];1346 Mask.AY=[npxy(1)-0.5 0.5 ];1347 Mask.CoordUnit='pixel';1348 % Mask.AX=[0.5 npxy(2)-0.5]; 1349 % Mask.AY=[npxy(1)-0.5 0.5 ]; 1350 % Mask.CoordUnit='pixel'; 1348 1351 if isequal(get(handles.slices,'Value'),1) 1349 1352 NbSlice=str2num(get(handles.num_NbSlice,'String')); … … 4609 4612 return 4610 4613 else 4611 % set(handles.ListObject,'Max',2);%allow multiple selection4612 4614 set(handles.ListObject,'Value',val); 4613 4615 flag=1; … … 4634 4636 Y=ObjectData.Coord(:,2); 4635 4637 if testphys 4636 [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases 4638 pos=[X Y zeros(size(X))]; 4639 if isfield(Calib,'SliceCoord') && length(Calib.SliceCoord)>=3 4640 if isfield(Calib,'SliceAngle')&&~isequal(Calib.SliceAngle,[0 0 0]) 4641 om=norm(Calib.SliceAngle);%norm of rotation angle in radians 4642 OmAxis=Calib.SliceAngle/om; %unit vector marking the rotation axis 4643 cos_om=cos(pi*om/180); 4644 sin_om=sin(pi*om/180); 4645 pos=cos_om*pos+sin_om*cross(OmAxis,pos)+(1-cos_om)*(OmAxis*pos')*OmAxis; 4646 end 4647 pos(:,1)=pos(:,1)+Calib.SliceCoord(1); 4648 pos(:,2)=pos(:,2)+Calib.SliceCoord(2); 4649 pos(:,3)=pos(:,3)+Calib.SliceCoord(3); 4650 end 4651 [X,Y]=px_XYZ(Calib,pos(:,1),pos(:,2),pos(:,3)); 4637 4652 end 4638 4653 flagobj=~inpolygon(Xi,Yi,X',Y');%=0 inside the polygon, 1 outside … … 4671 4686 RootFile(1)=[]; 4672 4687 end 4673 % filebase=fullfile(RootPath,RootFile);4674 4688 list=get(handles.masklevel,'String'); 4675 4689 masknumber=num2str(length(list));
Note: See TracChangeset
for help on using the changeset viewer.