Masking routines.
Functions:
|
Convert an array from one 'mask' convention to another. |
|
Perform convention change of sequence of masks |
|
Convert labels array to list of masks |
|
Convert list of masks to labels |
- lnpy.core.mask.mask_change_convention(mask, convention_in='image', convention_out='masked')[source]#
Convert an array from one ‘mask’ convention to another.
- Parameters:
convention_in, convention_out (
stringorbool) – Convention for input and output. Convention for mask. Allowable values are:'image' ``or ``True: True values included, False values excluded. This is the normal convention inscipy.ndimage.'masked'orFalse: False values are included, True values are excluded. This is the convention innumpy.ma
- Returns:
ndarray– New ‘mask’ array with specified convention.
- lnpy.core.mask.masks_change_convention(masks, convention_in='image', convention_out='masked')[source]#
Perform convention change of sequence of masks
- Parameters:
masks (sequence of array-like) – masks[i] is the ‘ith’ mask
convention_in, convention_out (
stringorboolorNone) – Convention for input and output. Convention for mask. Allowable values are:‘image’ or True : True values included, False values excluded. This is the normal convention in
scipy.ndimage.‘masked’ or False: False values are included, True values are excluded. This is the convention in
numpy.ma
If None, then pass return input mask
- Returns:
new_masks (
listofndarray) – New ‘masks’ array with specified convention.
- lnpy.core.mask.labels_to_masks(labels, features=None, include_boundary=False, convention='image', check_features=True, **kwargs)[source]#
Convert labels array to list of masks
- Parameters:
labels (
ndarrayofint) – Each unique value i in labels indicates a mask. That islabels == i.features (sequence of
int) – If specified, extract only those locations wherelabels == featurefor all valuesfeature in features. That is, select a subset of unique label values.include_boundary (
bool) – if True, include boundary regions in output maskconvention (
stringorbool) – Convention for mask. Allowable values are:- ‘image’ or TrueTrue values included, False values excluded.
This is the normal convention in
scipy.ndimage.
- ‘masked’ or False: False values are included, True values are excluded.
This is the convention in
numpy.ma
check_features (
bool) – if True, then make sure each feature is in labels**kwargs – arguments to find_boundary if include_boundary is True default to mode=’outer’, connectivity=labels.ndim
- Returns:
- lnpy.core.mask.masks_to_labels(masks, features=None, convention='image', dtype=<class 'numpy.int64'>)[source]#
Convert list of masks to labels
- Parameters:
masks (
listof array-like ofbool) – list of mask arrays.features (sequence of
int) – If specified, extract only those locations wherelabels == featurefor all valuesfeature in features. That is, select a subset of unique label values.convention (
stringorbool) – Convention for mask. Allowable values are:- ‘image’ or TrueTrue values included, False values excluded.
This is the normal convention in
scipy.ndimage.
- ‘masked’ or False: False values are included, True values are excluded.
This is the convention in
numpy.ma
- Returns:
ndarray– Label array.
See also