Skip to content

Commit

Permalink
Merge pull request #10 from alexlib/pyprocess_extended_search
Browse files Browse the repository at this point in the history
Pyprocess extended search
  • Loading branch information
alexlib committed Nov 17, 2016
2 parents fc49272 + 7421756 commit 71c2c7c
Show file tree
Hide file tree
Showing 13 changed files with 2,233 additions and 137 deletions.
23 changes: 0 additions & 23 deletions openpiv/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +0,0 @@
import os.path as _osp

# the root directory of the package when installed.
# this is an os independent trick to know where the
# package is installed, so we can access data files
# we have provided with the python module
__root__ = _osp.abspath(_osp.dirname(__file__))

# this is the location of the default parameters file
# which we have distributed with openpiv.
__default_config_file__ = _osp.join( __root__, 'data/defaults-processing-parameters.cfg' )


# import default modules
import openpiv.preprocess
import openpiv.tools
import openpiv.pyprocess
import openpiv.scaling
import openpiv.validation
import openpiv.filters
# import openpiv.ui
import openpiv.process
import openpiv.lib
Binary file added openpiv/examples/tutorial-part1/test001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added openpiv/examples/tutorial-part1/test002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 32 additions & 13 deletions openpiv/examples/tutorial-part1/tutorial-part1.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,43 @@
#!/usr/bin/env python
import sys
sys.path.append('/Users/alex/Documents/OpenPIV/openpiv-python')

import openpiv.tools
import openpiv.process
import openpiv.scaling
if 'OpenPIV' not in sys.path:
sys.path.append('/Users/alex/Documents/OpenPIV/alexlib/openpiv-python')

from openpiv import tools, validation, process, filters, scaling, pyprocess
import numpy as np

frame_a = openpiv.tools.imread( 'exp1_001_a.bmp' )
frame_b = openpiv.tools.imread( 'exp1_001_b.bmp' )
frame_a = tools.imread( 'exp1_001_a.bmp' )
frame_b = tools.imread( 'exp1_001_b.bmp' )

u, v, sig2noise = process.extended_search_area_piv( frame_a.astype(np.int32), frame_b.astype(np.int32), window_size=24, overlap=12, dt=0.02, search_area_size=64, sig2noise_method='peak2peak' )

x, y = process.get_coordinates( image_size=frame_a.shape, window_size=24, overlap=12 )

u, v, mask = validation.sig2noise_val( u, v, sig2noise, threshold = 1.3 )

u, v = filters.replace_outliers( u, v, method='localmean', max_iter=10, kernel_size=2)

x, y, u, v = scaling.uniform(x, y, u, v, scaling_factor = 96.52 )

tools.save(x, y, u, v, mask, 'exp1_001.txt' )

tools.display_vector_field('exp1_001.txt', scale=100, width=0.0025)



u, v, sig2noise = openpiv.process.extended_search_area_piv( frame_a.astype(np.int32), frame_b.astype(np.int32), window_size=24, overlap=12, dt=0.02, search_area_size=64, sig2noise_method='peak2peak' )
u1, v1, sig2noise = pyprocess.piv( frame_a.astype(np.int32),
frame_b.astype(np.int32),
window_size=24, overlap=12, dt=0.02, search_size=64, sig2noise_method='peak2peak' )

x, y = openpiv.process.get_coordinates( image_size=frame_a.shape, window_size=24, overlap=12 )
x, y = process.get_coordinates( image_size=frame_a.shape, window_size=24, overlap=12 )

u, v, mask = openpiv.validation.sig2noise_val( u, v, sig2noise, threshold = 1.3 )
u1, v1, mask = validation.sig2noise_val( u1, v1, sig2noise, threshold = 1.3 )

u, v = openpiv.filters.replace_outliers( u, v, method='localmean', max_iter=10, kernel_size=2)
u1, v1 = filters.replace_outliers( u1, v1, method='localmean', max_iter=10, kernel_size=2)

x, y, u, v = openpiv.scaling.uniform(x, y, u, v, scaling_factor = 96.52 )
x, y, u1, v1 = scaling.uniform(x, y, u1, v1, scaling_factor = 96.52 )

openpiv.tools.save(x, y, u, v, mask, 'exp1_001.txt' )
tools.save(x, y, u1, v1, mask, 'exp1_001_1.txt' )

openpiv.tools.display_vector_field('exp1_001.txt', scale=100, width=0.0025)
tools.display_vector_field('exp1_001_1.txt', scale=100, width=0.0025)
77 changes: 32 additions & 45 deletions openpiv/examples/tutorial-part1/tutorial-part2.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,44 @@
#!/usr/bin/env ipython
import sys
sys.path.append('/Users/alex/Documents/OpenPIV/openpiv-python')

