%'RUN_STLIN': combine velocity fields for stereo PIV % file_A,file_B: input velocity files %vel_type: string ='civ1' or 'civ2' function RUN_STLIN(file_A,file_B,vel_type,file_st,nx_patch,ny_patch,thresh_patch,fileAxml,fileBxml) [XmlDataA,error]=imadoc2struct(fileAxml);%read xml file associated to image series A [XmlDataB,error]=imadoc2struct(fileBxml);%read xml file associated to image series B npxA=[]; npyA=[]; pxB=[]; npyB=[]; if isfield(XmlDataA,'Camera') && isfield(XmlDataB,'Camera') if isfield(XmlDataA.Camera,'ImageSize')&& isfield(XmlDataB.Camera,'ImageSize') ImageSizeA=XmlDataA.Camera.ImageSize; ImageSizeB=XmlDataB.Camera.ImageSize; if ~isempty(ImageSizeA)&& ~isempty(ImageSizeB) xindex=findstr(ImageSizeA,'x'); if length(xindex)>=2 npxA=str2num(ImageSizeA(1:xindex(1)-1)); npyA=str2num(ImageSizeA(xindex(1)+1:xindex(2)-1)); end xindex=findstr(ImageSizeB,'x'); if length(xindex)>=2 npxB=str2num(ImageSizeB(1:xindex(1)-1)); npyB=str2num(ImageSizeB(xindex(1)+1:xindex(2)-1)); end end end end %%%%%%%% added for Duran if isfield(XmlDataA,'Npx')&&isfield(XmlDataA,'Npy')&&isfield(XmlDataB,'Npx')&&isfield(XmlDataB,'Npy') npxA=XmlDataA.Npx; npyA=XmlDataA.Npy; npxB=XmlDataB.Npx; npyB=XmlDataB.Npy; end %%%%%%%% added for Duran if isempty(npxA) ||isempty(npxB) msgbox_uvmat('ERROR','The size of image A needs to be defined in the xml file ImaDoc') return elseif isempty(npxB) || isempty(npyB) msgbox_uvmat('ERROR','The size of image B needs to be defined in the xml file ImaDoc') return end if isfield(XmlDataA,'GeometryCalib') tsaiA=XmlDataA.GeometryCalib; else msgbox_uvmat('ERROR','no geometric calibration available for image A') return end if isfield(XmlDataB,'GeometryCalib') tsaiB=XmlDataB.GeometryCalib; else msgbox_uvmat('ERROR','no geometric calibration available for image B') return end %corners of each image in px coordinates: cornerA(:,1)=[0 0 npxA npxA]';%x positions cornerA(:,2)=[0 npyA 0 npyA]';%y positions cornerB(:,1)=[0 0 npxB npxB]';%x positions cornerB(:,2)=[0 npyB 0 npyB]';%y positions %corners of each image in phys coordinates: [xyA(:,1),xyA(:,2)]=phys_XYZ(tsaiA,cornerA(:,1),cornerA(:,2)); [xyB(:,1),xyB(:,2)]=phys_XYZ(tsaiB,cornerB(:,1),cornerB(:,2)); max_x=max(max(xyA(:,1)),max(xyB(:,1)));%maximum on the 4 corners of the the images min_x=min(min(xyA(:,1)),min(xyB(:,1)));%minimum on the 4 corners of the the images max_y=max(max(xyA(:,2)),max(xyB(:,2))); min_y=min(min(xyA(:,2)),min(xyB(:,2))); array_realx=[min_x:(max_x-min_x)/(nx_patch-1):max_x]; array_realy=[min_y:(max_y-min_y)/(ny_patch-1):max_y]; [grid_realx,grid_realy]=meshgrid(array_realx,array_realy); grid_real(:,1)=reshape(grid_realx,nx_patch*ny_patch,1); grid_real(:,2)=reshape(grid_realy,nx_patch*ny_patch,1); grid_real(:,3)=zeros(nx_patch*ny_patch,1); [grid_imaA(:,1),grid_imaA(:,2)]=px_XYZ(tsaiA,grid_real(:,1),grid_real(:,2)); [grid_imaB(:,1),grid_imaB(:,2)]=px_XYZ(tsaiB,grid_real(:,1),grid_real(:,2)); flagA=grid_imaA(:,1)>0 & grid_imaA(:,1)0 & grid_imaA(:,2)0 & grid_imaB(:,1)0 & grid_imaB(:,2)