0% found this document useful (0 votes)
42 views8 pages

ME597 - Particle Image Velocimetry: Submitted By: Karna Patel Homework: 4

This document summarizes the results of an image shifting algorithm experiment conducted for a particle image velocimetry homework assignment. It shows that the displacement error is minimized when the interrogation windows of two images exactly overlap, within a window size of 64 pixels. As the windows are shifted relative to each other in increments along a 45 degree line, the error fluctuates but remains low within the 64 pixel range before increasing again. Contour plots verify that the correlation function peak shifts correspondingly with the interrogation window positions.

Uploaded by

karna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views8 pages

ME597 - Particle Image Velocimetry: Submitted By: Karna Patel Homework: 4

This document summarizes the results of an image shifting algorithm experiment conducted for a particle image velocimetry homework assignment. It shows that the displacement error is minimized when the interrogation windows of two images exactly overlap, within a window size of 64 pixels. As the windows are shifted relative to each other in increments along a 45 degree line, the error fluctuates but remains low within the 64 pixel range before increasing again. Contour plots verify that the correlation function peak shifts correspondingly with the interrogation window positions.

Uploaded by

karna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

ME597 Particle Image Velocimetry

Submitted by: Karna Patel


Homework: 4

Problem: 1
Image Padding:

FFT Correlation Tracking Code:


%---------------------------------------------------------------% Correlation tracking algorithm with matrix padding
%---------------------------------------------------------------% skeleton routine to load image files into matrices
clear all
% clear all variables
% gui to select files
[filename1, pathname1] = uigetfile('*.bmp','Choose file 1');
[filename2, pathname2] = uigetfile('*.bmp','Choose file 2');
%load the images into variables
[x1,map]=imread(fullfile(pathname1,filename1));
[x2,map]=imread(fullfile(pathname2,filename2));
%convert uint8 variables to double precision variables so that
%they can be used for calculations
A=double(x1(480:544,480:544));
B=padarray(A,[32,32]); %Array padding
x1d2=B;
x2d2=double(x2(448:576,448:576));
tic

phi4=real(fftshift(ifft2(conj(fft2(x1d2,128,128)) .* fft2(x2d2,128,128))));
toc
figure(3)
mesh(phi4)
[irf, icf] = find(phi4 == max(phi4(:)));
x_star_num1 = log(phi4(irf+1,icf)) - log(phi4(irf-1,icf));
x_star_den1 = 4*log(phi4(irf,icf)) - 2*log(phi4(irf-1,icf)) 2*log(phi4(irf+1,icf));
x_star1 = x_star_num1/x_star_den1
y_star_num1 = log(phi4(irf,icf+1)) - log(phi4(irf,icf-1));
y_star_den1 = 4*log(phi4(irf,icf)) - 2*log(phi4(irf,icf-1)) 2*log(phi4(irf,icf+1));
y_star1 = y_star_num1/y_star_den1
xdisplace1 = irf - 64 + x_star1
ydisplace1 = icf - 64 + y_star1

Displacement:
X displacement: -3.6281
Y displacement: 4.2134

Calculation Time:
Elapsed time is 0.008654 seconds

Wire Mesh Plot:

Comparison with HW #3:

X displacement
Y displacement
Calculation time

Homework 3
-3.9541
4.8654
0.3215 sec.

Homework 4
-3.6281
4.2134
0.008654 sec.

