Skip to content

Commit f6be4b8

Browse files
authored
Update masking_tutorial.py
1 parent b7c3d69 commit f6be4b8

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

openpiv/examples/masking_tutorial/masking_tutorial.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
# -*- coding: utf-8 -*-
2-
# <nbformat>3.0</nbformat>
3-
4-
# <codecell>
5-
1+
import numpy as np
62
import openpiv.tools
73
import openpiv.process
84
import openpiv.scaling
95
import openpiv.preprocess
6+
import openpiv.validation
7+
import openpiv.filters
108
from skimage import io
9+
from skimage.io import imshow
1110

12-
# %pylab inline
13-
14-
# <codecell>
1511

1612
file_a = 'Camera1-0101.tif'
1713
file_b = 'Camera1-0102.tif'
@@ -20,15 +16,11 @@
2016
im_b = io.imread( file_b )
2117
imshow(np.c_[im_a,im_b],cmap='gray')
2218

23-
# <codecell>
24-
2519
# let's crop the region of interest
2620
frame_a = im_a[380:1980,0:1390]
2721
frame_b = im_b[380:1980,0:1390]
2822
imshow(np.c_[frame_a,frame_b],cmap='gray')
2923

30-
# <codecell>
31-
3224
# Process the original cropped image and see the OpenPIV result:
3325

3426
# typical parameters:
@@ -54,21 +46,21 @@
5446
openpiv.tools.save(x, y, u, v, mask, 'test.txt', fmt='%9.6f', delimiter='\t')
5547
openpiv.tools.display_vector_field('test.txt', scale=50, width=0.002)
5648

57-
# <codecell>
49+
5850

5951
# masking using not optimal choice of the methods or parameters:
6052
masked_a = openpiv.preprocess.dynamic_masking(frame_a,method='edges',filter_size=7,threshold=0.005)
6153
masked_b = openpiv.preprocess.dynamic_masking(frame_b,method='intensity',filter_size=3,threshold=0.0)
6254
imshow(np.c_[masked_a,masked_b],cmap='gray')
6355

64-
# <codecell>
56+
6557

6658
# masking using optimal (manually tuned) set of parameters and the right method:
6759
masked_a = openpiv.preprocess.dynamic_masking(frame_a,method='edges',filter_size=7,threshold=0.01)
6860
masked_b = openpiv.preprocess.dynamic_masking(frame_b,method='edges',filter_size=7,threshold=0.01)
6961
imshow(np.c_[masked_a,masked_b],cmap='gray')
7062

71-
# <codecell>
63+
7264

7365
# Process the masked cropped image and see the OpenPIV result:
7466

0 commit comments

Comments
 (0)