Multiple Masks

62 views
Skip to first unread message

Gerardo Pradillo Macias

unread,
May 19, 2021, 12:56:06 PM5/19/21
to openpi...@googlegroups.com
Dear group,

I hope you are all doing well.
I don't know if i have missed this in a previous email, but I was wondering if there is a way that multiple masks can be added . In my specific case, I am studying the infamous cross-slot geometry and I am trying to remove the corners (white regions of the attached image).
Let me know what you think.

Kind regards,

--
Gerardo E. Pradillo Macias
Postdoctoral Fellow
Georgetown University
mask_cross2.tif

alex.l...@gmail.com

unread,
May 19, 2021, 4:44:01 PM5/19/21
to openpiv-users
It's rather easy to apply your image as a mask image 

test_directory = '../test_mask/'
img = rgb2gray(io.imread(os.path.join(test_directory, "mask_cross2.tif")))
img1, mask = preprocess.dynamic_masking(img_as_float(img), method="intensity")
mask_coords = preprocess.mask_coordinates(mask,1.5,3, plot=True)

I get

masked_cross.png

You could follow the procedure in this notebook 

or use `windef.py` with the `image_mask = True` as in this notebook

or simply use the line on all the frames: 

`a1, mask = preprocess.dynamic_masking(img_as_float(a), method="intensity")`
`b1, mask = preprocess.dynamic_masking(img_as_float(b), method="intensity")`

to every image and working on `a1` rather than `a`, i.e. `extended_piv_process(a1,b1)`

If you send two PIV images - I'd make a small tutorial notebook that shows these options. 

Alex 

alex.l...@gmail.com

unread,
May 19, 2021, 4:48:24 PM5/19/21
to openpiv-users
Basically, there are two approaches to masking (as far as I know):
a) apply the mask as an image, i.e. blackout all the regions that are "masked" in both frame A and frame B - in this case, openpiv would spend some time on the interrogation windows in those "masked" or "completely black" regions but would generate NaNs there as there is no motion. 
b) learn the mask as a polygon and mask out the regions that should not be processed using the `points_in_poly` approach. 

The method a) is more flexible in terms of the shape of the mask and number of regions to be masked, curvature, etc. it's computationally more expansive of course. The method b) is limited to the "polygon" type of regions and the curvature that can be represented. 

Regards
Reply all
Reply to author
Forward
0 new messages