# testing extended search area piv from pyprocess
# this won't show any difference since 0.23 version
# because we incorporate the extended_seach_piv
#
import numpy as np
from scipy.fft import rfft2, irfft2, fftshift
from numpy import log
import matplotlib.pyplot as plt
from openpiv.tools import imread
from openpiv.pyprocess import extended_search_area_piv, normalize_intensity
frame_a = imread('../test1/exp1_001_a.bmp')
frame_b = imread('../test1/exp1_001_b.bmp')
# frame_a = frame_a[:128,:64]
# frame_b = frame_b[:128,:64]
def show_pair(I,J):
fig, ax = plt.subplots(1,2,figsize=(12,8))
ax[0].imshow(I,cmap=plt.cm.gray)
ax[1].imshow(J,cmap=plt.cm.gray)
show_pair(frame_a, frame_b)
frame_a = normalize_intensity(frame_a)
frame_b = normalize_intensity(frame_b)
show_pair(frame_a, frame_b)
window_size = 32
overlap = 16
dt=1.0
search_area_size = 32
correlation_method="circular"
subpixel_method="gaussian"
sig2noise_method='peak2peak'
%%time
vel1 = extended_search_area_piv(frame_a, frame_b, window_size=window_size,
search_area_size=search_area_size, overlap=overlap,dt=dt,
correlation_method='circular',
subpixel_method=subpixel_method,
sig2noise_method=sig2noise_method)
CPU times: user 112 ms, sys: 6.59 ms, total: 119 ms Wall time: 118 ms
%%time
window_size = 24
search_area_size = 32
vel2 = extended_search_area_piv(frame_a, frame_b, window_size=window_size,
search_area_size=search_area_size, overlap=overlap,dt=dt,
correlation_method='circular',
normalized_correlation=True,
subpixel_method=subpixel_method,
sig2noise_method=sig2noise_method)
CPU times: user 118 ms, sys: 13 ms, total: 131 ms Wall time: 130 ms
%%time
window_size = 24
search_area_size = 32
vel2 = extended_search_area_piv(frame_a, frame_b, window_size=window_size,
search_area_size=search_area_size, overlap=overlap,dt=dt,
correlation_method='linear',
subpixel_method=subpixel_method,
sig2noise_method=sig2noise_method)
CPU times: user 160 ms, sys: 26.7 ms, total: 187 ms Wall time: 186 ms
%%time
window_size = 24
search_area_size = 32
vel2 = extended_search_area_piv(frame_a, frame_b, window_size=window_size,
search_area_size=search_area_size, overlap=overlap,dt=dt,
correlation_method='linear',
normalized_correlation=True,
subpixel_method=subpixel_method,
sig2noise_method=sig2noise_method)
CPU times: user 186 ms, sys: 1 ms, total: 187 ms Wall time: 185 ms
plt.figure(figsize=(20,20))
plt.quiver(vel1[0],-vel1[1],scale=100,color='b',alpha=0.5)
<matplotlib.quiver.Quiver at 0x7fc6da912670>