import openpiv.tools
import openpiv.process
import openpiv.scaling
import numpy as np

frame_a = openpiv.tools.imread( 'exp1_001_a.bmp' )
frame_b = openpiv.tools.imread( 'exp1_001_b.bmp' )

u, v, sig2noise = openpiv.process.extended_search_area_piv( frame_a.astype(np.int32), frame_b.astype(np.int32), window_size=24, overlap=12, dt=0.02, search_area_size=64, sig2noise_method='peak2peak' )

x, y = openpiv.process.get_coordinates( image_size=frame_a.shape, window_size=24, overlap=12 )

u, v, mask = openpiv.validation.sig2noise_val( u, v, sig2noise, threshold = 2.5 )

u, v = openpiv.filters.replace_outliers( u, v, method='localmean', max_iter=10, kernel_size=2)

x, y, u, v = openpiv.scaling.uniform(x, y, u, v, scaling_factor = 96.52 )

openpiv.tools.save(x, y, u, v, mask, 'exp1_001.txt' )

openpiv.tools.display_vector_field('exp1_001.txt', scale=100, width=0.0025)

if 'OpenPIV' not in sys.path:
sys.path.append('/Users/alex/Documents/OpenPIV/alexlib/openpiv-python')

from openpiv import tools, validation, process, filters, scaling, pyprocess
import numpy as np

u, v= openpiv.pyprocess.piv( frame_a, frame_b, corr_method='fft', window_size=24, overlap=12, dt=0.02, sig2noise_method='peak2peak' )
x, y = openpiv.pyprocess.get_coordinates( image_size=frame_a.shape, window_size=24, overlap=12 )


u, v, mask = openpiv.validation.sig2noise_val( u, v, sig2noise, threshold = 2.5 )

u, v = openpiv.filters.replace_outliers( u, v, method='localmean', max_iter=10, kernel_size=2.5)

x, y, u, v = openpiv.scaling.uniform(x, y, u, v, scaling_factor = 96.52 )

openpiv.tools.save(x, y, u, v, mask, 'exp1_002.txt' )

openpiv.tools.display_vector_field('exp1_002.txt', scale=100, width=0.0025)


frame_a = tools.imread( 'exp1_001_a.bmp' )
frame_b = tools.imread( 'exp1_001_b.bmp' )

u, v, sig2noise = process.extended_search_area_piv( frame_a.astype(np.int32),
frame_b.astype(np.int32), window_size=24, overlap=12, dt=0.02, search_area_size=64,
sig2noise_method='peak2peak' )
x, y = process.get_coordinates( image_size=frame_a.shape, window_size=24, overlap=12 )
u, v, mask = validation.sig2noise_val( u, v, sig2noise, threshold = 2.5 )
u, v = filters.replace_outliers( u, v, method='localmean', max_iter=10, kernel_size=2)
x, y, u, v = scaling.uniform(x, y, u, v, scaling_factor = 96.52 )
tools.save(x, y, u, v, mask, 'exp1_001.txt' )
tools.display_vector_field('exp1_001.txt', scale=100, width=0.0025)

u, v= openpiv.pyprocess.piv( frame_a, frame_b, corr_method='direct', window_size=24, overlap=12, dt=0.02, sig2noise_method='peak2peak' )
x, y = openpiv.pyprocess.get_coordinates( image_size=frame_a.shape, window_size=24, overlap=12 )


u, v, mask = openpiv.validation.sig2noise_val( u, v, sig2noise, threshold = 2.5 )
u, v, s2n= pyprocess.piv(frame_a, frame_b, corr_method='fft', window_size=24, overlap=12,
dt=0.02, sig2noise_method='peak2peak' )
x, y = pyprocess.get_coordinates( image_size=frame_a.shape, window_size=24, overlap=12 )
u, v, mask = validation.sig2noise_val( u, v, s2n, threshold = 2.5 )
u, v = filters.replace_outliers( u, v, method='localmean', max_iter=10, kernel_size=2.5)
x, y, u, v = scaling.uniform(x, y, u, v, scaling_factor = 96.52 )
tools.save(x, y, u, v, mask, 'exp1_002.txt' )
tools.display_vector_field('exp1_002.txt', scale=100, width=0.0025)

u, v = openpiv.filters.replace_outliers( u, v, method='localmean', max_iter=10, kernel_size=2.5)

x, y, u, v = openpiv.scaling.uniform(x, y, u, v, scaling_factor = 96.52 )

openpiv.tools.save(x, y, u, v, mask, 'exp1_002.txt' )

