Warn users of remove_small_objects about type

When input type is `int`, we assume that the image is pre-labeled.
However, when only 0 and 1 are present, it may be that the user expects
us to treat it as a binary image. We don't, but now issue a warning
that they might want to use a bool image.

Fixes #1178.
This commit is contained in:
Juan Nunez-Iglesias
2014-09-30 14:51:00 +10:00
parent d0fb18fded
commit a2def31fca
+5
View File
@@ -1,5 +1,6 @@
import numpy as np
import functools
import warnings
import scipy.ndimage as nd
from .selem import _default_selem
@@ -128,6 +129,10 @@ def remove_small_objects(ar, min_size=64, connectivity=1, in_place=False):
"relabeling the input with `scipy.ndimage.label` or "
"`skimage.morphology.label`.")
if len(component_sizes) == 2:
warnings.warn("Only one label was provided to `remove_small_objects`. "
"Did you mean to use a boolean array?")
too_small = component_sizes < min_size
too_small_mask = too_small[ccs]
out[too_small_mask] = 0