Ignore:
Timestamp:
Jul 19, 2024, 5:57:46 AM (4 months ago)
Author:
sommeria
Message:

filter_tps modified to avoid possible bugs in case of few vectors, subpixel interpolation slightly modified in civ

File:
1 edited

Legend:

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

    r1160 r1161  
    314314            return
    315315        end
    316         %for z_index=2:floor((NbSlice-1)/par_civ1.Dz)% loop on slices
     316     % loop on slices
    317317        for z_index=2:floor((NbSlice-SearchRange_z)/par_civ1.Dz)% loop on slices
    318             par_civ1.ImageA=circshift(par_civ1.ImageA,-par_civ1.Dz);%shift the indices in the image block upward by par_civ1.Dz
    319             par_civ1.ImageB=circshift(par_civ1.ImageA,-par_civ1.Dz);
     318            par_civ1.ImageA=circshift(par_civ1.ImageA,-par_civ1.Dz,1);%shift the indices in the image block upward by par_civ1.Dz
     319            par_civ1.ImageB=circshift(par_civ1.ImageB,-par_civ1.Dz,1);
    320320            for iz=1:par_civ1.Dz %read the new images at the end of the image block
    321                 j_image_index=j1_series_Civ1(z_index*par_civ1.Dz+SearchRange_z-par_civ1.Dz+iz,1)
     321                j_image_index=j1_series_Civ1(z_index*par_civ1.Dz+SearchRange_z-par_civ1.Dz+iz+1,1)
    322322                ImageName_A=fullfile_uvmat(RootPath_A,SubDir_A,RootFile_A,FileExt_A,NomType_A,i1_series_Civ1(1,ifield),[],j_image_index);%
    323323                A= read_image(ImageName_A,FileType_A);
     
    330330            [Data.Civ1_X(z_index,:,:),Data.Civ1_Y(z_index,:,:), Data.Civ1_U(z_index,:,:), Data.Civ1_V(z_index,:,:),Data.Civ1_W(z_index,:,:),...
    331331                Data.Civ1_C(z_index,:,:), Data.Civ1_FF(z_index,:,:), result_conv, errormsg] = civ3D (par_civ1);
    332 
    333332            if ~isempty(errormsg)
    334333                disp_uvmat('ERROR',errormsg,checkrun)
     
    523522            Data.CivStage=4;
    524523        end
    525         % else
    526         %     SubRange= par_civ2.Civ1_SubRange;
    527         %     NbCentres=par_civ2.Civ1_NbCentres;
    528         %     Coord_tps=par_civ2.Civ1_Coord_tps;
    529         %     U_tps=par_civ2.Civ1_U_tps;
    530         %     V_tps=par_civ2.Civ1_V_tps;
    531         %     Civ1_Dt=par_civ2.Civ1_Dt;
    532         %     Civ2_Dt=par_civ2.Civ1_Dt;
    533         %     Data.ListVarName={};
    534         %     Data.VarDimName={};
    535         % end
     524
    536525        Shiftx=zeros(size(par_civ2.Grid,1),1);% shift expected from civ1 data
    537526        Shifty=zeros(size(par_civ2.Grid,1),1);
    538527        nbval=zeros(size(par_civ2.Grid,1),1);% nbre of interpolated values at each grid point (from the different patch subdomains)
    539         if par_civ2.CheckDeformation
    540             DUDX=zeros(size(par_civ2.Grid,1),1);
    541             DUDY=zeros(size(par_civ2.Grid,1),1);
    542             DVDX=zeros(size(par_civ2.Grid,1),1);
    543             DVDY=zeros(size(par_civ2.Grid,1),1);
    544         end
     528
    545529        NbSubDomain=size(SubRange,3);
    546530        for isub=1:NbSubDomain% for each sub-domain of Patch1
     
    555539                Shiftx(ind_sel)=Shiftx(ind_sel)+EM*U_tps(1:nbvec_sub+3,isub);%velocity shift estimated by tps from civ1
    556540                Shifty(ind_sel)=Shifty(ind_sel)+EM*V_tps(1:nbvec_sub+3,isub);
    557                 if par_civ2.CheckDeformation
    558                     [EMDX,EMDY] = tps_eval_dxy(epoints,ctrs);%2D matrix of distances between extrapolation points epoints and spline centres (=site points) ctrs
    559                     DUDX(ind_sel)=DUDX(ind_sel)+EMDX*U_tps(1:nbvec_sub+3,isub);
    560                     DUDY(ind_sel)=DUDY(ind_sel)+EMDY*U_tps(1:nbvec_sub+3,isub);
    561                     DVDX(ind_sel)=DVDX(ind_sel)+EMDX*V_tps(1:nbvec_sub+3,isub);
    562                     DVDY(ind_sel)=DVDY(ind_sel)+EMDY*V_tps(1:nbvec_sub+3,isub);
    563                 end
    564541            end
    565542        end
     
    924901                        correl_xy=conv2(subima2,flip(flip(subima1,2),1),'valid');
    925902                        result_conv(kz,:,:)=correl_xy;
    926                         max_xy(kz)=max(max(correl_xy));
    927                          [yk(kz),xk(kz)]=find(correl_xy>=0.999*max_xy(kz),1);%find the indices of the maximum, use 0.999 to avoid rounding errors
     903                        max_xy(kz)=max(max(correl_xy));             
     904                         [yk(kz),xk(kz)]=find(correl_xy==max_xy(kz),1);%find the indices of the maximum, use 0.999 to avoid rounding errors
    928905                    end
    929906                    [corrmax,dz]=max(max_xy);
     
    990967FF=false;
    991968peakz=z;peaky=y;peakx=x;
    992 % if z < npz && z > 1 && y < npy && y > 1 && x < npx && x > 1
    993 %     f0 = log(result_conv(z,y,x));
    994 %     f1 = log(result_conv(z-1,y,x));
    995 %     f2 = log(result_conv(z+1,y,x));
    996 %     peakz = peakz+ (f1-f2)/(2*f1-4*f0+2*f2);
    997 %
    998 %     f1 = log(result_conv(z,y-1,x));
    999 %     f2 = log(result_conv(z,y+1,x));
    1000 %     peaky = peaky+ (f1-f2)/(2*f1-4*f0+2*f2);
    1001 %
    1002 %     f1 = log(result_conv(z,y,x-1));
    1003 %     f2 = log(result_conv(z,y,x+1));
    1004 %     peakx = peakx+ (f1-f2)/(2*f1-4*f0+2*f2);
    1005 % else
    1006 %     FF=true;
    1007 % end
     969if z < npz && z > 1 && y < npy && y > 1 && x < npx && x > 1
     970    f0 = log(result_conv(z,y,x));
     971    f1 = log(result_conv(z-1,y,x));
     972    f2 = log(result_conv(z+1,y,x));
     973    peakz = peakz+ (f1-f2)/(2*f1-4*f0+2*f2);
     974
     975    f1 = log(result_conv(z,y-1,x));
     976    f2 = log(result_conv(z,y+1,x));
     977    peaky = peaky+ (f1-f2)/(2*f1-4*f0+2*f2);
     978
     979    f1 = log(result_conv(z,y,x-1));
     980    f2 = log(result_conv(z,y,x+1));
     981    peakx = peakx+ (f1-f2)/(2*f1-4*f0+2*f2);
     982else
     983    FF=true;
     984end
    1008985
    1009986vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1 peakz-floor(npz/2)-1];
Note: See TracChangeset for help on using the changeset viewer.