Changeset 880 for trunk/src/series/civ_series.m
 Timestamp:
 Mar 4, 2015, 12:01:38 AM (9 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/series/civ_series.m
r879 r880 1015 1015 end 1016 1016 %threshold on image minimum 1017 if check_MinIma && (image1_mean < par_civ.MinIma  image2_mean < par_civ.MinIma)1018 F(ivec)=3;1019 end1020 %threshold on image maximum1021 if check_MaxIma && (image1_mean > par_civ.MaxIma  image2_mean > par_civ.MaxIma)1022 F(ivec)=3;1023 end1024 1025 1017 if F(ivec)~=3 1026 if checkmask 1027 image1_crop=(image1_cropimage1_mean).*~mask1_crop;%substract the mean, put to zero the masked parts 1028 image2_crop=(image2_cropimage2_mean).*~mask2_crop; 1029 else 1030 image1_crop=(image1_cropimage1_mean); 1031 image2_crop=(image2_cropimage2_mean); 1032 end 1033 if CheckDeformation 1034 xi=(1:mesh:size(image1_crop,2)); 1035 yi=(1:mesh:size(image1_crop,1))'; 1036 [XI,YI]=meshgrid(xiceil(size(image1_crop,2)/2),yiceil(size(image1_crop,1)/2)); 1037 XIant=XIpar_civ.DUDX(ivec)*XIpar_civ.DUDY(ivec)*YI+ceil(size(image1_crop,2)/2); 1038 YIant=YIpar_civ.DVDX(ivec)*XIpar_civ.DVDY(ivec)*YI+ceil(size(image1_crop,1)/2); 1039 image1_crop=interp2(image1_crop,XIant,YIant); 1040 image1_crop(isnan(image1_crop))=0; 1041 xi=(1:mesh:size(image2_crop,2)); 1042 yi=(1:mesh:size(image2_crop,1))'; 1043 image2_crop=interp2(image2_crop,xi,yi,'*spline'); 1044 image2_crop(isnan(image2_crop))=0; 1045 %par_civ.CorrSmooth=3;%%%%%%%%%%%%%%%%%%% 1046 %% 1047 end 1048 sum_square=sum(sum(image1_crop.*image1_crop)); 1049 %reference: Oliver Pust, PIV: Direct CrossCorrelation 1050 result_conv= conv2(image2_crop,flipdim(flipdim(image1_crop,2),1),'valid'); 1051 corrmax= max(max(result_conv)); 1052 result_conv=(result_conv/corrmax)*255; %normalize, peak=always 255 1053 %Find the correlation max, at 255 1054 [y,x] = find(result_conv==255,1); 1055 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 1056 sum_square=sum_square*sum(sum(subimage2_crop.*subimage2_crop));% product of variances of image 1 and 2 1057 sum_square=sqrt(sum_square);% srt of the variance product to normalise correlation 1058 if ~isempty(y) && ~isempty(x) 1059 try 1060 if par_civ.CorrSmooth==1 1061 [vector,F(ivec)] = SUBPIXGAUSS (result_conv,x,y); 1062 elseif par_civ.CorrSmooth==2 1063 [vector,F(ivec)] = SUBPIX2DGAUSS (result_conv,x,y); 1064 else 1065 [vector,F(ivec)] = quadr_fit(result_conv,x,y); 1066 end 1067 utable(ivec)=vector(1)*mesh+shiftx(ivec); 1068 vtable(ivec)=vector(2)*mesh+shifty(ivec); 1069 xtable(ivec)=iref+utable(ivec)/20.5;% convec flow (velocity taken at the point middle from imgae 1 and 2) 1070 ytable(ivec)=jref+vtable(ivec)/20.5;% and position of pixel 1=0.5 (convention for image coordinates=0 at the edge) 1071 iref=round(xtable(ivec));% nearest image index for the middle of the vector 1072 jref=round(ytable(ivec)); 1073 % eliminate vectors located in the mask 1074 if checkmask && par_civ.Mask(jref,iref)<200 && par_civ.Mask(jref,iref)>=100 1075 utable(ivec)=0; 1076 vtable(ivec)=0; 1018 if check_MinIma && (image1_mean < par_civ.MinIma  image2_mean < par_civ.MinIma) 1019 F(ivec)=3; 1020 %threshold on image maximum 1021 elseif check_MaxIma && (image1_mean > par_civ.MaxIma  image2_mean > par_civ.MaxIma) 1022 F(ivec)=3; 1023 end 1024 if F(ivec)~=3 1025 %mask 1026 if checkmask 1027 image1_crop=(image1_cropimage1_mean).*~mask1_crop;%substract the mean, put to zero the masked parts 1028 image2_crop=(image2_cropimage2_mean).*~mask2_crop; 1029 else 1030 image1_crop=(image1_cropimage1_mean); 1031 image2_crop=(image2_cropimage2_mean); 1032 end 1033 %deformation 1034 if CheckDeformation 1035 xi=(1:mesh:size(image1_crop,2)); 1036 yi=(1:mesh:size(image1_crop,1))'; 1037 [XI,YI]=meshgrid(xiceil(size(image1_crop,2)/2),yiceil(size(image1_crop,1)/2)); 1038 XIant=XIpar_civ.DUDX(ivec)*XIpar_civ.DUDY(ivec)*YI+ceil(size(image1_crop,2)/2); 1039 YIant=YIpar_civ.DVDX(ivec)*XIpar_civ.DVDY(ivec)*YI+ceil(size(image1_crop,1)/2); 1040 image1_crop=interp2(image1_crop,XIant,YIant); 1041 image1_crop(isnan(image1_crop))=0; 1042 xi=(1:mesh:size(image2_crop,2)); 1043 yi=(1:mesh:size(image2_crop,1))'; 1044 image2_crop=interp2(image2_crop,xi,yi,'*spline'); 1045 image2_crop(isnan(image2_crop))=0; 1046 %par_civ.CorrSmooth=3;%%%%%%%%%%%%%%%%%%% 1047 %% 1048 end 1049 sum_square=sum(sum(image1_crop.*image1_crop)); 1050 %reference: Oliver Pust, PIV: Direct CrossCorrelation 1051 result_conv= conv2(image2_crop,flipdim(flipdim(image1_crop,2),1),'valid'); 1052 corrmax= max(max(result_conv)); 1053 result_conv=(result_conv/corrmax)*255; %normalize, peak=always 255 1054 %Find the correlation max, at 255 1055 [y,x] = find(result_conv==255,1); 1056 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 1057 sum_square=sum_square*sum(sum(subimage2_crop.*subimage2_crop));% product of variances of image 1 and 2 1058 sum_square=sqrt(sum_square);% srt of the variance product to normalise correlation 1059 if ~isempty(y) && ~isempty(x) 1060 try 1061 if par_civ.CorrSmooth==1 1062 [vector,F(ivec)] = SUBPIXGAUSS (result_conv,x,y); 1063 elseif par_civ.CorrSmooth==2 1064 [vector,F(ivec)] = SUBPIX2DGAUSS (result_conv,x,y); 1065 else 1066 [vector,F(ivec)] = quadr_fit(result_conv,x,y); 1067 end 1068 utable(ivec)=vector(1)*mesh+shiftx(ivec); 1069 vtable(ivec)=vector(2)*mesh+shifty(ivec); 1070 xtable(ivec)=iref+utable(ivec)/20.5;% convec flow (velocity taken at the point middle from imgae 1 and 2) 1071 ytable(ivec)=jref+vtable(ivec)/20.5;% and position of pixel 1=0.5 (convention for image coordinates=0 at the edge) 1072 iref=round(xtable(ivec));% nearest image index for the middle of the vector 1073 jref=round(ytable(ivec)); 1074 % eliminate vectors located in the mask 1075 if checkmask && par_civ.Mask(jref,iref)<200 && par_civ.Mask(jref,iref)>=100 1076 utable(ivec)=0; 1077 vtable(ivec)=0; 1078 F(ivec)=3; 1079 end 1080 ctable(ivec)=corrmax/sum_square;% correlation value 1081 catch ME 1077 1082 F(ivec)=3; 1078 1083 end 1079 ctable(ivec)=corrmax/sum_square;% correlation value 1080 catch ME 1084 else 1081 1085 F(ivec)=3; 1082 1086 end 1083 else1084 F(ivec)=3;1085 1087 end 1086 1088 end
Note: See TracChangeset
for help on using the changeset viewer.