Problem: 2
Image Shifting Algorithm:
%------------------------------------------------------------% Solution for problem 2 starts from here
%------------------------------------------------------------a1d2=double(x1(480:544,480:544));
a2d2=double(x2(480:544,480:544));
tic
phi4=real(fftshift(ifft2(conj(fft2(a1d2,64,64)) .* fft2(a2d2,64,64))));
toc
figure(4)
mesh(phi4)
[irf, icf] = find(phi4 == max(phi4(:)));
x_star_num1 = log(phi4(irf+1,icf)) - log(phi4(irf-1,icf));
x_star_den1 = 4*log(phi4(irf,icf)) - 2*log(phi4(irf-1,icf)) 2*log(phi4(irf+1,icf));
x_star1 = x_star_num1/x_star_den1
y_star_num1 = log(phi4(irf,icf+1)) - log(phi4(irf,icf-1));
y_star_den1 = 4*log(phi4(irf,icf)) - 2*log(phi4(irf,icf-1)) 2*log(phi4(irf,icf+1));
y_star1 = y_star_num1/y_star_den1
xa_displace1 = irf - 32 + x_star1
ya_displace1 = icf - 32 + y_star1
b1d2=double(x1(480:544,480:544));
%window 1 will remain the same
b2d2=double(x2(544:608,544:608));
%window 2 will shift one step
upward
tic
phi4=real(fftshift(ifft2(conj(fft2(b1d2,64,64)) .* fft2(b2d2,64,64))));
toc
figure(5)
mesh(phi4)
[irf, icf] = find(phi4 == max(phi4(:)));
x_star_num1 = log(phi4(irf+1,icf)) - log(phi4(irf-1,icf));
x_star_den1 = 4*log(phi4(irf,icf)) - 2*log(phi4(irf-1,icf)) 2*log(phi4(irf+1,icf));
x_star1 = x_star_num1/x_star_den1
y_star_num1 = log(phi4(irf,icf+1)) - log(phi4(irf,icf-1));
y_star_den1 = 4*log(phi4(irf,icf)) - 2*log(phi4(irf,icf-1)) 2*log(phi4(irf,icf+1));
y_star1 = y_star_num1/y_star_den1
xb_displace1 = irf - 32 + x_star1
yb_displace1 = icf - 32 + y_star1
c1d2=double(x1(480:544,480:544));
%window 1 will remain the same

c2d2=double(x2(608:672,608:672));
%window 2 will shift one step
upward
tic
phi4=real(fftshift(ifft2(conj(fft2(c1d2,64,64)) .* fft2(c2d2,64,64))));
toc
figure(6)
mesh(phi4)
[irf, icf] = find(phi4 == max(phi4(:)));
x_star_num1 = log(phi4(irf+1,icf)) - log(phi4(irf-1,icf));
x_star_den1 = 4*log(phi4(irf,icf)) - 2*log(phi4(irf-1,icf)) 2*log(phi4(irf+1,icf));
x_star1 = x_star_num1/x_star_den1
y_star_num1 = log(phi4(irf,icf+1)) - log(phi4(irf,icf-1));
y_star_den1 = 4*log(phi4(irf,icf)) - 2*log(phi4(irf,icf-1)) 2*log(phi4(irf,icf+1));
y_star1 = y_star_num1/y_star_den1
xc_displace1 = irf - 32 + x_star1
yc_displace1 = icf - 32 + y_star1
k1d2=double(x1(480:544,480:544));
%window 1 will remain the same
k2d2=double(x2(416:480,416:480));
%window 2 will shift one step
downward
tic
phi4=real(fftshift(ifft2(conj(fft2(k1d2,64,64)) .* fft2(k2d2,64,64))));
toc
figure(7)
mesh(phi4)
[irf, icf] = find(phi4 == max(phi4(:)));
x_star_num1 = log(phi4(irf+1,icf)) - log(phi4(irf-1,icf));
x_star_den1 = 4*log(phi4(irf,icf)) - 2*log(phi4(irf-1,icf)) 2*log(phi4(irf+1,icf));
x_star1 = x_star_num1/x_star_den1
y_star_num1 = log(phi4(irf,icf+1)) - log(phi4(irf,icf-1));
y_star_den1 = 4*log(phi4(irf,icf)) - 2*log(phi4(irf,icf-1)) 2*log(phi4(irf,icf+1));
y_star1 = y_star_num1/y_star_den1
xk_displace1 = irf - 32 + x_star1
yk_displace1 = icf - 32 + y_star1
l1d2=double(x1(480:544,480:544));
%window 1 will remain steady
l2d2=double(x2(416:480,416:480));
%window 2 will shift one step
downward
tic
phi4=real(fftshift(ifft2(conj(fft2(l1d2,64,64)) .* fft2(l2d2,64,64))));
toc
figure(8)
mesh(phi4)
[irf, icf] = find(phi4 == max(phi4(:)));
x_star_num1 = log(phi4(irf+1,icf)) - log(phi4(irf-1,icf));
x_star_den1 = 4*log(phi4(irf,icf)) - 2*log(phi4(irf-1,icf)) 2*log(phi4(irf+1,icf));
x_star1 = x_star_num1/x_star_den1
y_star_num1 = log(phi4(irf,icf+1)) - log(phi4(irf,icf-1));
y_star_den1 = 4*log(phi4(irf,icf)) - 2*log(phi4(irf,icf-1)) 2*log(phi4(irf,icf+1));
y_star1 = y_star_num1/y_star_den1
xl_displace1 = irf - 32 + x_star1
yl_displace1 = icf - 32 + y_star1
x_known = -3.70
%Known x displacement
y_known = 4.31
%Known y displacement
RMS_error_1 = ((xa-x_known)^2 - (ya-y_known)^2)^0.5
%RMS error for
superimpose case

