{ } Raw JSON

bundles / skimage latest / skimage / morphology / misc / remove_small_holes

function

skimage.morphology.misc:remove_small_holes

source: /dev/scikit-image/src/skimage/morphology/misc.py :154

Signature

def   remove_small_holes ( ar area_threshold = <DEPRECATED> connectivity = 1 * max_size = 63 out = None )

Summary

Remove contiguous holes smaller than the specified size.

Parameters

ar : ndarray (arbitrary shape, int or bool type)

The array containing the connected components of interest.

max_size : int, optional

Remove holes whose contiguous area (or volume, in N-D) contains this number of pixels or fewer.

connectivity : int, {1, 2, ..., ar.ndim}, optional (default: 1)

The connectivity defining the neighborhood of a pixel.

out : ndarray

Array of the same shape as ar and bool dtype, into which the output is placed. By default, a new array is created.

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.

Other Parameters

area_threshold : DEPRECATED

Deprecated in favor of max_size.

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, max_size=1)
b
c = morphology.remove_small_holes(a, max_size=1, connectivity=2)
c
d = morphology.remove_small_holes(a, max_size=1, out=a)
d is a

See also

skimage.morphology.remove_objects_by_distance
skimage.morphology.remove_small_objects

Aliases

  • skimage.morphology.remove_small_holes

Referenced by