# 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 numpy.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, \
moving_window_array, \
fft_correlate_strided_images, \
find_subpixel_peak_position, \
normalize_intensity, \
get_field_shape
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 121 ms, sys: 8.58 ms, total: 130 ms Wall time: 129 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 164 ms, sys: 4.29 ms, total: 169 ms Wall time: 168 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 199 ms, sys: 39.9 ms, total: 238 ms Wall time: 237 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 201 ms, sys: 27.1 ms, total: 228 ms Wall time: 227 ms
plt.figure(figsize=(20,20))
plt.quiver(vel1[0],vel1[1],scale=100,color='b',alpha=0.2)
<matplotlib.quiver.Quiver at 0x7f8b2d9e46d0>