Ignore:
Timestamp:
Jan 30, 2015, 8:37:03 PM (9 years ago)
Author:
sommeria
Message:

bugs repaired

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series/civ_series.m

    r861 r862  
    614614            end
    615615        end
    616         if par_civ2.CheckDeformation
    617             DUDX=zeros(size(par_civ2.Grid,1),1);
    618             DUDY=zeros(size(par_civ2.Grid,1),1);
    619             DVDX=zeros(size(par_civ2.Grid,1),1);
    620             DVDY=zeros(size(par_civ2.Grid,1),1);
    621         end
    622616       
    623617        % get the guess from patch1 or patch2 (case 'CheckCiv3')
     
    661655        Shifty=zeros(size(par_civ2.Grid,1),1);
    662656        nbval=zeros(size(par_civ2.Grid,1),1);% nbre of interpolated values at each grid point (from the different patch subdomains)
     657        if par_civ2.CheckDeformation
     658            DUDX=zeros(size(par_civ2.Grid,1),1);
     659            DUDY=zeros(size(par_civ2.Grid,1),1);
     660            DVDX=zeros(size(par_civ2.Grid,1),1);
     661            DVDY=zeros(size(par_civ2.Grid,1),1);
     662        end
    663663        NbSubDomain=size(SubRange,3);
    664664        for isub=1:NbSubDomain% for each sub-domain of Patch1
    665665            nbvec_sub=NbCentres(isub);% nbre of Civ vectors in the subdomain
    666666            ind_sel=find(par_civ2.Grid(:,1)>=SubRange(1,1,isub) & par_civ2.Grid(:,1)<=SubRange(1,2,isub) &...
    667                 par_civ2.Grid(:,2)>=SubRange(2,1,isub) & par_civ2.Grid(:,2)<=SubRange(2,2,isub));
     667                par_civ2.Grid(:,2)>=SubRange(2,1,isub) & par_civ2.Grid(:,2)<=SubRange(2,2,isub));% grid points in the subdomain
    668668            if ~isempty(ind_sel)
    669                 epoints = par_civ2.Grid(ind_sel,:);% coordinates of interpolation sites
     669                epoints = par_civ2.Grid(ind_sel,:);% coordinates of interpolation sites (measurement grids)
    670670                ctrs=Coord_tps(1:nbvec_sub,:,isub) ;%(=initial points) ctrs
    671671                nbval(ind_sel)=nbval(ind_sel)+1;% records the number of values for each interpolation point (in case of subdomain overlap)
    672                 EM = tps_eval(epoints,ctrs);
    673                 Shiftx(ind_sel)=Shiftx(ind_sel)+EM*U_tps(1:nbvec_sub+3,isub);
     672                EM = tps_eval(epoints,ctrs);% thin plate spline (tps) coefficient
     673                Shiftx(ind_sel)=Shiftx(ind_sel)+EM*U_tps(1:nbvec_sub+3,isub);%velocity shift estimated by tps from civ1
    674674                Shifty(ind_sel)=Shifty(ind_sel)+EM*V_tps(1:nbvec_sub+3,isub);
    675675                if par_civ2.CheckDeformation
     
    691691            end
    692692        end
    693         ibx2=ceil(par_civ2.CorrBoxSize(1)/2);
    694         iby2=ceil(par_civ2.CorrBoxSize(2)/2);
    695         par_civ2.SearchBoxSize(1)=2*ibx2+9;% search ara +-4 pixels around the guess
    696         par_civ2.SearchBoxSize(2)=2*iby2+9;
     693%         ibx2=ceil(par_civ2.CorrBoxSize(1)/2);
     694%         iby2=ceil(par_civ2.CorrBoxSize(2)/2);
     695       % par_civ2.SearchBoxSize(1)=2*ibx2+9;% search ara +-4 pixels around the guess
     696        %par_civ2.SearchBoxSize(2)=2*iby2+9;
    697697        if CheckInputFile % else Dt given by par_civ2
    698698            if strcmp(Param.ActionInput.ListCompareMode,'displacement')
     
    704704        end
    705705        par_civ2.SearchBoxShift=(Civ2_Dt/Civ1_Dt)*[Shiftx(nbval>=1)./nbval(nbval>=1) Shifty(nbval>=1)./nbval(nbval>=1)];
    706         par_civ2.Grid=[par_civ2.Grid(nbval>=1,1)-par_civ2.SearchBoxShift(:,1)/2 par_civ2.Grid(nbval>=1,2)-par_civ2.SearchBoxShift(:,2)/2];% grid taken at the extrapolated origin of the displacement vectors
     706        % shift the grid points by half the expected shift to provide the correlation box position in image A
     707        par_civ2.Grid=[par_civ2.Grid(nbval>=1,1)-par_civ2.SearchBoxShift(nbval>=1,1)/2 par_civ2.Grid(nbval>=1,2)-par_civ2.SearchBoxShift(nbval>=1,2)/2];
    707708        if par_civ2.CheckDeformation
    708709            par_civ2.DUDX=DUDX./nbval;
     
    712713        end
    713714       
    714         % calculate velocity data (y and v in indices, reverse to y component)
     715        % calculate velocity data (y and v in image indices, reverse to y component)
    715716        [xtable, ytable, utable, vtable, ctable, F,result_conv,errormsg] = civ (par_civ2);
    716717       
     
    880881%  .ImageWidth: nb of pixels of the image in x
    881882%  .Dx, Dy: mesh for the PIV calculation
    882 %  .Grid: grid giving the PIV calculation points (alternative to .Dx .Dy)
     883%  .Grid: grid giving the PIV calculation points (alternative to .Dx .Dy): centres of the correlation boxes in Image A
    883884%  .Mask: name of a mask file or mask image matrix itself
    884885%  .MinIma: thresholds for image luminosity
     
    893894
    894895%% prepare measurement grid
    895 if isfield(par_civ,'Grid')% grid points set as input
    896     if ischar(par_civ.Grid)%read the grid file if the input is a file name
     896if isfield(par_civ,'Grid')% grid points set as input, central positions of the sub-images in image A
     897    if ischar(par_civ.Grid)%read the grid file if the input is a file name (grid in x, y image coordinates)
    897898        par_civ.Grid=dlmread(par_civ.Grid);
    898899        par_civ.Grid(1,:)=[];%the first line must be removed (heading in the grid file)
    899900    end
    900     % else par_civ.Grid is already an array
    901 else% automatic grid
     901    % else par_civ.Grid is already an array, no action here
     902else% automatic grid in x, y image coordinates
    902903    minix=floor(par_civ.Dx/2)-0.5;
    903904    maxix=minix+par_civ.Dx*floor((par_civ.ImageWidth-1)/par_civ.Dx);
    904     miniy=floor(par_civ.Dy/2)-0.5;
     905    miniy=floor(par_civ.Dy/2)-0.5;% first automatic grid point at half the mesh Dy
    905906    maxiy=minix+par_civ.Dy*floor((par_civ.ImageHeight-1)/par_civ.Dy);
    906907    [GridX,GridY]=meshgrid(minix:par_civ.Dx:maxix,miniy:par_civ.Dy:maxiy);
    907908    par_civ.Grid(:,1)=reshape(GridX,[],1);
    908     par_civ.Grid(:,2)=reshape(GridY,[],1);
     909    par_civ.Grid(:,2)=reshape(GridY,[],1);% increases with array index
    909910end
    910911nbvec=size(par_civ.Grid,1);
     
    915916isx2=ceil(par_civ.SearchBoxSize(1)/2);
    916917isy2=ceil(par_civ.SearchBoxSize(2)/2);
    917 shiftx=round(par_civ.SearchBoxShift(:,1));
     918shiftx=round(par_civ.SearchBoxShift(:,1));%use the input shift estimate, rounded to the next integer value
    918919shifty=-round(par_civ.SearchBoxShift(:,2));% sign minus because image j index increases when y decreases
    919920if numel(shiftx)==1% case of a unique shift for the whole field( civ1)
     
    922923end
    923924
    924 %% Default output
    925 xtable=par_civ.Grid(:,1);
    926 ytable=par_civ.Grid(:,2);
    927 utable=zeros(nbvec,1);
    928 vtable=zeros(nbvec,1);
     925%% Array initialisation and default output  if par_civ.CorrSmooth=0 (just the grid calculated, no civ computation)
     926xtable=round(par_civ.Grid(:,1)+0.5)-0.5;
     927ytable=round(par_civ.ImageHeight-par_civ.Grid(:,2)+0.5)-0.5;% y index corresponding to the position in image coordiantes
     928utable=shiftx;%zeros(nbvec,1);
     929vtable=shifty;%zeros(nbvec,1);
    929930ctable=zeros(nbvec,1);
    930931F=zeros(nbvec,1);
     
    943944check_MaxIma=isfield(par_civ,'MaxIma') && ~isempty(par_civ.MaxIma);
    944945
    945 % %% prepare images
    946 % if isfield(par_civ,'reverse_pair')
    947 %     if par_civ.reverse_pair
    948 %         if ischar(par_civ.ImageB)
    949 %             temp=par_civ.ImageA;
    950 %             par_civ.ImageA=imread(par_civ.ImageB);
    951 %         end
    952 %         if ischar(temp)
    953 %             par_civ.ImageB=imread(temp);
    954 %         end
    955 %     end
    956 % else
    957 %     if ischar(par_civ.ImageA)
    958 %         par_civ.ImageA=imread(par_civ.ImageA);
    959 %     end
    960 %     if ischar(par_civ.ImageB)
    961 %         par_civ.ImageB=imread(par_civ.ImageB);
    962 %     end
    963 % end
    964946par_civ.ImageA=sum(double(par_civ.ImageA),3);%sum over rgb component for color images
    965947par_civ.ImageB=sum(double(par_civ.ImageB),3);
     
    1000982    mesh=0.25;%mesh in pixels for subpixel image interpolation (x 4 in each direction)
    1001983end
    1002 if par_civ.CorrSmooth~=0 % par_civ.CorrSmooth=0 implies no civ computation (just input image and grid points viven)
     984
     985if par_civ.CorrSmooth~=0 % par_civ.CorrSmooth=0 implies no civ computation (just input image and grid points given)
    1003986    for ivec=1:nbvec
    1004987        iref=round(par_civ.Grid(ivec,1)+0.5);% xindex on the image A for the middle of the correlation box
    1005         jref=round(par_civ.ImageHeight-par_civ.Grid(ivec,2)+0.5);% yindex on the image B for the middle of the correlation box
     988        jref=round(par_civ.ImageHeight-par_civ.Grid(ivec,2)+0.5);%  j index  for the middle of the correlation box in the image A
    1006989        F(ivec)=0;
    1007990        subrange1_x=iref-ibx2:iref+ibx2;% x indices defining the first subimage
     
    10761059            else
    10771060                F(ivec)=3;
    1078                 [y,x]
    10791061            end
    10801062        end
     
    10851067%------------------------------------------------------------------------
    10861068% --- Find the maximum of the correlation function after interpolation
     1069% OUPUT:
     1070% vector = optimum displacement vector with subpixel correction
     1071% F =flag: =0 OK
     1072%           =-2 , warning: max too close to the edge of the search box (1 pixel margin)
     1073% INPUT:
     1074% x,y: position of the maximum correlation at integer values
     1075
    10871076function [vector,F] = SUBPIXGAUSS (result_conv,x,y)
    10881077%------------------------------------------------------------------------
    1089 vector=[0 0]; %default
     1078% vector=[0 0]; %default
    10901079F=0;
    10911080[npy,npx]=size(result_conv);
     
    11171106function [vector,F] = SUBPIX2DGAUSS (result_conv,x,y)
    11181107%------------------------------------------------------------------------
    1119 vector=[0 0]; %default
     1108% vector=[0 0]; %default
    11201109F=-2;
    11211110peaky=y;
Note: See TracChangeset for help on using the changeset viewer.