Changeset 862 for trunk/src/series/civ_series.m
- Timestamp:
- Jan 30, 2015, 8:37:03 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/civ_series.m
r861 r862 614 614 end 615 615 end 616 if par_civ2.CheckDeformation617 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 end622 616 623 617 % get the guess from patch1 or patch2 (case 'CheckCiv3') … … 661 655 Shifty=zeros(size(par_civ2.Grid,1),1); 662 656 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 663 663 NbSubDomain=size(SubRange,3); 664 664 for isub=1:NbSubDomain% for each sub-domain of Patch1 665 665 nbvec_sub=NbCentres(isub);% nbre of Civ vectors in the subdomain 666 666 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 668 668 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) 670 670 ctrs=Coord_tps(1:nbvec_sub,:,isub) ;%(=initial points) ctrs 671 671 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 674 674 Shifty(ind_sel)=Shifty(ind_sel)+EM*V_tps(1:nbvec_sub+3,isub); 675 675 if par_civ2.CheckDeformation … … 691 691 end 692 692 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 guess696 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; 697 697 if CheckInputFile % else Dt given by par_civ2 698 698 if strcmp(Param.ActionInput.ListCompareMode,'displacement') … … 704 704 end 705 705 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]; 707 708 if par_civ2.CheckDeformation 708 709 par_civ2.DUDX=DUDX./nbval; … … 712 713 end 713 714 714 % calculate velocity data (y and v in i ndices, reverse to y component)715 % calculate velocity data (y and v in image indices, reverse to y component) 715 716 [xtable, ytable, utable, vtable, ctable, F,result_conv,errormsg] = civ (par_civ2); 716 717 … … 880 881 % .ImageWidth: nb of pixels of the image in x 881 882 % .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 883 884 % .Mask: name of a mask file or mask image matrix itself 884 885 % .MinIma: thresholds for image luminosity … … 893 894 894 895 %% 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 896 if 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) 897 898 par_civ.Grid=dlmread(par_civ.Grid); 898 899 par_civ.Grid(1,:)=[];%the first line must be removed (heading in the grid file) 899 900 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 902 else% automatic grid in x, y image coordinates 902 903 minix=floor(par_civ.Dx/2)-0.5; 903 904 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 905 906 maxiy=minix+par_civ.Dy*floor((par_civ.ImageHeight-1)/par_civ.Dy); 906 907 [GridX,GridY]=meshgrid(minix:par_civ.Dx:maxix,miniy:par_civ.Dy:maxiy); 907 908 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 909 910 end 910 911 nbvec=size(par_civ.Grid,1); … … 915 916 isx2=ceil(par_civ.SearchBoxSize(1)/2); 916 917 isy2=ceil(par_civ.SearchBoxSize(2)/2); 917 shiftx=round(par_civ.SearchBoxShift(:,1)); 918 shiftx=round(par_civ.SearchBoxShift(:,1));%use the input shift estimate, rounded to the next integer value 918 919 shifty=-round(par_civ.SearchBoxShift(:,2));% sign minus because image j index increases when y decreases 919 920 if numel(shiftx)==1% case of a unique shift for the whole field( civ1) … … 922 923 end 923 924 924 %% Default output925 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) 926 xtable=round(par_civ.Grid(:,1)+0.5)-0.5; 927 ytable=round(par_civ.ImageHeight-par_civ.Grid(:,2)+0.5)-0.5;% y index corresponding to the position in image coordiantes 928 utable=shiftx;%zeros(nbvec,1); 929 vtable=shifty;%zeros(nbvec,1); 929 930 ctable=zeros(nbvec,1); 930 931 F=zeros(nbvec,1); … … 943 944 check_MaxIma=isfield(par_civ,'MaxIma') && ~isempty(par_civ.MaxIma); 944 945 945 % %% prepare images946 % if isfield(par_civ,'reverse_pair')947 % if par_civ.reverse_pair948 % if ischar(par_civ.ImageB)949 % temp=par_civ.ImageA;950 % par_civ.ImageA=imread(par_civ.ImageB);951 % end952 % if ischar(temp)953 % par_civ.ImageB=imread(temp);954 % end955 % end956 % else957 % if ischar(par_civ.ImageA)958 % par_civ.ImageA=imread(par_civ.ImageA);959 % end960 % if ischar(par_civ.ImageB)961 % par_civ.ImageB=imread(par_civ.ImageB);962 % end963 % end964 946 par_civ.ImageA=sum(double(par_civ.ImageA),3);%sum over rgb component for color images 965 947 par_civ.ImageB=sum(double(par_civ.ImageB),3); … … 1000 982 mesh=0.25;%mesh in pixels for subpixel image interpolation (x 4 in each direction) 1001 983 end 1002 if par_civ.CorrSmooth~=0 % par_civ.CorrSmooth=0 implies no civ computation (just input image and grid points viven) 984 985 if par_civ.CorrSmooth~=0 % par_civ.CorrSmooth=0 implies no civ computation (just input image and grid points given) 1003 986 for ivec=1:nbvec 1004 987 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 box988 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 1006 989 F(ivec)=0; 1007 990 subrange1_x=iref-ibx2:iref+ibx2;% x indices defining the first subimage … … 1076 1059 else 1077 1060 F(ivec)=3; 1078 [y,x]1079 1061 end 1080 1062 end … … 1085 1067 %------------------------------------------------------------------------ 1086 1068 % --- 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 1087 1076 function [vector,F] = SUBPIXGAUSS (result_conv,x,y) 1088 1077 %------------------------------------------------------------------------ 1089 vector=[0 0]; %default1078 % vector=[0 0]; %default 1090 1079 F=0; 1091 1080 [npy,npx]=size(result_conv); … … 1117 1106 function [vector,F] = SUBPIX2DGAUSS (result_conv,x,y) 1118 1107 %------------------------------------------------------------------------ 1119 vector=[0 0]; %default1108 % vector=[0 0]; %default 1120 1109 F=-2; 1121 1110 peaky=y;
Note: See TracChangeset
for help on using the changeset viewer.