Changeset 1195 for trunk/src/civ.m
- Timestamp:
- Feb 26, 2026, 4:16:03 PM (5 days ago)
- File:
-
- 1 edited
-
trunk/src/civ.m (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r1179 r1195 4 4 % 5 5 % OUTPUT: 6 % xtable: set of x coordinates7 % ytable: set of y coordinates 8 % utable: set of u displacements (along x) 6 % xtable: set of x positions of the first image in integer image coordinates , the measurement position is xtable-0.5+utable/2 7 % ytable: set of y coordinates of the first image in integer image coordinates (starting in the image bottom, image index= npy-ytable+1 , the measurement position is ytable-0.5+vtable/2 8 % utable: set of u displacements (along x), in pixels 9 9 % vtable: set of v displacements (along y) 10 10 % ctable: max image correlation for each vector … … 44 44 %% prepare measurement grid if not given as input 45 45 if ~isfield(par_civ,'Grid')% grid points defining central positions of the sub-images in image A 46 nbinterv_x=floor((npx_ima-1)/par_civ.Dx); 46 nbinterv_x=floor((npx_ima-1)/par_civ.Dx);%expected number of intervals Dx 47 47 gridlength_x=nbinterv_x*par_civ.Dx; 48 48 minix=ceil((npx_ima-gridlength_x)/2); 49 nbinterv_y=floor((npy_ima-1)/par_civ.Dy); 49 nbinterv_y=floor((npy_ima-1)/par_civ.Dy);%expected number of intervals Dy 50 50 gridlength_y=nbinterv_y*par_civ.Dy; 51 51 miniy=ceil((npy_ima-gridlength_y)/2); 52 [GridX,GridY]=meshgrid(minix :par_civ.Dx:npx_ima-1,miniy:par_civ.Dy:npy_ima-1);52 [GridX,GridY]=meshgrid(minix+0.5:par_civ.Dx:npx_ima-0.5,miniy+0.5:par_civ.Dy:npy_ima-0.5);% grid of initial positions in pixel coordinates (y upward) 53 53 par_civ.Grid(:,1)=reshape(GridX,[],1); 54 54 par_civ.Grid(:,2)=reshape(GridY,[],1);% increases with array index … … 66 66 67 67 shiftx=par_civ.SearchBoxShift(:,1);%use the input shift estimate, rounded to the next integer value 68 shifty= -par_civ.SearchBoxShift(:,2);% sign minus because image j index increases when y decreases68 shifty=par_civ.SearchBoxShift(:,2);% 69 69 if numel(shiftx)==1% case of a unique shift for the whole field( civ1) 70 70 shiftx=shiftx*ones(nbvec,1); … … 73 73 74 74 %% shift the grid by half the expected displacement to get the velocity closer to the initial grid 75 par_civ.Grid(:,1)=par_civ.Grid(:,1)-shiftx/2; 76 par_civ.Grid(:,2)=par_civ.Grid(:,2) +shifty/2;75 par_civ.Grid(:,1)=par_civ.Grid(:,1)-shiftx/2;% initial positions in image coordinates (y upward) 76 par_civ.Grid(:,2)=par_civ.Grid(:,2)-shifty/2; 77 77 78 78 %% Array initialisation and default output if par_civ.CorrSmooth=0 (just the grid calculated, no civ computation) 79 xtable=round(par_civ.Grid(:,1)+0.5) -0.5;80 ytable=round(npy_ima-par_civ.Grid(:,2)+0.5) -0.5;% y indexcorresponding to the position in image coordinates79 xtable=round(par_civ.Grid(:,1)+0.5);% tables of image indices corresponding to the input grid 80 ytable=round(npy_ima-par_civ.Grid(:,2)+0.5);% y image indices corresponding to the position in image coordinates 81 81 shiftx=round(shiftx); 82 82 shifty=round(shifty); 83 utable=shiftx;%zeros(nbvec,1); 84 vtable= shifty;%zeros(nbvec,1);83 utable=shiftx;%zeros(nbvec,1);% expected displacements in pixel indices (y downward) 84 vtable=-shifty;%zeros(nbvec,1); 85 85 ctable=zeros(nbvec,1); 86 86 FF=zeros(nbvec,1); … … 128 128 if par_civ.CorrSmooth~=0 % par_civ.CorrSmooth=0 implies no civ computation (just input image and grid points given) 129 129 for ivec=1:nbvec 130 iref=round(par_civ.Grid(ivec,1)+0.5);% xindex on the image A for the middle of the correlation box 131 jref=round(npy_ima-par_civ.Grid(ivec,2)+0.5);% j index for the middle of the correlation box in the image A 130 % iref=round(par_civ.Grid(ivec,1));% xindex on the image A for the middle of the correlation box 131 % jref=round(npy_ima-par_civ.Grid(ivec,2));% j index for the middle of the correlation box in the image A 132 iref=xtable(ivec);% xindex on the image A for the middle of the correlation box 133 jref=ytable(ivec);% j index for the middle of the correlation box in the image A 134 132 135 FF(ivec)=0; 133 136 ibx2=floor(CorrBoxSizeX(ivec)/2); … … 138 141 subrange1_y=jref-iby2:jref+iby2;% y indices defining the first subimage 139 142 subrange2_x=iref+shiftx(ivec)-isx2:iref+shiftx(ivec)+isx2;%x indices defining the second subimage 140 subrange2_y=jref +shifty(ivec)-isy2:jref+shifty(ivec)+isy2;%y indices defining the second subimage143 subrange2_y=jref-shifty(ivec)-isy2:jref-shifty(ivec)+isy2;%y indices defining the second subimage 141 144 image1_crop=MinA*ones(numel(subrange1_y),numel(subrange1_x));% default value=min of image A 142 145 image2_crop=MinA*ones(numel(subrange2_y),numel(subrange2_x));% default value=min of image A … … 224 227 end 225 228 utable(ivec)=vector(1)*mesh+shiftx(ivec); 226 vtable(ivec)=- (vector(2)*mesh+shifty(ivec));227 xtable(ivec)=iref+utable(ivec)/2-0.5;% convec flow (velocity taken at the point middle from imgae 1 and 2)228 ytable(ivec)=jref+vtable(ivec)/2-0.5;% and position of pixel 1=0.5 (convention for image coordinates=0 at the edge)229 iref=round(xtable(ivec)+0.5);% nearest image index for the middle of the vector230 jref=round(ytable(ivec)+0.5);229 vtable(ivec)=-vector(2)*mesh+shifty(ivec);% vtable and shifty in image coordinates (opposite to pixel shift) 230 % xtable(ivec)=iref+utable(ivec)/2-0.5;% convec flow (velocity taken at the point middle from imgae 1 and 2) 231 % ytable(ivec)=jref+vtable(ivec)/2-0.5;% and position of pixel 1=0.5 (convention for image coordinates=0 at the edge) 232 % iref=round(xtable(ivec)+0.5);% nearest image index for the middle of the vector 233 % jref=round(ytable(ivec)+0.5); 231 234 % eliminate vectors located in the mask 232 if checkmask && (iref<1 || jref<1 ||iref>npx_ima || jref>npy_ima ||( par_civ.Mask(jref,iref)<200 && par_civ.Mask(jref,iref)>=100))233 utable(ivec)=0;234 vtable(ivec)=0;235 FF(ivec)=1;236 end235 % if checkmask && (iref<1 || jref<1 ||iref>npx_ima || jref>npy_ima ||( par_civ.Mask(jref,iref)<200 && par_civ.Mask(jref,iref)>=100)) 236 % utable(ivec)=0; 237 % vtable(ivec)=0; 238 % FF(ivec)=1; 239 % end 237 240 ctable(ivec)=corrmax/sum_square;% correlation value 238 241 catch ME
Note: See TracChangeset
for help on using the changeset viewer.
