mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-30 02:56:19 +08:00
Rename function to remove_small_objects
This commit is contained in:
@@ -7,4 +7,4 @@ from .watershed import watershed, is_local_maximum
|
||||
from ._skeletonize import skeletonize, medial_axis
|
||||
from .convex_hull import convex_hull_image
|
||||
from .greyreconstruct import reconstruction
|
||||
from .misc import remove_small_connected_components
|
||||
from .misc import remove_small_objects
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import numpy as np
|
||||
import scipy.ndimage as nd
|
||||
|
||||
def remove_small_connected_components(ar, min_size=64,
|
||||
connectivity=1, in_place=False):
|
||||
def remove_small_objects(ar, min_size=64, connectivity=1, in_place=False):
|
||||
"""Remove connected components smaller than the specified size.
|
||||
|
||||
Parameters
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import numpy as np
|
||||
from numpy.testing import assert_array_equal, assert_equal
|
||||
from skimage.morphology import remove_small_connected_components
|
||||
from skimage.morphology import remove_small_objects
|
||||
|
||||
test_image = np.array([[0, 0, 0, 1, 0],
|
||||
[1, 1, 1, 0, 0],
|
||||
@@ -9,22 +9,22 @@ def test_one_connectivity():
|
||||
expected = np.array([[0, 0, 0, 0, 0],
|
||||
[1, 1, 1, 0, 0],
|
||||
[1, 1, 1, 0, 0]], bool)
|
||||
observed = remove_small_connected_components(test_image, min_size=6)
|
||||
observed = remove_small_objects(test_image, min_size=6)
|
||||
assert_array_equal(observed, expected)
|
||||
|
||||
def test_two_connectivity():
|
||||
expected = np.array([[0, 0, 0, 1, 0],
|
||||
[1, 1, 1, 0, 0],
|
||||
[1, 1, 1, 0, 0]], bool)
|
||||
observed = remove_small_connected_components(test_image, min_size=7,
|
||||
observed = remove_small_objects(test_image, min_size=7,
|
||||
connectivity=2)
|
||||
assert_array_equal(observed, expected)
|
||||
|
||||
def test_in_place():
|
||||
observed = remove_small_connected_components(test_image, min_size=6,
|
||||
observed = remove_small_objects(test_image, min_size=6,
|
||||
in_place=True)
|
||||
assert_equal(observed is test_image, True,
|
||||
"remove_small_connected_components in_place argument failed.")
|
||||
"remove_small_objects in_place argument failed.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
np.testing.run_module_suite()
|
||||
|
||||
Reference in New Issue
Block a user