RMS_error_2 = ((xb-x_known)^2 - (yb-y_known)^2)^0.5


%RMS error for
first upper square
RMS_error_3 = ((xc-x_known)^2 - (yc-y_known)^2)^0.5
%RMS error for
second upper square
RMS_error_4 = ((xk-x_known)^2 - (yk-y_known)^2)^0.5
%RMS error for
first lower square
RMS_error_5 = ((xl-x_known)^2 - (yl-y_known)^2)^0.5
%RMS error for
second lower square
%plot error of error of displacement as a function of a window shift
plot(RMS_error, window_shift)
% plot RMS_error VS window_shift line graph

Plot: Error of displacement VS Image shift

- Sudden decrement in the displacement error will remain


till the span of 64 pixels. This is the position at which
interrogation window 1 and interrogation window 2 will try
to superimpose.
- Apart from these 64 pixels, RMS error value will fluctuate
in the positive and negative Y direction. This is the positon
at which interrogation window 1 and interrogation window
2 will not superimpose.

Contour Plots:
- As shown in the below image, we put interrogation
window 1 fix throughout the calculation.

- Interrogation

window 2 will change its position


throughout the calculation.
- Movement of interrogation window 2 is guided by the
line drawn at +45 degree with the +x direction.

Graphical Representation and Contour plots:

- As we can see in the above image red frame in the first


interrogation window which will remain fix throughout
the calculation
- Yellow-orange windows are the special cases for the
image shift.
- Notice that this all windows lies on the straight line
making +45 angle with the positive X direction.
- In the below figure, middle contour plot depicts that our
correlation function exist at the middle of the 64 by 64
plane.
- A close look will reveal that as we go upward, our
correlation function position will also move upward. This
could be prove by the first counter plot where

correlation function is slightly move towards upper side


because our second interrogation window is at that
place.

- Further scrutinize will reveal that in the last contour


plot, correlation function is moved slightly toward lower
side because our second interrogation window is
moving from upward to downward direction.
- Upon examination of this direct implementation of the
cross-correlation function two things are obvious: first,
the number of multiplications per correlation value
increases in proportion to the interrogation window (or
sample) area, and second, the cross-correlation method
inherently recovers linear shifts only.
- No rotations or deformations can be recovered by this
first order method. Therefore, the cross-correlation
between two particle image samples will only yield the
displacement vector to first order, that is, the average
linear shift of the particles within the interrogation
window.
- This means that the interrogation window size should
be chosen sufficiently small such that the second order
effects (i.e. displacement gradients) can be neglected.

You might also like