remove_small_holes
-
skimage.morphology.remove_small_holes(ar, min_size=64, connectivity=1, in_place=False)
[source] -
Remove continguous holes smaller than the specified size.
Parameters: ar : ndarray (arbitrary shape, int or bool type)
The array containing the connected components of interest.
min_size : int, optional (default: 64)
The hole component size.
connectivity : int, {1, 2, ..., ar.ndim}, optional (default: 1)
The connectivity defining the neighborhood of a pixel.
in_place : bool, optional (default: False)
If
True
, remove the connected components in the input array itself. Otherwise, make a copy.Returns: out : ndarray, same shape and type as input
ar
The input array with small holes within connected components removed.
Raises: TypeError
If the input array is of an invalid type, such as float or string.
ValueError
If the input array contains negative values.
Notes
If the array type is int, it is assumed that it contains already-labeled objects. The labels are not kept in the output image (this function always outputs a bool image). It is suggested that labeling is completed after using this function.
Examples
>>> from skimage import morphology >>> a = np.array([[1, 1, 1, 1, 1, 0], ... [1, 1, 1, 0, 1, 0], ... [1, 0, 0, 1, 1, 0], ... [1, 1, 1, 1, 1, 0]], bool) >>> b = morphology.remove_small_holes(a, 2) >>> b array([[ True, True, True, True, True, False], [ True, True, True, True, True, False], [ True, False, False, True, True, False], [ True, True, True, True, True, False]], dtype=bool) >>> c = morphology.remove_small_holes(a, 2, connectivity=2) >>> c array([[ True, True, True, True, True, False], [ True, True, True, False, True, False], [ True, False, False, True, True, False], [ True, True, True, True, True, False]], dtype=bool) >>> d = morphology.remove_small_holes(a, 2, in_place=True) >>> d is a True
Please login to continue.