- Timestamp:
- Feb 22, 2015, 11:07:07 PM (10 years ago)
- Location:
- trunk/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/get_field.m
r874 r876 268 268 drawnow 269 269 uiwait(handles.get_field); 270 271 %------------------------------------------------------------------------272 % --- Executes when user attempts to close get_field.273 %------------------------------------------------------------------------274 %------------------------------------------------------------------------275 276 277 % Use UIRESUME instead of delete because the OutputFcn needs278 % to get the updated handles structure.279 280 % function get_field_CloseRequestFcn(hObject, eventdata)281 % handles.output=[];282 % guidata(hObject, handles);% Update handles structure283 % %delete(handles.get_field);284 % uiresume(handles.get_field);285 %drawnow286 % if isequal(get(handles.get_field, 'waitstatus'), 'waiting')287 % % The GUI is still in UIWAIT, us UIRESUME288 % uiresume(handles.get_field);289 % else290 % % The GUI is no longer waiting, just close it291 % delete(handles.get_field);292 % end293 270 294 271 % ----------------------------------------------------------------------- … … 775 752 end 776 753 if numel(var_component)<2 777 if numel( test_coord)<2754 if numel(find(test_coord))<2 778 755 ListCoord={''}; 779 756 else 780 if numel( test_coord)>=3757 if numel(find(test_coord))>=3 781 758 set(handles.Coord_x,'Value',3) 782 759 set(handles.Coord_y,'Value',2) … … 1068 1045 set(handles.vector_z,'Visible',status) 1069 1046 set(handles.W_title,'Visible',status) 1047 if strcmp(status,'on') 1070 1048 Field=get(handles.get_field,'UserData'); 1071 1049 if Field.MaxDim>=3% for 3D fields, propose to use the third variable as time … … 1077 1055 end 1078 1056 end 1079 1057 end 1080 1058 %------------------------------------------------------------------------ 1081 1059 % --- Executes on button press in OK. -
trunk/src/series.m
r872 r876 2419 2419 GetFieldData=get_field(FirstFileName,ParamIn); 2420 2420 FieldList={}; 2421 if isfield(GetFieldData,'FieldOption')% if a field has been selected 2421 2422 switch GetFieldData.FieldOption 2422 2423 case 'vectors' … … 2482 2483 set(handles.Coord_x,'Visible','on') 2483 2484 set(handles.Coord_y,'Visible','on') 2485 end 2484 2486 else 2485 2487 msgbox_uvmat('ERROR',[FirstFileName ' does not exist']) -
trunk/src/series/civ_input.m
r874 r876 1860 1860 end 1861 1861 if isfield(Param,'OutputSubDir') 1862 Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series1862 Param=rmfield(Param,'OutputSubDir'); %remove output file option from civ_series 1863 1863 end 1864 1864 ParamPatch1=Param.ActionInput.Patch1; %store the patch1 parameters 1865 1865 Param.ActionInput=rmfield(Param.ActionInput,'Patch1');% does not execute Patch 1866 Param.IndexRange.first_i=str2num(get(handles.ref_i,'String')); 1867 Param.IndexRange.last_i=Param.IndexRange.first_i; 1868 if strcmp(get(handles.ref_j,'Visible'),'on') 1869 Param.IndexRange.first_j=str2num(get(handles.ref_j,'String')); 1870 Param.IndexRange.last_j=Param.IndexRange.first_j; 1871 else 1872 Param.IndexRange.first_j=1; 1873 Param.IndexRange.last_j=1; 1874 end 1866 1875 [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results 1867 1876 bckcolor=get(handles.civ_input,'Color'); … … 1938 1947 set(handles.Fix1,'BackgroundColor',[1 1 0]) 1939 1948 set(handles.Patch1,'BackgroundColor',[1 1 0]) 1949 Param.IndexRange.first_i=str2num(get(handles.ref_i,'String')); 1950 Param.IndexRange.last_i=Param.IndexRange.first_i; 1951 if strcmp(get(handles.ref_j,'Visible'),'on') 1952 Param.IndexRange.first_j=str2num(get(handles.ref_j,'String')); 1953 Param.IndexRange.last_j=Param.IndexRange.first_j; 1954 else 1955 Param.IndexRange.first_j=1; 1956 Param.IndexRange.last_j=1; 1957 end 1940 1958 [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results 1941 1959 … … 2031 2049 ParamPatch2=Param.ActionInput.Patch2; %store the patch1 parameters 2032 2050 Param.ActionInput=rmfield(Param.ActionInput,'Patch2');% does not execute Patch 2051 Param.IndexRange.first_i=str2num(get(handles.ref_i,'String')); 2052 Param.IndexRange.last_i=Param.IndexRange.first_i; 2053 if strcmp(get(handles.ref_j,'Visible'),'on') 2054 Param.IndexRange.first_j=str2num(get(handles.ref_j,'String')); 2055 Param.IndexRange.last_j=Param.IndexRange.first_j; 2056 else 2057 Param.IndexRange.first_j=1; 2058 Param.IndexRange.last_j=1; 2059 end 2033 2060 [Data,errormsg]=civ_series(Param);% get the civ1+fix1 results 2034 2061 bckcolor=get(handles.civ_input,'Color'); -
trunk/src/series/civ_series.m
r873 r876 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;697 693 if CheckInputFile % else Dt given by par_civ2 698 694 if strcmp(Param.ActionInput.ListCompareMode,'displacement') … … 707 703 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]; 708 704 if par_civ2.CheckDeformation 709 par_civ2.DUDX=DUDX ./nbval;710 par_civ2.DUDY=DUDY ./nbval;711 par_civ2.DVDX=DVDX ./nbval;712 par_civ2.DVDY=DVDY ./nbval;705 par_civ2.DUDX=DUDX(nbval>=1)./nbval(nbval>=1); 706 par_civ2.DUDY=DUDY(nbval>=1)./nbval(nbval>=1); 707 par_civ2.DVDX=DVDX(nbval>=1)./nbval(nbval>=1); 708 par_civ2.DVDY=DVDY(nbval>=1)./nbval(nbval>=1); 713 709 end 714 710 … … 910 906 911 907 %% prepare correlation and search boxes 912 ibx2= ceil(par_civ.CorrBoxSize(1)/2);913 iby2= ceil(par_civ.CorrBoxSize(2)/2);914 isx2= ceil(par_civ.SearchBoxSize(1)/2);915 isy2= ceil(par_civ.SearchBoxSize(2)/2);908 ibx2=floor(par_civ.CorrBoxSize(1)/2); 909 iby2=floor(par_civ.CorrBoxSize(2)/2); 910 isx2=floor(par_civ.SearchBoxSize(1)/2); 911 isy2=floor(par_civ.SearchBoxSize(2)/2); 916 912 shiftx=round(par_civ.SearchBoxShift(:,1));%use the input shift estimate, rounded to the next integer value 917 913 shifty=-round(par_civ.SearchBoxShift(:,2));% sign minus because image j index increases when y decreases … … 968 964 end 969 965 check_undefined=(par_civ.Mask<200 & par_civ.Mask>=20 ); 970 par_civ.ImageA(check_undefined)=0;% put image A to zero (i.e. the min image value) in the undefined area971 par_civ.ImageB(check_undefined)=0;% put image B to zero (i.e. the min image value) in the undefined area966 % par_civ.ImageA(check_undefined)=0;% put image A to zero (i.e. the min image value) in the undefined area 967 % par_civ.ImageB(check_undefined)=0;% put image B to zero (i.e. the min image value) in the undefined area 972 968 end 973 969 … … 993 989 image2_crop=MinA*ones(numel(subrange2_y),numel(subrange2_x));% default value=min of image A 994 990 mask1_crop=ones(numel(subrange1_y),numel(subrange1_x));% default value=1 for mask 995 mask2_crop=ones(numel(subrange2_y),numel(subrange2_x));% default value= minfor mask991 mask2_crop=ones(numel(subrange2_y),numel(subrange2_x));% default value=1 for mask 996 992 check1_x=subrange1_x>=1 & subrange1_x<=par_civ.ImageWidth;% check which points in the subimage 1 are contained in the initial image 1 997 993 check1_y=subrange1_y>=1 & subrange1_y<=par_civ.ImageHeight; … … 1006 1002 F(ivec)=3; % 1007 1003 else 1004 image1_crop=image1_crop.*~mask1_crop;% put to zero the masked pixels (mask1_crop='true'=1) 1005 image2_crop=image2_crop.*~mask2_crop; 1008 1006 image1_mean=mean(mean(image1_crop))/(1-sizemask); 1009 1007 image2_mean=mean(mean(image2_crop))/(1-sizemask); … … 1026 1024 XIant=XI-par_civ.DUDX(ivec)*XI-par_civ.DUDY(ivec)*YI+ceil(size(image1_crop,2)/2); 1027 1025 YIant=YI-par_civ.DVDX(ivec)*XI-par_civ.DVDY(ivec)*YI+ceil(size(image1_crop,1)/2); 1026 image1_crop_1=image1_crop; 1028 1027 image1_crop=interp2(image1_crop,XIant,YIant); 1028 image1_crop_2=image1_crop; 1029 1029 image1_crop(isnan(image1_crop))=0; 1030 image1_crop_3=image1_crop; 1030 1031 xi=(1:mesh:size(image2_crop,2)); 1031 1032 yi=(1:mesh:size(image2_crop,1))'; 1032 1033 image2_crop=interp2(image2_crop,xi,yi); 1033 1034 image2_crop(isnan(image2_crop))=0; 1035 par_civ.CorrSmooth=3; 1034 1036 %% 1035 1037 end … … 1041 1043 %Find the correlation max, at 255 1042 1044 [y,x] = find(result_conv==255,1); 1045 subimage2_crop=image2_crop(y:y+2*iby2/mesh,x:x+2*ibx2/mesh);%subimage of image 2 corresponding to the optimum displacement of first image 1046 sum_square=sum_square*sum(sum(subimage2_crop.*subimage2_crop));% product of variances of image 1 and 2 1047 sum_square=sqrt(sum_square);% srt of the variance product to normalise correlation 1043 1048 if ~isempty(y) && ~isempty(x) 1044 1049 try … … 1047 1052 elseif par_civ.CorrSmooth==2 1048 1053 [vector,F(ivec)] = SUBPIX2DGAUSS (result_conv,x,y); 1054 else 1055 [vector,F(ivec)] = quadr_fit(result_conv,x,y); 1049 1056 end 1050 1057 utable(ivec)=vector(1)*mesh+shiftx(ivec); … … 1052 1059 xtable(ivec)=iref+utable(ivec)/2-0.5;% convec flow (velocity taken at the point middle from imgae 1 and 2) 1053 1060 ytable(ivec)=jref+vtable(ivec)/2-0.5;% and position of pixel 1=0.5 (convention for image coordinates=0 at the edge) 1054 iref=round(xtable(ivec));% image index for the middle of the vector1061 iref=round(xtable(ivec));% nearest image index for the middle of the vector 1055 1062 jref=round(ytable(ivec)); 1063 % eliminate vectors located in the mask 1056 1064 if checkmask && par_civ.Mask(jref,iref)<200 && par_civ.Mask(jref,iref)>=100 1057 1065 utable(ivec)=0; … … 1150 1158 end 1151 1159 vector=[peakx-floor(npx/2)-1 peaky-floor(npy/2)-1]; 1160 1161 %------------------------------------------------------------------------ 1162 % --- Find the maximum of the correlation function after quadratic interpolation 1163 function [vector,F] = quadr_fit(result_conv,x,y) 1164 [npy,npx]=size(result_conv); 1165 if x<4 || y<4 || npx-x<4 ||npy-y <4 1166 F=-2; 1167 vector=[x y]; 1168 else 1169 F=0; 1170 x_ind=x-4:x+4; 1171 y_ind=y-4:y+4; 1172 x_vec=0.25*(x_ind-x); 1173 y_vec=0.25*(y_ind-y); 1174 [X,Y]=meshgrid(x_vec,y_vec); 1175 coord=[reshape(X,[],1) reshape(Y,[],1)]; 1176 result_conv=reshape(result_conv(y_ind,x_ind),[],1); 1177 1178 1179 % n=numel(X); 1180 % x=[X Y]; 1181 % X=X-0.5; 1182 % Y=Y+0.5; 1183 % y = (X.*X+2*Y.*Y+X.*Y+6) + 0.1*rand(n,1); 1184 p = polyfitn(coord,result_conv,2); 1185 A(1,1)=2*p.Coefficients(1); 1186 A(1,2)=p.Coefficients(2); 1187 A(2,1)=p.Coefficients(2); 1188 A(2,2)=2*p.Coefficients(4); 1189 vector=[x y]'-A\[p.Coefficients(3) p.Coefficients(5)]'; 1190 vector=vector'-[floor(npx/2) floor(npy/2)]-1 ; 1191 % zg = polyvaln(p,coord); 1192 % figure 1193 % surf(x_vec,y_vec,reshape(zg,9,9)) 1194 % hold on 1195 % plot3(X,Y,reshape(result_conv,9,9),'o') 1196 % hold off 1197 end 1152 1198 1153 1199 %'RUN_FIX': function for fixing velocity fields: -
trunk/src/series/stereo_civ.m
r864 r876 1 %' civ_series': PIV function activated by the general GUI series1 %'stereo_civ': determination of topography by image correlation of two stereo views 2 2 % --- call the sub-functions: 3 3 % civ: PIV function itself -
trunk/src/series/stereo_input.m
r865 r876 1 %'stereo_input': function associated with the GUI 'stereo_input.fig' to set the input parameters for civ_series1 %'stereo_input': function associated with the GUI 'stereo_input.fig' to set the input parameters for stereo_civ 2 2 %------------------------------------------------------------------------ 3 3 % function ParamOut = stereo_input(Param) -
trunk/src/sub_field.m
r866 r876 43 43 SubData=Field; 44 44 return 45 end 46 if ~isfield(Field_1,'VarAttribute') 47 Field_1.VarAttribute={}; 45 48 end 46 49 … … 107 110 end 108 111 112 109 113 %% rename the dimensions of the second field if identical to those of the first 110 114 for ilist=1:numel(Field_1.VarDimName) … … 127 131 ind_remove=false(size(Field_1.ListVarName)); 128 132 % loop on the variables of the second field Field_1 129 for ilist=1:numel(Field_1. ListVarName)133 for ilist=1:numel(Field_1.VarAttribute) 130 134 % case of variable with a single dimension 131 135 if ~isempty(Field_1.VarAttribute{ilist}) && ~isempty(regexp(Field_1.VarAttribute{ilist}.Role,'^coord'))% if variable with Role coord... is found. … … 173 177 ListVarNameNew=ListVarNameNew(~check_remove); % %list of renaimed varaibles corresponding to ListVarNameSub 174 178 VarDimNameSub=Field_1.VarDimName(~check_remove); 179 if numel(Field_1.VarAttribute)<max(find(~check_remove)) 180 for ilist=numel(Field_1.VarAttribute)+1:max(find(~check_remove)) 181 Field_1.VarAttribute{ilist}={}; 182 end 183 end 175 184 VarAttributeSub=Field_1.VarAttribute(~check_remove); 176 185 check_rename=check_rename(~check_remove); -
trunk/src/transform_field/diff_vel.m
r870 r876 1 %' sub_field': combines two input fields1 %'diff_vel': calculate the difference of two input velocity fields. 2 2 % 3 % the two fields are subtstracted when of the same nature (scalar or4 % vector), if the coordinates do not coincide, the second field is5 % interpolated on the cooridintes of the first one6 % 7 % when scalar and vectors are combined, the fields are just merged in a single matlab structure for common visualisation 3 % the second velocity field is linearly interpolated 4 % (after elimination of the vectors marked with an error flag) to the positions of 5 % the first one before subtraction. The ancilary data of the first field 6 % are preserved while those of the second one are lost. 7 8 8 %----------------------------------------------------------------------- 9 % function SubData= sub_field(Field,XmlData,Field_1)9 % function SubData=diff_vel(Field,XmlData,Field_1) 10 10 % 11 11 % OUPUT: … … 14 14 % INPUT: 15 15 % Field: matlab structure representing the first field 16 % XmlData: not used, needed for consistency with the call of transform fct. 16 17 % Field_1:matlab structure representing the second field 17 18 -
trunk/src/transform_field/signal_spectrum.m
r810 r876 1 % 'signal_spectrum': calculate and display spectrum of the current field1 % 'signal_spectrum': calculate and display power spectrum of the current field 2 2 % operate on a 1D signal or the first dimension of a higher dimensional matrix (then average over other dimensions) 3 3 % this function aplies the Welch method and call the function of the matlab signal processing toolbox -
trunk/src/transform_field/sub_field.m
r810 r876 1 %'sub_field': combines two input fields 1 %'sub_field': combines two input fields, taking the difference if of the same nature 2 2 % 3 % the two fields are subtstracted when of the same nature (scalar or 4 % vector), if the coordinates do not coincide, the second field is 5 % interpolated on the cooridintes of the first one 3 % the two fields are subtracted when of the same nature (scalar or 4 % vector),and defined at the same points 6 5 % 7 6 % when scalar and vectors are combined, the fields are just merged in a single matlab structure for common visualisation
Note: See TracChangeset
for help on using the changeset viewer.