Changeset 370 for trunk/src/civ_matlab.m


Ignore:
Timestamp:
Jan 13, 2012, 10:51:16 AM (12 years ago)
Author:
sommeria
Message:

bug corrected in civ_uvmat civ2, opening new files made more convenient in civ

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ_matlab.m

    r369 r370  
    215215    [GridX,GridY]=meshgrid(minix:par_civ2.Dx:maxix,miniy:par_civ2.Dy:maxiy);
    216216    GridX=reshape(GridX,[],1);
    217     GridY=reshape(GridY,[],1);
     217    GridY=reshape(GridY,[],1); 
    218218    Shiftx=zeros(size(GridX));% shift expected from civ1 data
    219219    Shifty=zeros(size(GridX));
     
    254254    par_civ2.Grid=[GridX(nbval>=1)-par_civ2.Shiftx/2 GridY(nbval>=1)-par_civ2.Shifty/2];% grid taken at the extrapolated origin of the displacement vectors   
    255255    if par_civ2.CheckDeformation
    256         DUDX=DUDX./nbval;
    257         DUDY=DUDY./nbval;
    258         DVDX=DVDX./nbval;
    259         DVDY=DVDY./nbval;
     256        par_civ2.DUDX=DUDX./nbval;
     257        par_civ2.DUDY=DUDY./nbval;
     258        par_civ2.DVDX=DVDX./nbval;
     259        par_civ2.DVDY=DVDY./nbval;
    260260    end
    261261    % caluclate velocity data (y and v in indices, reverse to y component)
     
    494494if CheckDecimal
    495495    mesh=0.2;%mesh in pixels for subpixel image interpolation
     496    CheckDeformation=isfield(par_civ,'CheckDeformation')&& par_civ.CheckDeformation==1;
    496497end
    497498% vector=[0 0];%default
    498499for ivec=1:nbvec
    499     iref=par_civ.Grid(ivec,1);% xindex on the image A for the middle of the correlation box
    500     jref=par_civ.Grid(ivec,2);% yindex on the image B for the middle of the correlation box
     500    iref=round(par_civ.Grid(ivec,1)+0.5);% xindex on the image A for the middle of the correlation box
     501    jref=round(par_civ.ImageHeight-par_civ.Grid(ivec,2)+0.5);% yindex on the image B for the middle of the correlation box
    501502    if ~(checkmask && par_civ.Mask(jref,iref)<=20) %velocity not set to zero by the black mask
    502503        if jref-iby2<1 || jref+iby2>par_civ.ImageHeight|| iref-ibx2<1 || iref+ibx2>par_civ.ImageWidth||...
     
    520521            image1_crop=image1_crop-image1_mean;%substract the mean
    521522            image2_crop=image2_crop-image2_mean;
    522             if isfield(par_civ,'CheckDecimal')&& par_civ.CheckDecimal==1
     523            if CheckDecimal
    523524                xi=(1:mesh:size(image1_crop,2));
    524525                yi=(1:mesh:size(image1_crop,1))';
    525                 image1_crop=interp2(image1_crop,xi,yi);
     526                if CheckDeformation
     527                    [XI,YI]=meshgrid(xi-ceil(size(image1_crop,2)/2),yi-ceil(size(image1_crop,1)/2));
     528                    XIant=XI-par_civ.DUDX(ivec)*XI-par_civ.DUDY(ivec)*YI+ceil(size(image1_crop,2)/2);
     529                    YIant=YI-par_civ.DVDX(ivec)*XI-par_civ.DVDY(ivec)*YI+ceil(size(image1_crop,1)/2);
     530                    image1_crop=interp2(image1_crop,XIant,YIant);
     531                else
     532                    image1_crop=interp2(image1_crop,xi,yi);
     533                end
    526534                xi=(1:mesh:size(image2_crop,2));
    527535                yi=(1:mesh:size(image2_crop,1))';
     
    544552                    utable(ivec)=vector(1)*mesh+shiftx(ivec);
    545553                    vtable(ivec)=vector(2)*mesh+shifty(ivec);                 
    546                     xtable(ivec)=iref+utable(ivec)/2;% convec flow (velocity taken at the point middle from imgae1 and 2)
    547                     ytable(ivec)=jref+vtable(ivec)/2;
     554                    xtable(ivec)=iref+utable(ivec)/2-0.5;% convec flow (velocity taken at the point middle from imgae 1 and 2)
     555                    ytable(ivec)=jref+vtable(ivec)/2-0.5;% and position of pixel 1=0.5 (convention for image coordinates=0 at the edge)
    548556                    iref=round(xtable(ivec));% image index for the middle of the vector
    549557                    jref=round(ytable(ivec));
Note: See TracChangeset for help on using the changeset viewer.