mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-28 21:12:29 +08:00
Fix imports and suppress deprecation warnings
This commit is contained in:
@@ -4,8 +4,9 @@ from math import sqrt, atan2, pi as PI
|
||||
import numpy as np
|
||||
from scipy import ndimage
|
||||
|
||||
from skimage.morphology import convex_hull_image, label
|
||||
from skimage.measure import _moments
|
||||
from skimage.morphology import convex_hull_image
|
||||
from ._ccomp import label
|
||||
from . import _moments
|
||||
|
||||
|
||||
__all__ = ['regionprops', 'perimeter']
|
||||
|
||||
@@ -3,7 +3,7 @@ __all__ = ['convex_hull_image', 'convex_hull_object']
|
||||
import numpy as np
|
||||
from ._pnpoly import grid_points_inside_poly
|
||||
from ._convex_hull import possible_hull
|
||||
from skimage.morphology import label
|
||||
from ..measure._ccomp import label
|
||||
from skimage.util import unique_rows
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ from numpy.testing import assert_array_equal, run_module_suite
|
||||
|
||||
from skimage.morphology import label
|
||||
from warnings import catch_warnings
|
||||
from _shared.util import skimage_deprecation
|
||||
|
||||
class TestConnectedComponents:
|
||||
def setup(self):
|
||||
@@ -25,7 +26,7 @@ class TestConnectedComponents:
|
||||
def test_random(self):
|
||||
x = (np.random.random((20, 30)) * 5).astype(np.int)
|
||||
|
||||
with catch_warnings(DeprecationWarning):
|
||||
with catch_warnings(skimage_deprecation):
|
||||
labels = label(x)
|
||||
|
||||
n = labels.max()
|
||||
@@ -37,13 +38,13 @@ class TestConnectedComponents:
|
||||
x = np.array([[0, 0, 1],
|
||||
[0, 1, 0],
|
||||
[1, 0, 0]])
|
||||
with catch_warnings(DeprecationWarning):
|
||||
with catch_warnings(skimage_deprecation):
|
||||
assert_array_equal(label(x), x)
|
||||
|
||||
def test_4_vs_8(self):
|
||||
x = np.array([[0, 1],
|
||||
[1, 0]], dtype=int)
|
||||
with catch_warnings(DeprecationWarning):
|
||||
with catch_warnings(skimage_deprecation):
|
||||
assert_array_equal(label(x, 4),
|
||||
[[0, 1],
|
||||
[2, 3]])
|
||||
@@ -56,7 +57,7 @@ class TestConnectedComponents:
|
||||
[1, 1, 5],
|
||||
[0, 0, 0]])
|
||||
|
||||
with catch_warnings(DeprecationWarning):
|
||||
with catch_warnings(skimage_deprecation):
|
||||
assert_array_equal(label(x), [[0, 1, 1],
|
||||
[0, 0, 2],
|
||||
[3, 3, 3]])
|
||||
@@ -91,7 +92,7 @@ class TestConnectedComponents:
|
||||
[0, 0, 6],
|
||||
[5, 5, 5]])
|
||||
|
||||
with catch_warnings(DeprecationWarning):
|
||||
with catch_warnings(skimage_deprecation):
|
||||
assert_array_equal(label(x, return_num=True)[1], 4)
|
||||
|
||||
assert_array_equal(label(x, background=0, return_num=True)[1], 3)
|
||||
|
||||
@@ -71,7 +71,7 @@ def hough_line_peaks(hspace, angles, dists, min_distance=9, min_angle=10,
|
||||
hspace *= mask
|
||||
hspace_t = hspace > threshold
|
||||
|
||||
label_hspace = morphology.label(hspace_t)
|
||||
label_hspace = measure.label(hspace_t)
|
||||
props = measure.regionprops(label_hspace)
|
||||
coords = np.array([np.round(p.centroid) for p in props], dtype=int)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user