diff --git a/skimage/morphology/misc.py b/skimage/morphology/misc.py index 159a3a3b..81f47e9c 100644 --- a/skimage/morphology/misc.py +++ b/skimage/morphology/misc.py @@ -21,6 +21,28 @@ def remove_small_connected_components(ar, min_size=64, ------- out : ndarray, same shape and type as input `ar` The input array with small connected components removed. + + Examples + -------- + >>> import numpy as np + >>> from skimage import morphology + >>> from scipy import ndimage as nd + >>> a = np.array([[0, 0, 0, 1, 0], + ... [1, 1, 1, 0, 0], + ... [1, 1, 1, 0, 1]], bool) + >>> b = morphology.remove_small_connected_components(a, 6) + >>> b + array([[False, False, False, False, False], + [ True, True, True, False, False], + [ True, True, True, False, False]], dtype=bool) + >>> c = morphology.remove_small_connected_components(a, 7, connectivity=2) + >>> c + array([[False, False, False, True, False], + [ True, True, True, False, False], + [ True, True, True, False, False]], dtype=bool) + >>> d = morphology.remove_small_connected_components(a, 6, in_place=True) + >>> d is a + True """ structuring_element = nd.generate_binary_structure(ar.ndim, connectivity) if in_place: