Skip to content

deprecation of remove_small_objects min_size arg does not preserve original behavior #8001

@jmuhlich

Description

@jmuhlich

Description:

With the deprecation of the min_size argument to remove_small_objects in 0.26, the behavior when passing min_size is now different than before. My expectation is that deprecation preserves the existing behavior (until the functionality is removed completely of course).

The arg deprecation is handled by deprecate_parameter, but this helper seems to be intended just for parameter renaming, not changes in the interpretation of the value. It forcibly overwrites the "old" arg name with DEPRECATED, preventing the backwards-compatibility logic in remove_small_objects from being able to tell when the old name is used. min_size is always DEPRECATED at this point so this check is never true:

if min_size is not DEPRECATED:
# Exclusive threshold is deprecated behavior
too_small = component_sizes < min_size

I guess deprecate_parameter needs a way to prevent overwriting the old arg name if the function itself wants to handle things.

Way to reproduce:

import numpy as np
from skimage.morphology import remove_small_objects

img = np.array([[1, 2, 2]])
# Remove all objects strictly smaller than size 2
res = remove_small_objects(img, 2)
print(res)
# 0.25: [[0 2 2]] (correct)
# 0.26: [[0 0 0]] (wrong, this is the result of max_size=2)

Version information:

3.12.3 (main, Nov  6 2025, 13:44:16) [GCC 13.3.0]
Linux-6.8.0-64-generic-x86_64-with-glibc2.39
scikit-image version: 0.26.0
numpy version: 2.4.0

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions