Measurements in Fluid Mechanics 058:180:001 (ME:5180:0001) Time & Location: 2:30P - 3:20P MWF 218 MLH Office Hours: 4:00P – 5:00P MWF 223B-5 HL Instructor: Lichuan Gui [email protected]http://lcgui.net Students are encouraged to attend the class. You may not be able to understand by just reading the lecture notes.
Students are encouraged to attend the class. You may not be able to understand by just reading the lecture notes. Measurements in Fluid Mechanics 058:180:001 (ME:5180:0001) Time & Location: 2:30P - 3:20P MWF 218 MLH Office Hours: 4:00P – 5:00P MWF 223B-5 HL. Instructor: Lichuan Gui - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Measurements in Fluid Mechanics058:180:001 (ME:5180:0001)
Process digital image before evaluationW/o iteration, unsharp mask (r=11) Iterated evaluation, unsharp mask (r=11)
Matlab function for erroneous vector identification File name: errordetection.m
function[valid]=errordetection(U,V,dU,dV)% U - horizontal particle image displacement% V - vertical particle image displacement% dU(1) - minimal horizontal particle image displacement% dU(2) - maximal horizontal particle image displacement% dU(3) - error tolerance of horizontal particle image displacement% dV(1) - minimal vertical particle image displacement% dV(2) - maximal vertical particle image displacement% dV(3) - error tolerance of vertical particle image displacement% Valid - validation index of the particle image displacement% 1 for valid vector, 0 for evaluation error
[nx ny]=size(U); % determine number of rows & collumns of interrogation grid
for i=1:nx % range filtering begin for j=1:ny if U(i,j)>=dU(1) & U(i,j)<=dU(2) & V(i,j)>=dV(1) & V(i,j)<=dV(2) valid1(i,j)=1; else valid1(i,j)=0; end endend % range filtering end
17
18
File name: errordetection.m
for i=1:nx % median filter begin for j=1:ny if valid1(i,j)==0 % skip detected errors valid(i,j)=0; continue; end % skip detected errors nr=0; % search for valid vectors in 3x3 neighborhood for p=-1:1 for q=-1:1 if i+p>=1 & i+p<=nx & j+q>=1 & j+q<=ny & valid1(i+p,j+q)==1 nr=nr+1; u(nr)=U(i+p,j+q); v(nr)=V(i+p,j+q); end end end % search for valid vectors in 3x3 neighborhood if nr<3 % skip vector without enough valid neighbors valid(i,j)=0; continue; end % skip vector without enough valid neighbors
Matlab function for erroneous vector identification
19
File name: errordetection.m
for p=1:nr-1 % determine median vector for q=p+1:nr if u(q)>u(p) um=u(p); u(p)=u(q); u(q)=um; end if v(q)>v(p) vm=v(p); v(p)=v(q); v(q)=vm; end end end nm=int16(nr/2); um=u(nm); vm=v(nm); % determine median vector if abs(U(i,j)-um)<=dU(3) & abs(V(i,j)-vm)<=dV(3) % detect wrong vector valid(i,j)=1; else valid(i,j)=0; end % detect wrong vector end
end % median filter end
Matlab function for erroneous vector identification
20
Matlab function for local vector interpolationFile name: interpolation.mfunction[U V valid2]=interpolation(U,V, valid1)[nx ny]=size(U);for i=1:nx for j=1:ny if valid1(i,j)==1 valid2(i,j)=1; continue; end nr=0; um=0; vm=0; for p=-1:1 for q=-1:1 if i+p>=1 & i+p<=nx & j+q>=1 & j+q<=ny & valid1(i+p,j+q)==1 nr=nr+1; um=um+U(i+p,j+q); vm=vm+V(i+p,j+q); end end end if nr>0 valid2(i,j)=1; U(i,j)=um/nr; V(i,j)=vm/nr; else valid2(i,j)=0; end end end
% U - horizontal particle image displacement% V - vertical particle image displacement% valid - validation index of the particle image displacement
Example of Matlab program for evaluating double exposed recording D001_1.bmp Main programclear;A=imread('D001_1.bmp'); % input image file G=img2xy(A); % convert image to gray value distribution
[nx ny]=size(G); % determine size of the imagerow=ny/Mg-1; % number of grid rows col=nx/Mg-1; % number of grid columns
for nn=1:NN % iteration begin M=(nn-1)*(M2-M1)/(NN-1)+M1; % determine window width N=(nn-1)*(N2-N1)/(NN-1)+N1; % determine window height sr=(nn-1)*(sr2-sr1)/(NN-1)+sr1; % determine search radius
if nn>1 [U V valid]=interpolation(U,V, valid); % interpolation for window shift [U V valid]=interpolation(U,V, valid); % interpolation for window shift end
Example of Matlab program for evaluating double exposed recording D001_1.bmp for i=1:col for j=1:row if nn==1 % determine window shift wsx=sr; wsy=0; else if valid(i,j)>0 wsx=U(i,j); wsy=V(i,j); if sr>int16(wsx) % adjust search radius for double exposed recording sr=int16(wsx); end end end x=i*Mg; % determine horizontal coordinate of interrogation point y=j*Ng; % determine vertical coordinate of interrogation point g1=sample3(G,M,N,x-wsx/2,y-wsy/2); % evaluation sample with backward wondow shift g2=sample3(G,M,N,x+wsx/2,y+wsy/2); % evaluation sample with forward wondow shift [C m n]=correlation(g1,g2); % claculating corraltion function [cm vx vy]=peaksearch(C,m,n,sr,0,0); % determine particle image displacement U(i,j)=vx+wsx; % adjust particle image displacement with window shift V(i,j)=vy+wsy; % adjust particle image displacement with window shift X(i,j)=x; % record evaluation coordinate Y(i,j)=y; % record evaluation coordinate end end
valid=errordetection(U,V,dU,dV); % detect evaluation errorsend % iteration end
Example of Matlab program for evaluating double exposed recording D001_1.bmp for i=1:col % remove evaluation errors for j=1:row if valid(i,j)==0 U(i,j)=0; V(i,j)=0; end endend quiver(X,Y,U,V);
Unsharp mask filter may be used for further improvement
Example of Matlab program for evaluating single exposed recording pair Main programclear;A1=imread('A001_1.bmp'); % input image file A2=imread('A001_2.bmp'); % input image file G1=img2xy(A1); % convert image to gray value distributionG2=img2xy(A2); % convert image to gray value distribution
[nx ny]=size(G1); % determine size of the imagerow=ny/Mg-1; % number of grid rows col=nx/Mg-1; % number of grid columns
for nn=1:NN % iteration begin sr=int16((nn-1)*(sr2-sr1)/(NN-1)+sr1); % determine search radius
if nn>1 [U V valid]=interpolation(U,V, valid); % interpolation for window shift [U V valid]=interpolation(U,V, valid); % interpolation for window shift end
Example of Matlab program for evaluating single exposed recording pair
for i=1:col for j=1:row if nn==1 % determine window shift wsx=0; wsy=0; else if valid(i,j)>0 wsx=U(i,j); wsy=V(i,j); end end x=i*Mg; % determine horizontal coordinate of interrogation point y=j*Ng; % determine vertical coordinate of interrogation point g1=sample3(G1,M,N,x-wsx/2,y-wsy/2); % evaluation sample with backward window shift g2=sample3(G2,M,N,x+wsx/2,y+wsy/2); % evaluation sample with forward window shift [C m n]=correlation(g1,g2); % calculating correlation function [cm vx vy]=peaksearch(C,m,n,sr,0,0); % determine particle image displacement U(i,j)=vx+wsx; % adjust particle image displacement with window shift V(i,j)=vy+wsy; % adjust particle image displacement with window shift X(i,j)=x; % record evaluation coordinate Y(i,j)=y; % record evaluation coordinate end end