diff --git a/TODO.txt b/TODO.txt index e2fc4218..3e6b3a7e 100644 --- a/TODO.txt +++ b/TODO.txt @@ -3,6 +3,8 @@ Remember to list any API changes below in `doc/source/api_changes.txt`. Version 0.13 ------------ * Remove deprecated `None` defaults for `skimage.exposure.rescale_intensity` +* Remove deprecated `skimage.filter.canny` import in filter/__init__.py file (canny is now in `skimage.feature.canny`). + * Don't forget to complete api_changes.txt. (`GitHub discuss `__ ) Version 0.12 ------------ diff --git a/doc/examples/applications/plot_coins_segmentation.py b/doc/examples/applications/plot_coins_segmentation.py index 49ff399f..50eec0bb 100644 --- a/doc/examples/applications/plot_coins_segmentation.py +++ b/doc/examples/applications/plot_coins_segmentation.py @@ -57,7 +57,7 @@ segmentation. To do this, we first get the edges of features using the Canny edge-detector. """ -from skimage.filter import canny +from skimage.feature import canny edges = canny(coins/255.) fig, ax = plt.subplots(figsize=(4, 3)) diff --git a/doc/examples/plot_canny.py b/doc/examples/plot_canny.py index f1caf264..82a930e5 100644 --- a/doc/examples/plot_canny.py +++ b/doc/examples/plot_canny.py @@ -19,7 +19,7 @@ import numpy as np import matplotlib.pyplot as plt from scipy import ndimage -from skimage import filter +from skimage import feature # Generate noisy image of a square @@ -31,8 +31,8 @@ im = ndimage.gaussian_filter(im, 4) im += 0.2 * np.random.random(im.shape) # Compute the Canny filter for two values of sigma -edges1 = filter.canny(im) -edges2 = filter.canny(im, sigma=3) +edges1 = feature.canny(im) +edges2 = feature.canny(im, sigma=3) # display results fig, (ax1, ax2, ax3) = plt.subplots(nrows=1, ncols=3, figsize=(8, 3)) diff --git a/doc/examples/plot_circular_elliptical_hough_transform.py b/doc/examples/plot_circular_elliptical_hough_transform.py index fbdd4f2c..9b0be0fb 100755 --- a/doc/examples/plot_circular_elliptical_hough_transform.py +++ b/doc/examples/plot_circular_elliptical_hough_transform.py @@ -37,16 +37,16 @@ Its size is extended by two times the larger radius. import numpy as np import matplotlib.pyplot as plt -from skimage import data, filter, color +from skimage import data, color from skimage.transform import hough_circle -from skimage.feature import peak_local_max +from skimage.feature import peak_local_max, canny from skimage.draw import circle_perimeter from skimage.util import img_as_ubyte # Load picture and detect edges image = img_as_ubyte(data.coins()[0:95, 70:370]) -edges = filter.canny(image, sigma=3, low_threshold=10, high_threshold=50) +edges = canny(image, sigma=3, low_threshold=10, high_threshold=50) fig, ax = plt.subplots(ncols=1, nrows=1, figsize=(5, 2)) @@ -106,14 +106,15 @@ References import matplotlib.pyplot as plt -from skimage import data, filter, color +from skimage import data, color +from skimage.feature import canny from skimage.transform import hough_ellipse from skimage.draw import ellipse_perimeter # Load picture, convert to grayscale and detect edges image_rgb = data.coffee()[0:220, 160:420] image_gray = color.rgb2gray(image_rgb) -edges = filter.canny(image_gray, sigma=2.0, +edges = canny(image_gray, sigma=2.0, low_threshold=0.55, high_threshold=0.8) # Perform a Hough Transform diff --git a/doc/examples/plot_line_hough_transform.py b/doc/examples/plot_line_hough_transform.py index bdb05661..4293c409 100644 --- a/doc/examples/plot_line_hough_transform.py +++ b/doc/examples/plot_line_hough_transform.py @@ -58,7 +58,7 @@ References from skimage.transform import (hough_line, hough_line_peaks, probabilistic_hough_line) -from skimage.filter import canny +from skimage.feature import canny from skimage import data import numpy as np diff --git a/doc/source/user_guide/tutorial_segmentation.txt b/doc/source/user_guide/tutorial_segmentation.txt index cff7c651..d183102f 100644 --- a/doc/source/user_guide/tutorial_segmentation.txt +++ b/doc/source/user_guide/tutorial_segmentation.txt @@ -38,11 +38,11 @@ Edge-based segmentation Let us first try to detect edges that enclose the coins. For edge detection, we use the `Canny detector -`_ of ``skimage.filter.canny`` +`_ of ``skimage.feature.canny`` :: - >>> from skimage.filter import canny + >>> from skimage.feature import canny >>> edges = canny(coins/255.) As the background is very smooth, almost all edges are found at the diff --git a/skimage/feature/__init__.py b/skimage/feature/__init__.py index c46fde01..90bb6e53 100644 --- a/skimage/feature/__init__.py +++ b/skimage/feature/__init__.py @@ -1,3 +1,4 @@ +from ._canny import canny from ._daisy import daisy from ._hog import hog from .texture import greycomatrix, greycoprops, local_binary_pattern @@ -17,7 +18,8 @@ from .util import plot_matches from .blob import blob_dog, blob_log, blob_doh -__all__ = ['daisy', +__all__ = ['canny' + 'daisy', 'hog', 'greycomatrix', 'greycoprops', diff --git a/skimage/filter/_canny.py b/skimage/feature/_canny.py similarity index 100% rename from skimage/filter/_canny.py rename to skimage/feature/_canny.py diff --git a/skimage/feature/tests/__init__.py b/skimage/feature/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/skimage/filter/tests/test_canny.py b/skimage/feature/tests/test_canny.py similarity index 99% rename from skimage/filter/tests/test_canny.py rename to skimage/feature/tests/test_canny.py index 2c758edf..43db5037 100644 --- a/skimage/filter/tests/test_canny.py +++ b/skimage/feature/tests/test_canny.py @@ -1,7 +1,7 @@ import unittest import numpy as np from scipy.ndimage import binary_dilation, binary_erosion -import skimage.filter as F +import skimage.feature as F class TestCanny(unittest.TestCase): diff --git a/skimage/filter/__init__.py b/skimage/filter/__init__.py index 649eba6b..0228957e 100644 --- a/skimage/filter/__init__.py +++ b/skimage/filter/__init__.py @@ -1,6 +1,5 @@ from .lpi_filter import inverse, wiener, LPIFilter2D from ._gaussian import gaussian_filter -from ._canny import canny from .edges import (sobel, hsobel, vsobel, scharr, hscharr, vscharr, prewitt, hprewitt, vprewitt, roberts, roberts_positive_diagonal, roberts_negative_diagonal) @@ -10,7 +9,6 @@ from .thresholding import (threshold_adaptive, threshold_otsu, threshold_yen, threshold_isodata) from . import rank - from skimage._shared.utils import deprecated from skimage import restoration denoise_bilateral = deprecated('skimage.restoration.denoise_bilateral')\ @@ -20,6 +18,13 @@ denoise_tv_bregman = deprecated('skimage.restoration.denoise_tv_bregman')\ denoise_tv_chambolle = deprecated('skimage.restoration.denoise_tv_chambolle')\ (restoration.denoise_tv_chambolle) +# Backward compatibility v<0.11 +@deprecated +def canny(*args, **kwargs): + # Hack to avoid circular import + from skimage.feature._canny import canny as canny_ + return canny_(*args, **kwargs) + __all__ = ['inverse', 'wiener', diff --git a/skimage/viewer/plugins/canny.py b/skimage/viewer/plugins/canny.py index c2294ba8..83e80890 100644 --- a/skimage/viewer/plugins/canny.py +++ b/skimage/viewer/plugins/canny.py @@ -1,7 +1,7 @@ import numpy as np import skimage -from skimage.filter import canny +from skimage.feature import canny from .overlayplugin import OverlayPlugin from ..widgets import Slider, ComboBox