From 95977c237f882bb43a41f10b437d2bc064366c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 31 Jan 2016 18:07:01 +0100 Subject: [PATCH 01/16] Fix deprecation warning in plot_ransac --- doc/examples/transform/plot_ransac.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/examples/transform/plot_ransac.py b/doc/examples/transform/plot_ransac.py index 770e8cd1..12b36f32 100644 --- a/doc/examples/transform/plot_ransac.py +++ b/doc/examples/transform/plot_ransac.py @@ -10,7 +10,7 @@ the RANSAC algorithm. import numpy as np from matplotlib import pyplot as plt -from skimage.measure import LineModel, ransac +from skimage.measure import LineModelND, ransac np.random.seed(seed=1) @@ -32,11 +32,11 @@ data[::2] += 5 * noise[::2] data[::4] += 20 * noise[::4] # fit line using all data -model = LineModel() +model = LineModelND() model.estimate(data) # robustly fit line only using inlier data with RANSAC algorithm -model_robust, inliers = ransac(data, LineModel, min_samples=2, +model_robust, inliers = ransac(data, LineModelND, min_samples=2, residual_threshold=1, max_trials=1000) outliers = inliers == False From fdbd9938fb30f773205c7d5b384e66186dce0c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 31 Jan 2016 18:08:57 +0100 Subject: [PATCH 02/16] Apply PEP8 to plot_adapt_rgb --- doc/examples/color_exposure/plot_adapt_rgb.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/examples/color_exposure/plot_adapt_rgb.py b/doc/examples/color_exposure/plot_adapt_rgb.py index 24d8f078..64b2d00b 100644 --- a/doc/examples/color_exposure/plot_adapt_rgb.py +++ b/doc/examples/color_exposure/plot_adapt_rgb.py @@ -49,7 +49,8 @@ image = data.astronaut() fig = plt.figure(figsize=(14, 7)) ax_each = fig.add_subplot(121, adjustable='box-forced') -ax_hsv = fig.add_subplot(122, sharex=ax_each, sharey=ax_each, adjustable='box-forced') +ax_hsv = fig.add_subplot(122, sharex=ax_each, sharey=ax_each, + adjustable='box-forced') # We use 1 - sobel_each(image) # but this will not work if image is not normalized @@ -107,7 +108,8 @@ def sobel_gray(image): return filters.sobel(image) fig = plt.figure(figsize=(7, 7)) -ax = fig.add_subplot(111, sharex=ax_each, sharey=ax_each, adjustable='box-forced') +ax = fig.add_subplot(111, sharex=ax_each, sharey=ax_each, + adjustable='box-forced') # We use 1 - sobel_gray(image) # but this will not work if image is not normalized From 7cf9d7ffdb43b336c84ddff40fbc713b31e5592d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 31 Jan 2016 18:16:47 +0100 Subject: [PATCH 03/16] Fix deprecation warning in equalize_adapthist --- skimage/exposure/_adapthist.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/skimage/exposure/_adapthist.py b/skimage/exposure/_adapthist.py index b42f3169..2f0ed859 100644 --- a/skimage/exposure/_adapthist.py +++ b/skimage/exposure/_adapthist.py @@ -25,7 +25,7 @@ NR_OF_GREY = 2 ** 14 # number of grayscale levels to use in CLAHE algorithm @adapt_rgb(hsv_value) -def equalize_adapthist(image, ntiles_x=8, ntiles_y=8, clip_limit=0.01, +def equalize_adapthist(image, ntiles_x=None, ntiles_y=None, clip_limit=0.01, nbins=256, kernel_size=None): """Contrast Limited Adaptive Histogram Equalization (CLAHE). @@ -76,10 +76,12 @@ def equalize_adapthist(image, ntiles_x=8, ntiles_y=8, clip_limit=0.01, image = img_as_uint(image) image = rescale_intensity(image, out_range=(0, NR_OF_GREY - 1)) - if kernel_size is None: + if ntiles_x is not None or ntiles_y is not None: warn('`ntiles_*` have been deprecated in favor of ' '`kernel_size`. The `ntiles_*` keyword arguments ' 'will be removed in v0.14', skimage_deprecation) + + if kernel_size is None: ntiles_x = ntiles_x or 8 ntiles_y = ntiles_y or 8 kernel_size = (np.round(image.shape[0] / ntiles_y), From 20e1fcdbbb33e54b664103284a01acd75d0d2478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 31 Jan 2016 18:18:15 +0100 Subject: [PATCH 04/16] Fix deprecation warning in plot_active_contours --- doc/examples/edges/plot_active_contours.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/examples/edges/plot_active_contours.py b/doc/examples/edges/plot_active_contours.py index f6f2c1f6..50d6fe48 100644 --- a/doc/examples/edges/plot_active_contours.py +++ b/doc/examples/edges/plot_active_contours.py @@ -28,7 +28,7 @@ import numpy as np import matplotlib.pyplot as plt from skimage.color import rgb2gray from skimage import data -from skimage.filters import gaussian_filter +from skimage.filters import gaussian from skimage.segmentation import active_contour # Test scipy version, since active contour is only possible @@ -52,7 +52,7 @@ if not new_scipy: '0.14.0 and above.') if new_scipy: - snake = active_contour(gaussian_filter(img, 3), + snake = active_contour(gaussian(img, 3), init, alpha=0.015, beta=10, gamma=0.001) fig = plt.figure(figsize=(7, 7)) @@ -80,7 +80,7 @@ y = np.linspace(136, 50, 100) init = np.array([x, y]).T if new_scipy: - snake = active_contour(gaussian_filter(img, 1), init, bc='fixed', + snake = active_contour(gaussian(img, 1), init, bc='fixed', alpha=0.1, beta=1.0, w_line=-5, w_edge=0, gamma=0.1) fig = plt.figure(figsize=(9, 5)) From e3287c8cda606d902a76926baaadbbb44625ee2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 31 Jan 2016 18:29:36 +0100 Subject: [PATCH 05/16] Fix warning in plot_gabors_from_astronaut --- doc/examples/features_detection/plot_gabors_from_astronaut.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/examples/features_detection/plot_gabors_from_astronaut.py b/doc/examples/features_detection/plot_gabors_from_astronaut.py index a8cb50c2..7f718014 100644 --- a/doc/examples/features_detection/plot_gabors_from_astronaut.py +++ b/doc/examples/features_detection/plot_gabors_from_astronaut.py @@ -51,7 +51,7 @@ np.random.seed(42) patch_shape = 8, 8 n_filters = 49 -astro = color.rgb2gray(data.astronaut()) +astro = np.ascontiguousarray(color.rgb2gray(data.astronaut())) # -- filterbank1 on original image patches1 = view_as_windows(astro, patch_shape) From a7685738c9bd54a53858199b2225dbb4d1adce8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 31 Jan 2016 18:32:10 +0100 Subject: [PATCH 06/16] Fix warning in plot_rank_mean --- doc/examples/filters/plot_rank_mean.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/examples/filters/plot_rank_mean.py b/doc/examples/filters/plot_rank_mean.py index a6fd75d6..7a5428ce 100644 --- a/doc/examples/filters/plot_rank_mean.py +++ b/doc/examples/filters/plot_rank_mean.py @@ -26,7 +26,7 @@ from skimage.morphology import disk from skimage.filters import rank -image = (data.coins()).astype(np.uint16) * 16 +image = data.coins() selem = disk(20) percentile_result = rank.mean_percentile(image, selem=selem, p0=.1, p1=.9) @@ -46,5 +46,4 @@ for n in range(0, len(imgs)): ax[n].set_adjustable('box-forced') ax[n].axis('off') - plt.show() From 976ac85e4520b0174f69e95dfcddde0dd7402386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 31 Jan 2016 18:39:40 +0100 Subject: [PATCH 07/16] Fix warning in plot_view_as_blocks --- doc/examples/numpy_operations/plot_view_as_blocks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/examples/numpy_operations/plot_view_as_blocks.py b/doc/examples/numpy_operations/plot_view_as_blocks.py index 53797aac..862d8e32 100644 --- a/doc/examples/numpy_operations/plot_view_as_blocks.py +++ b/doc/examples/numpy_operations/plot_view_as_blocks.py @@ -25,7 +25,7 @@ from skimage.util.shape import view_as_blocks # -- get `astronaut` from skimage.data in grayscale -l = color.rgb2gray(data.astronaut()) +l = np.ascontiguousarray(color.rgb2gray(data.astronaut())) # -- size of blocks block_shape = (4, 4) From a28a9d42e8dc193b0e9ffeb2323462a12b11022e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 31 Jan 2016 18:41:10 +0100 Subject: [PATCH 08/16] Fix warning in plot_swirl --- doc/examples/transform/plot_swirl.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/examples/transform/plot_swirl.py b/doc/examples/transform/plot_swirl.py index b93efe9f..117276db 100644 --- a/doc/examples/transform/plot_swirl.py +++ b/doc/examples/transform/plot_swirl.py @@ -72,9 +72,10 @@ from skimage.transform import swirl image = data.checkerboard() -swirled = swirl(image, rotation=0, strength=10, radius=120, order=2) +swirled = swirl(image, rotation=0, strength=10, radius=120) -fig, (ax0, ax1) = plt.subplots(1, 2, figsize=(8, 3), sharex=True, sharey=True, subplot_kw={'adjustable':'box-forced'}) +fig, (ax0, ax1) = plt.subplots(1, 2, figsize=(8, 3), sharex=True, sharey=True, + subplot_kw={'adjustable':'box-forced'}) ax0.imshow(image, cmap=plt.cm.gray, interpolation='none') ax0.axis('off') From 9a9f9b205c0c37b68dfce81f37a193cbbaaa2ceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 31 Jan 2016 18:48:14 +0100 Subject: [PATCH 09/16] Improve plot_morphology --- .../xx_applications/plot_morphology.py | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/doc/examples/xx_applications/plot_morphology.py b/doc/examples/xx_applications/plot_morphology.py index 33246793..35bf79e9 100644 --- a/doc/examples/xx_applications/plot_morphology.py +++ b/doc/examples/xx_applications/plot_morphology.py @@ -25,14 +25,16 @@ To get started, let's load an image using ``io.imread``. Note that morphology functions only work on gray-scale or binary images, so we set ``as_grey=True``. """ +import os import matplotlib.pyplot as plt from skimage.data import data_dir from skimage.util import img_as_ubyte from skimage import io -phantom = img_as_ubyte(io.imread(data_dir+'/phantom.png', as_grey=True)) +orig_phantom = img_as_ubyte(io.imread(os.path.join(data_dir, "phantom.png"), + as_grey=True)) fig, ax = plt.subplots() -ax.imshow(phantom, cmap=plt.cm.gray) +ax.imshow(orig_phantom, cmap=plt.cm.gray) """ .. image:: PLOT2RST.current_figure @@ -42,7 +44,8 @@ Let's also define a convenience function for plotting comparisons: def plot_comparison(original, filtered, filter_name): - fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(8, 4), sharex=True, sharey=True) + fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(8, 4), sharex=True, + sharey=True) ax1.imshow(original, cmap=plt.cm.gray) ax1.set_title('original') ax1.axis('off') @@ -68,8 +71,8 @@ from skimage.morphology import black_tophat, skeletonize, convex_hull_image from skimage.morphology import disk selem = disk(6) -eroded = erosion(phantom, selem) -plot_comparison(phantom, eroded, 'erosion') +eroded = erosion(orig_phantom, selem) +plot_comparison(orig_phantom, eroded, 'erosion') """ .. image:: PLOT2RST.current_figure @@ -88,8 +91,8 @@ pixels in the neighborhood centered at (i, j)*. Dilation enlarges bright regions and shrinks dark regions. """ -dilated = dilation(phantom, selem) -plot_comparison(phantom, dilated, 'dilation') +dilated = dilation(orig_phantom, selem) +plot_comparison(orig_phantom, dilated, 'dilation') """ .. image:: PLOT2RST.current_figure @@ -108,8 +111,8 @@ dilation*. Opening can remove small bright spots (i.e. "salt") and connect small dark cracks. """ -opened = opening(phantom, selem) -plot_comparison(phantom, opened, 'opening') +opened = opening(orig_phantom, selem) +plot_comparison(orig_phantom, opened, 'opening') """ .. image:: PLOT2RST.current_figure @@ -134,7 +137,7 @@ small bright cracks. To illustrate this more clearly, let's add a small crack to the white border: """ -phantom = img_as_ubyte(io.imread(data_dir+'/phantom.png', as_grey=True)) +phantom = orig_phantom.copy() phantom[10:30, 200:210] = 0 closed = closing(phantom, selem) @@ -161,7 +164,7 @@ that are smaller than the structuring element. To make things interesting, we'll add bright and dark spots to the image: """ -phantom = img_as_ubyte(io.imread(data_dir+'/phantom.png', as_grey=True)) +phantom = orig_phantom.copy() phantom[340:350, 200:210] = 255 phantom[100:110, 200:210] = 0 @@ -215,10 +218,9 @@ on binary images only. """ -from skimage import img_as_bool -horse = ~img_as_bool(io.imread(data_dir+'/horse.png', as_grey=True)) +horse = io.imread(os.path.join(data_dir, "horse.png"), as_grey=True) -sk = skeletonize(horse) +sk = skeletonize(horse == 0) plot_comparison(horse, sk, 'skeletonize') """ @@ -237,7 +239,7 @@ that this is also performed on binary images. """ -hull1 = convex_hull_image(horse) +hull1 = convex_hull_image(horse == 0) plot_comparison(horse, hull1, 'convex hull') """ @@ -252,11 +254,11 @@ enclose that grain: import numpy as np -horse2 = np.copy(horse) -horse2[45:50, 75:80] = 1 +horse_mask = horse == 0 +horse_mask[45:50, 75:80] = 1 -hull2 = convex_hull_image(horse2) -plot_comparison(horse2, hull2, 'convex hull') +hull2 = convex_hull_image(horse_mask) +plot_comparison(horse_mask, hull2, 'convex hull') """ .. image:: PLOT2RST.current_figure From 5e780bb27f1bd8d4b1a8705ee8cfe19018d3caf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 31 Jan 2016 18:51:23 +0100 Subject: [PATCH 10/16] Fix unknown Example section warning --- skimage/external/tifffile/tifffile.py | 4 ++-- skimage/novice/__init__.py | 4 ++-- skimage/restoration/_denoise.py | 4 ++-- skimage/restoration/inpaint.py | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/skimage/external/tifffile/tifffile.py b/skimage/external/tifffile/tifffile.py index 817bb44f..c30120d7 100644 --- a/skimage/external/tifffile/tifffile.py +++ b/skimage/external/tifffile/tifffile.py @@ -3104,8 +3104,8 @@ def _replace_by(module_function, package=None, warn=False): func : function Wrapped function, hopefully calling a function in another module. - Example - ------- + Examples + -------- >>> @_replace_by('_tifffile.decodepackbits') ... def decodepackbits(encoded): ... raise NotImplementedError diff --git a/skimage/novice/__init__.py b/skimage/novice/__init__.py index 058f3c82..02da082b 100644 --- a/skimage/novice/__init__.py +++ b/skimage/novice/__init__.py @@ -19,8 +19,8 @@ the normal, array-oriented image functions used by scikit-image. instead of row, column. -Example -------- +Examples +-------- We can create a Picture object open opening an image file: >>> from skimage import novice diff --git a/skimage/restoration/_denoise.py b/skimage/restoration/_denoise.py index 62985cc7..07819fa0 100644 --- a/skimage/restoration/_denoise.py +++ b/skimage/restoration/_denoise.py @@ -55,8 +55,8 @@ def denoise_bilateral(image, win_size=5, sigma_range=None, sigma_spatial=1, ---------- .. [1] http://users.soe.ucsc.edu/~manduchi/Papers/ICCV98.pdf - Example - ------- + Examples + -------- >>> from skimage import data, img_as_float >>> astro = img_as_float(data.astronaut()) >>> astro = astro[220:300, 220:320] diff --git a/skimage/restoration/inpaint.py b/skimage/restoration/inpaint.py index bf696e04..5ecd28c7 100644 --- a/skimage/restoration/inpaint.py +++ b/skimage/restoration/inpaint.py @@ -92,8 +92,8 @@ def inpaint_biharmonic(img, mask, multichannel=False): out : (M[, N[, ..., P]][, C]) ndarray Input image with masked pixels inpainted. - Example - ------- + Examples + -------- >>> img = np.tile(np.square(np.linspace(0, 1, 5)), (5, 1)) >>> mask = np.zeros_like(img) >>> mask[2, 2:] = 1 @@ -111,11 +111,11 @@ def inpaint_biharmonic(img, mask, multichannel=False): if img.ndim < 1: raise ValueError('Input array has to be at least 1D') - + img_baseshape = img.shape[:-1] if multichannel else img.shape if img_baseshape != mask.shape: raise ValueError('Input arrays have to be the same shape') - + if np.ma.isMaskedArray(img): raise TypeError('Masked arrays are not supported') From 3bf2250b646d461769b9b32af09deaf92192bc2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 31 Jan 2016 18:54:22 +0100 Subject: [PATCH 11/16] Fix unknown Note section warning --- skimage/_shared/version_requirements.py | 4 ++-- skimage/transform/_warps.py | 4 ++-- skimage/transform/_warps_cy.pyx | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/skimage/_shared/version_requirements.py b/skimage/_shared/version_requirements.py index 430f7f5e..0ee5cd18 100644 --- a/skimage/_shared/version_requirements.py +++ b/skimage/_shared/version_requirements.py @@ -57,8 +57,8 @@ def is_installed(name, version=None): out : bool True if `name` is installed matching the optional version. - Note - ---- + Notes + ----- Original Copyright (C) 2009-2011 Pierre Raybaut Licensed under the terms of the MIT License. """ diff --git a/skimage/transform/_warps.py b/skimage/transform/_warps.py index 1979e8d4..cd3963bd 100644 --- a/skimage/transform/_warps.py +++ b/skimage/transform/_warps.py @@ -50,8 +50,8 @@ def resize(image, output_shape, order=1, mode='constant', cval=0, clip=True, Whether to keep the original range of values. Otherwise, the input image is converted according to the conventions of `img_as_float`. - Note - ---- + Notes + ----- Modes 'reflect' and 'symmetric' are similar, but differ in whether the edge pixels are duplicated during the reflection. As an example, if an array has values [0, 1, 2] and was padded to the right by four values using diff --git a/skimage/transform/_warps_cy.pyx b/skimage/transform/_warps_cy.pyx index a3167016..aec7aae6 100644 --- a/skimage/transform/_warps_cy.pyx +++ b/skimage/transform/_warps_cy.pyx @@ -77,8 +77,8 @@ def _warp_fast(cnp.ndarray image, cnp.ndarray H, output_shape=None, Used in conjunction with mode 'C' (constant), the value outside the image boundaries. - Note - ---- + Notes + ----- Modes 'reflect' and 'symmetric' are similar, but differ in whether the edge pixels are duplicated during the reflection. As an example, if an array has values [0, 1, 2] and was padded to the right by four values using From 8c5d30c2ac9a3a27db2d2648bd6e84a2813d9c66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 31 Jan 2016 18:54:30 +0100 Subject: [PATCH 12/16] Fix unknown Properties section warning --- skimage/external/tifffile/tifffile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skimage/external/tifffile/tifffile.py b/skimage/external/tifffile/tifffile.py index c30120d7..44de0bb1 100644 --- a/skimage/external/tifffile/tifffile.py +++ b/skimage/external/tifffile/tifffile.py @@ -2208,7 +2208,7 @@ class TiffSequence(object): The data shape and dtype of all files must match. - Properties + Attributes ---------- files : list List of file names. From 2441166a4e8a2a103c1d5d099cff67e08ea071fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 31 Jan 2016 18:57:59 +0100 Subject: [PATCH 13/16] Apply PEP8 to plot_circular_elliptical_hough_transform --- .../edges/plot_circular_elliptical_hough_transform.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/examples/edges/plot_circular_elliptical_hough_transform.py b/doc/examples/edges/plot_circular_elliptical_hough_transform.py index 5d5a8b2e..389a1afa 100755 --- a/doc/examples/edges/plot_circular_elliptical_hough_transform.py +++ b/doc/examples/edges/plot_circular_elliptical_hough_transform.py @@ -138,7 +138,9 @@ image_rgb[cy, cx] = (0, 0, 255) edges = color.gray2rgb(edges) edges[cy, cx] = (250, 0, 0) -fig2, (ax1, ax2) = plt.subplots(ncols=2, nrows=1, figsize=(8, 4), sharex=True, sharey=True, subplot_kw={'adjustable':'box-forced'}) +fig2, (ax1, ax2) = plt.subplots(ncols=2, nrows=1, figsize=(8, 4), sharex=True, + sharey=True, + subplot_kw={'adjustable':'box-forced'}) ax1.set_title('Original picture') ax1.imshow(image_rgb) From 6eea36a3befd5d5ba7933fbd39ae843638704d43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sun, 31 Jan 2016 21:57:14 +0100 Subject: [PATCH 14/16] Fix test cases for new deprecation behavior --- skimage/exposure/tests/test_exposure.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/skimage/exposure/tests/test_exposure.py b/skimage/exposure/tests/test_exposure.py index 4b88b67f..095e85ac 100644 --- a/skimage/exposure/tests/test_exposure.py +++ b/skimage/exposure/tests/test_exposure.py @@ -211,11 +211,13 @@ def test_adapthist_grayscale(): img = skimage.img_as_float(data.astronaut()) img = rgb2gray(img) img = np.dstack((img, img, img)) - with expected_warnings(['precision loss|non-contiguous input', + with expected_warnings(['precision loss|non-contiguous input', 'deprecated']): adapted_old = exposure.equalize_adapthist(img, 10, 9, clip_limit=0.001, nbins=128) - adapted = exposure.equalize_adapthist(img, kernel_size=(57, 51), clip_limit=0.01, nbins=128) + with expected_warnings(['precision loss|non-contiguous input']): + adapted = exposure.equalize_adapthist(img, kernel_size=(57, 51), + clip_limit=0.01, nbins=128) assert img.shape == adapted.shape assert_almost_equal(peak_snr(img, adapted), 102.078, 3) assert_almost_equal(norm_brightness_err(img, adapted), 0.0529, 3) @@ -230,7 +232,7 @@ def test_adapthist_color(): warnings.simplefilter('always') hist, bin_centers = exposure.histogram(img) assert len(w) > 0 - with expected_warnings(['precision loss', 'deprecated']): + with expected_warnings(['precision loss']): adapted = exposure.equalize_adapthist(img, clip_limit=0.01) assert_almost_equal = np.testing.assert_almost_equal @@ -249,7 +251,7 @@ def test_adapthist_alpha(): img = skimage.img_as_float(data.astronaut()) alpha = np.ones((img.shape[0], img.shape[1]), dtype=float) img = np.dstack((img, alpha)) - with expected_warnings(['precision loss', 'deprecated']): + with expected_warnings(['precision loss']): adapted = exposure.equalize_adapthist(img) assert adapted.shape != img.shape img = img[:, :, :3] From 045b04703acdf84f4af2602f110b330ffe67b7a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Mon, 1 Feb 2016 08:49:54 +0100 Subject: [PATCH 15/16] Revert contiguous array conversion --- doc/examples/features_detection/plot_gabors_from_astronaut.py | 2 +- doc/examples/numpy_operations/plot_view_as_blocks.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/examples/features_detection/plot_gabors_from_astronaut.py b/doc/examples/features_detection/plot_gabors_from_astronaut.py index 7f718014..a8cb50c2 100644 --- a/doc/examples/features_detection/plot_gabors_from_astronaut.py +++ b/doc/examples/features_detection/plot_gabors_from_astronaut.py @@ -51,7 +51,7 @@ np.random.seed(42) patch_shape = 8, 8 n_filters = 49 -astro = np.ascontiguousarray(color.rgb2gray(data.astronaut())) +astro = color.rgb2gray(data.astronaut()) # -- filterbank1 on original image patches1 = view_as_windows(astro, patch_shape) diff --git a/doc/examples/numpy_operations/plot_view_as_blocks.py b/doc/examples/numpy_operations/plot_view_as_blocks.py index 862d8e32..53797aac 100644 --- a/doc/examples/numpy_operations/plot_view_as_blocks.py +++ b/doc/examples/numpy_operations/plot_view_as_blocks.py @@ -25,7 +25,7 @@ from skimage.util.shape import view_as_blocks # -- get `astronaut` from skimage.data in grayscale -l = np.ascontiguousarray(color.rgb2gray(data.astronaut())) +l = color.rgb2gray(data.astronaut()) # -- size of blocks block_shape = (4, 4) From 10ffe9f690ee58d25cb5c8d884fbf53be1e79d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Mon, 1 Feb 2016 09:55:50 +0100 Subject: [PATCH 16/16] Use kwargs for figure config --- doc/examples/transform/plot_swirl.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/examples/transform/plot_swirl.py b/doc/examples/transform/plot_swirl.py index 117276db..8f38afbc 100644 --- a/doc/examples/transform/plot_swirl.py +++ b/doc/examples/transform/plot_swirl.py @@ -74,7 +74,8 @@ from skimage.transform import swirl image = data.checkerboard() swirled = swirl(image, rotation=0, strength=10, radius=120) -fig, (ax0, ax1) = plt.subplots(1, 2, figsize=(8, 3), sharex=True, sharey=True, +fig, (ax0, ax1) = plt.subplots(nrows=1, ncols=2, figsize=(8, 3), + sharex=True, sharey=True, subplot_kw={'adjustable':'box-forced'}) ax0.imshow(image, cmap=plt.cm.gray, interpolation='none')