See the post on LinkedIn by Stefano Brizzolara https://www.linkedin.com/posts/stefano-brizzolara-6a8501198_rheinfall-flowvisualization-ugcPost-6672832128742408192-lRub
from openpiv import tools, pyprocess, validation, filters, scaling
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import imageio
frame_a = tools.imread('../test8/frame0001.tif')
frame_b = tools.imread('../test8/frame0002.tif')
fig,ax = plt.subplots(1,2,figsize=(12,10))
ax[0].imshow(frame_a,cmap=plt.cm.gray)
ax[1].imshow(frame_b,cmap=plt.cm.gray)
<matplotlib.image.AxesImage at 0x7f758e295d60>
winsize = 12 # pixels
searchsize = 32 # pixels, search in image B
overlap = 6 # pixels
dt = 1./30 # sec, assume 30 fps
frame_a[:600,:] = 0 # basically masking out the non-illuminated region
frame_b[:600,:] = 0
u0, v0, sig2noise = pyprocess.extended_search_area_piv(frame_a.astype(np.int32),
frame_b.astype(np.int32),
window_size=winsize,
overlap=overlap, dt=dt,
search_area_size=searchsize,
sig2noise_method='peak2peak' )
/home/user/Downloads/repos/openpiv-python/openpiv/pyprocess.py:298: RuntimeWarning: invalid value encountered in double_scalars peak1_j + ((log(cd) - log(cu)) / (2 * log(cd) - 4 * log(c) + 2 * log(cu))), /home/user/Downloads/repos/openpiv-python/openpiv/pyprocess.py:297: RuntimeWarning: invalid value encountered in double_scalars peak1_i + ((log(cl) - log(cr)) / (2 * log(cl) - 4 * log(c) + 2 * log(cr))),
x, y = pyprocess.get_coordinates(frame_a.shape,searchsize, overlap)
u1, v1, mask = validation.sig2noise_val( u0, v0, sig2noise, threshold = 1.15)
u2, v2 = filters.replace_outliers( u1, v1, method='localmean', max_iter=10, kernel_size=2)
x, y, u3, v3 = scaling.uniform(x, y, u2, v2, scaling_factor = 1. )
tools.save(x, y, u3, v3, sig2noise, mask, 'exp1_001.txt' )
# tools.display_vector_field('exp1_001.txt', scaling_factor=100., width=0.0025)
# If you need a larger view:
fig, ax = plt.subplots(figsize=(12,12))
tools.display_vector_field('exp1_001.txt', ax=ax, scaling_factor=1.0,
scale=1000, width=0.0045, on_img=True,
image_name='~/Downloads/bridgepile_wake/frame0001.tif');