Apply Mask

Apply binary mask to an image.

plantcv.apply_mask(img, mask, mask_color)

returns masked image

Original RGB image

Screenshot

Mask image

Screenshot


from plantcv import plantcv as pcv

# Set global debug behavior to None (default), "print" (to file), 
# or "plot" (Jupyter Notebooks or X11)

pcv.params.debug = "plot"

# Apply binary 'white' mask over an image. 
masked_image = pcv.apply_mask(img=img, mask=mask, mask_color='white')

White-masked image

Screenshot


from plantcv import plantcv as pcv

# Set global debug behavior to None (default), "print" (to file), 
# or "plot" (Jupyter Notebooks or X11)

pcv.params.debug = "plot"

# Apply binary 'black' mask over an image.
masked_image = pcv.apply_mask(img=img, mask=mask, mask_color='black')

Black-masked image

Screenshot

Source Code: Here