Rename function to remove_small_objects

This commit is contained in:
Juan Nunez-Iglesias
2013-03-03 20:47:02 +11:00
parent d6c5ba38ef
commit b07f7fd9bd
3 changed files with 7 additions and 8 deletions
+1 -1
View File
@@ -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 -2
View File
@@ -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
+5 -5
View File
@@ -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()