fill_holes_and_remove_small_masks#
- omnipose.core.fill_holes_and_remove_small_masks(masks, min_size=None, max_size=None, hole_size=3, dim=2)[source]#
fill holes in masks (2D/3D) and discard masks smaller than min_size (2D)
fill holes in each mask using scipy.ndimage.morphology.binary_fill_holes
- Parameters
masks (int, 2D or 3D array) -- labelled masks, 0=NO masks; 1,2,...=mask labels, size [Ly x Lx] or [Lz x Ly x Lx]
min_size (int (optional, default 3**dim)) -- minimum number of pixels per mask (exclusive), can turn off with -1
max_size (int (optional, default None)) -- maximum number of pixels per mask (exclusive)
hole_size (int (optional, default 3)) -- holes bigger than this are NOT filled
dim (int (optional, default 2)) -- dimension of the masks
- Returns
masks -- masks with holes filled and masks smaller than min_size removed, 0=NO masks; 1,2,...=mask labels, size [Ly x Lx] or [Lz x Ly x Lx]
- Return type
int, 2D or 3D array