mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-06 05:16:40 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user