From 6cf12ac0d88545727cf7d983b5f212163f0e6140 Mon Sep 17 00:00:00 2001 From: Juan Nunez-Iglesias Date: Wed, 9 Oct 2013 09:28:38 +0000 Subject: [PATCH] Fix join_segmentations example using img_as_float data.coins() returns a ubyte image in Python 2.7.x but a float32 image in Python 3.x. This ensures that the image always has the same type for the rest of the example. --- doc/examples/plot_join_segmentations.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/examples/plot_join_segmentations.py b/doc/examples/plot_join_segmentations.py index facd5171..625113e5 100644 --- a/doc/examples/plot_join_segmentations.py +++ b/doc/examples/plot_join_segmentations.py @@ -18,16 +18,16 @@ from skimage.filter import sobel from skimage.segmentation import slic, join_segmentations from skimage.morphology import watershed from skimage.color import label2rgb -from skimage import data +from skimage import data, img_as_float -coins = data.coins() +coins = img_as_float(data.coins()) # make segmentation using edge-detection and watershed edges = sobel(coins) markers = np.zeros_like(coins) foreground, background = 1, 2 -markers[coins < 30] = background -markers[coins > 150] = foreground +markers[coins < 30.0 / 255] = background +markers[coins > 150.0 / 255] = foreground ws = watershed(edges, markers) seg1 = nd.label(ws == foreground)[0] @@ -60,3 +60,4 @@ for ax in axes: ax.axis('off') plt.subplots_adjust(hspace=0.01, wspace=0.01, top=1, bottom=0, left=0, right=1) plt.show() +