|
1 | | -# -*- coding: utf-8 -*- |
2 | | -# <nbformat>3.0</nbformat> |
3 | | - |
4 | | -# <codecell> |
5 | | - |
| 1 | +import numpy as np |
6 | 2 | import openpiv.tools |
7 | 3 | import openpiv.process |
8 | 4 | import openpiv.scaling |
9 | 5 | import openpiv.preprocess |
| 6 | +import openpiv.validation |
| 7 | +import openpiv.filters |
10 | 8 | from skimage import io |
| 9 | +from skimage.io import imshow |
11 | 10 |
|
12 | | -# %pylab inline |
13 | | - |
14 | | -# <codecell> |
15 | 11 |
|
16 | 12 | file_a = 'Camera1-0101.tif' |
17 | 13 | file_b = 'Camera1-0102.tif' |
|
20 | 16 | im_b = io.imread( file_b ) |
21 | 17 | imshow(np.c_[im_a,im_b],cmap='gray') |
22 | 18 |
|
23 | | -# <codecell> |
24 | | - |
25 | 19 | # let's crop the region of interest |
26 | 20 | frame_a = im_a[380:1980,0:1390] |
27 | 21 | frame_b = im_b[380:1980,0:1390] |
28 | 22 | imshow(np.c_[frame_a,frame_b],cmap='gray') |
29 | 23 |
|
30 | | -# <codecell> |
31 | | - |
32 | 24 | # Process the original cropped image and see the OpenPIV result: |
33 | 25 |
|
34 | 26 | # typical parameters: |
|
54 | 46 | openpiv.tools.save(x, y, u, v, mask, 'test.txt', fmt='%9.6f', delimiter='\t') |
55 | 47 | openpiv.tools.display_vector_field('test.txt', scale=50, width=0.002) |
56 | 48 |
|
57 | | -# <codecell> |
| 49 | + |
58 | 50 |
|
59 | 51 | # masking using not optimal choice of the methods or parameters: |
60 | 52 | masked_a = openpiv.preprocess.dynamic_masking(frame_a,method='edges',filter_size=7,threshold=0.005) |
61 | 53 | masked_b = openpiv.preprocess.dynamic_masking(frame_b,method='intensity',filter_size=3,threshold=0.0) |
62 | 54 | imshow(np.c_[masked_a,masked_b],cmap='gray') |
63 | 55 |
|
64 | | -# <codecell> |
| 56 | + |
65 | 57 |
|
66 | 58 | # masking using optimal (manually tuned) set of parameters and the right method: |
67 | 59 | masked_a = openpiv.preprocess.dynamic_masking(frame_a,method='edges',filter_size=7,threshold=0.01) |
68 | 60 | masked_b = openpiv.preprocess.dynamic_masking(frame_b,method='edges',filter_size=7,threshold=0.01) |
69 | 61 | imshow(np.c_[masked_a,masked_b],cmap='gray') |
70 | 62 |
|
71 | | -# <codecell> |
| 63 | + |
72 | 64 |
|
73 | 65 | # Process the masked cropped image and see the OpenPIV result: |
74 | 66 |
|
|
0 commit comments