Changeset 862 for trunk/src/series
- Timestamp:
- Jan 30, 2015, 8:37:03 PM (10 years ago)
- Location:
- trunk/src/series
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/civ2vel_3C.m
r840 r862 1 %'civ2vel_3C': combine velocity fields from two cameras to get three velocity components1 %'civ2vel_3C': combine velocity fields from two cameras to get three velocity components 2 2 %------------------------------------------------------------------------ 3 3 % function ParamOut=civ2vel_3C(Param) … … 116 116 tsaiA=XmlData{1}.GeometryCalib; 117 117 else 118 msgbox_uvmat('ERROR','no geometric calibration available for image A')118 disp_uvmat('ERROR','no geometric calibration available for image A',checkrun) 119 119 return 120 120 end … … 122 122 tsaiB=XmlData{2}.GeometryCalib; 123 123 else 124 msgbox_uvmat('ERROR','no geometric calibration available for image B')124 disp_uvmat('ERROR','no geometric calibration available for image B',checkrun) 125 125 return 126 126 end 127 127 [filecell,i1_series,i2_series,j1_series,j2_series]=get_file_series(Param); 128 128 129 %% grid of physical positions 129 %% grid of physical positions (given by projection plane) 130 if ~Param.CheckObject 131 disp_uvmat('ERROR','a projection plane with interpolation is needed',checkrun) 132 return 133 end 134 ObjectData=Param.ProjObject; 135 130 136 [x,y]=meshgrid(ObjectData.RangeX(1):ObjectData.DX:ObjectData.RangeX(2),ObjectData.RangeY(1):ObjectData.DY:ObjectData.RangeY(2)); 137 z=zeros(size(x)); 138 [Field,ParamOut,errormsg] = read_field(FileName,FileType,ParamIn,num) 131 139 %camera coordinates:initialisation 2 cameras 132 140 NbCamera=2; … … 178 186 %% transform the input field (e.g; phys) if requested (no transform involving two input fields) 179 187 %camera coordinates 180 xc=R(1)*Xphys+R(2)*Yphys+R(3)*Zphys+Calib.Tx_Ty_Tz(1);181 yc=R(4)*Xphys+R(5)*Yphys+R(6)*Zphys+Calib.Tx_Ty_Tz(2);182 zc=R(7)*Xphys+R(8)*Yphys+R(9)*Zphys+Calib.Tx_Ty_Tz(3);183 184 %undistorted image coordinates185 Xu=xc./zc;186 Yu=yc./zc;187 188 Data{iview}=phys(Data{iview},XmlData{iview}); 188 189 -
trunk/src/series/civ_input.m
r861 r862 397 397 %% Civ2 parameters 398 398 Param.Civ2.CorrBoxSize=[21 21]; 399 Param.Civ2.SearchBoxSize=[ 31 31];399 Param.Civ2.SearchBoxSize=[27 27]; 400 400 Param.Civ2.CorrSmooth=1; 401 401 Param.Civ2.Dx=10; … … 539 539 set(handles.ListPairCiv2,'Visible','off') 540 540 end 541 if max(checkbox(1:3))==0 && get(handles.CheckCiv2,'UserData')==6,% no operation asked before Civ2 and input file ready for civ3 541 hseries=findobj(allchild(0),'Tag','series');% find the parent GUI 'series' 542 hhseries=guidata(hseries); %handles of the elements in 'series' 543 InputTable=get(hhseries.InputTable,'Data'); 544 if size(InputTable,1)>=1 && strcmp(InputTable{1,5},'.nc') && max(checkbox(1:3))==0 %&& get(handles.CheckCiv2,'UserData')==6,% no operation asked before Civ2 and input file ready for civ3 542 545 set(handles.CheckCiv3,'Visible','on') 543 546 else … … 573 576 checkeven=(mod(ActionInput.Civ2.CorrBoxSize,2)==0); 574 577 ActionInput.Civ2.CorrBoxSize(checkeven)=ActionInput.Civ2.CorrBoxSize(checkeven)+1;% set correlation box sizes to odd values 575 ActionInput.Civ2.SearchBoxSize=max(ActionInput.Civ2.SearchBoxSize,ActionInput.Civ2.CorrBoxSize+ 6);578 ActionInput.Civ2.SearchBoxSize=max(ActionInput.Civ2.SearchBoxSize,ActionInput.Civ2.CorrBoxSize+4); 576 579 checkeven=(mod(ActionInput.Civ2.SearchBoxSize,2)==0); 577 580 ActionInput.Civ2.SearchBoxSize(checkeven)=ActionInput.Civ2.SearchBoxSize(checkeven)+1;% set search box sizes to odd values … … 1132 1135 % --- Executes on button press in CheckDeformation. 1133 1136 function CheckDeformation_Callback(hObject, eventdata, handles) 1134 set(handles. configSource,'String','NEW')1137 set(handles.ConfigSource,'String','NEW') 1135 1138 set(handles.OK,'BackgroundColor',[1 0 1]) 1136 1139 … … 1751 1754 Param.Action.RUN=1; 1752 1755 Param.ActionInput=read_GUI(handles.civ_input); 1756 if isfield(Param.ActionInput,'Fix1') 1757 Param.ActionInput=rmfield(Param.ActionInput,'Fix1'); 1758 end 1759 if isfield(Param.ActionInput,'Patch1') 1760 Param.ActionInput=rmfield(Param.ActionInput,'Patch1'); 1761 end 1762 if isfield(Param.ActionInput,'Civ2')%remove options that may be selected beyond Patch1 1763 Param.ActionInput=rmfield(Param.ActionInput,'Civ2'); 1764 end 1765 if isfield(Param.ActionInput,'Fix2') 1766 Param.ActionInput=rmfield(Param.ActionInput,'Fix2'); 1767 end 1768 if isfield(Param.ActionInput,'Patch2') 1769 Param.ActionInput=rmfield(Param.ActionInput,'Patch2'); 1770 end 1753 1771 if isfield(Param,'OutputSubDir') 1754 1772 Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series … … 1819 1837 Param.Action.RUN=1; 1820 1838 Param.ActionInput=read_GUI(handles.civ_input); 1839 if isfield(Param.ActionInput,'Civ2')%remove options that may be selected beyond Patch1 1840 Param.ActionInput=rmfield(Param.ActionInput,'Civ2'); 1841 end 1842 if isfield(Param.ActionInput,'Fix2') 1843 Param.ActionInput=rmfield(Param.ActionInput,'Fix2'); 1844 end 1845 if isfield(Param.ActionInput,'Patch2') 1846 Param.ActionInput=rmfield(Param.ActionInput,'Patch2'); 1847 end 1821 1848 if isfield(Param,'OutputSubDir') 1822 1849 Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series … … 1928 1955 ViewData.PlotAxes.X=Data.Civ2_X'; 1929 1956 ViewData.PlotAxes.Y=Data.Civ2_Y'; 1930 ViewData.PlotAxes.ShiftX=Data.Civ2_U';% shift at each point (from patch1) estimated by runningciv21957 ViewData.PlotAxes.ShiftX=Data.Civ2_U';% shift at each point (from patch1) estimated by the preliminary run of civ2 1931 1958 ViewData.PlotAxes.ShiftY=Data.Civ2_V'; 1932 1959 ViewData.PlotAxes.Civ1_SubRange=Data.Civ1_SubRange; … … 2279 2306 drawnow 2280 2307 end 2281 2282 2283 2284 2285 2286 -
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; -
trunk/src/series/stereo_civ.m
r854 r862 50 50 path_series=fileparts(which('series')); 51 51 addpath(fullfile(path_series,'series')) 52 Data=civ_input(Param);% introduce the civ parameters using the GUI civ_input 52 % Data=civ_input(Param);% introduce the civ parameters using the GUI civ_input 53 Data=stereo_input(Param) 53 54 if isempty(Data) 54 55 Data=Param;% if civ_input has been cancelled, keep previous parameters
Note: See TracChangeset
for help on using the changeset viewer.