openpiv.tools.display_vector_field('exp1_002.txt', scale=100, width=0.0025)
u,v,s2n = pyprocess.piv( frame_a, frame_b, corr_method='direct', window_size=24,
overlap=12, dt=0.02, sig2noise_method='peak2peak' )
x, y = pyprocess.get_coordinates( image_size=frame_a.shape, window_size=24, overlap=12 )
u, v, mask = validation.sig2noise_val( u, v, sig2noise, threshold = 2.5 )
u, v = filters.replace_outliers( u, v, method='localmean', max_iter=10, kernel_size=2.5)
x, y, u, v = scaling.uniform(x, y, u, v, scaling_factor = 96.52 )
tools.save(x, y, u, v, mask, 'exp1_002.txt' )
tools.display_vector_field('exp1_002.txt', scale=100, width=0.0025)
56 changes: 56 additions & 0 deletions openpiv/examples/tutorial-part1/tutorial-part2small.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env python
import sys

if 'OpenPIV' not in sys.path:
sys.path.append('/Users/alex/Documents/OpenPIV/alexlib/openpiv-python')

from openpiv import tools, validation, process, filters, scaling, pyprocess
import numpy as np
import matplotlib.pyplot as plt

frame_a = tools.imread('exp1_001_a.bmp')
frame_b = tools.imread('exp1_001_b.bmp' )


frame_a = frame_a[:128,:128]
frame_b = frame_b[:128,:128]

from pylab import *
imshow(np.c_[frame_a,frame_b],cmap=cm.gray)
show()


u, v, sig2noise = process.extended_search_area_piv(
frame_a.astype(np.int32),
frame_b.astype(np.int32),
window_size=24, overlap=12,
dt=0.02, search_area_size=32,
sig2noise_method='peak2peak' )

x, y = process.get_coordinates( image_size=frame_a.shape, window_size=24, overlap=12 )


plt.figure()
plt.quiver(x,y,u,v)
plt.show()


u, v, s2n = pyprocess.piv( frame_a, frame_b, corr_method='fft',
window_size=32, overlap=12, dt=0.02, sig2noise_method='peak2peak' )
x, y = pyprocess.get_coordinates( image_size=frame_a.shape, window_size=32, overlap=12 )

plt.figure()
plt.quiver(x,y,u,v)
plt.show()


u, v, s2n = pyprocess.piv( frame_a, frame_b, corr_method='direct',
window_size=24, overlap=12, dt=0.02,
sig2noise_method='peak2peak',
search_size = 32)
x, y = pyprocess.get_coordinates( image_size=frame_a.shape,
window_size=24, overlap=12 )

plt.figure()
plt.quiver(x,y,u,v)
plt.show()
58 changes: 58 additions & 0 deletions openpiv/examples/tutorial-part1/tutorial-part3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python
import sys

if 'OpenPIV' not in sys.path:
sys.path.append('/Users/alex/Documents/OpenPIV/alexlib/openpiv-python')

from openpiv import tools, process, pyprocess
import numpy as np
import matplotlib.pyplot as plt

from skimage.transform import resize
from skimage import img_as_ubyte


frame_a = tools.imread( 'test001.png')
frame_b = tools.imread( 'test002.png')


# frame_a = img_as_ubyte(resize(frame_a,(1024,256)))
# frame_b = img_as_ubyte(resize(frame_b,(1024,256)))

frame_a = frame_a[:512,-200:]
frame_b = frame_b[:512,-200:]

#frame_a = frame_a[:256,:]
#frame_b = frame_b[:256,:]

plt.figure()
plt.imshow(np.c_[frame_a,frame_b],cmap=plt.cm.gray)
plt.show()


u, v = process.extended_search_area_piv(frame_a.astype(np.int32),
frame_b.astype(np.int32), window_size=24, overlap=12, search_area_size=32, dt = 1.)

plt.figure()
plt.quiver(u,v)
plt.axis('equal')
plt.show()

u1, v1 = pyprocess.piv(frame_a, frame_b, window_size=32, search_size=48, overlap=24)

# x, y = process.get_coordinates( image_size=frame_a.shape, window_size=24, overlap=0)

plt.figure()
plt.quiver(u1,v1,v1)
plt.axis('equal')
plt.show()


u2, v2 = pyprocess.piv(frame_a, frame_b, corr_method = 'direct', window_size=32)

# x, y = process.get_coordinates( image_size=frame_a.shape, window_size=24, overlap=0)

plt.figure()
plt.quiver(u2,v2,v2)
plt.axis('equal')
plt.show()
232 changes: 232 additions & 0 deletions openpiv/examples/tutorial-part1/tutorial_part2.ipynb

Large diffs are not rendered by default.

254 changes: 254 additions & 0 deletions openpiv/examples/tutorial-part1/tutorial_part3.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 71c2c7c

Please sign in to comment.