From 29a29721c805caabaed764220d3b1e1410c45a2a Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Mon, 1 Apr 2013 22:33:10 -0500 Subject: [PATCH] DOC: Change more examples to use `image_label2rgb` --- doc/examples/applications/plot_coins_segmentation.py | 5 ++++- doc/examples/plot_label.py | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/examples/applications/plot_coins_segmentation.py b/doc/examples/applications/plot_coins_segmentation.py index cea5a468..55ba5c0c 100644 --- a/doc/examples/applications/plot_coins_segmentation.py +++ b/doc/examples/applications/plot_coins_segmentation.py @@ -160,8 +160,11 @@ individually. """ +from skimage.color import image_label2rgb + segmentation = ndimage.binary_fill_holes(segmentation - 1) labeled_coins, _ = ndimage.label(segmentation) +image_label_overlay = image_label2rgb(coins, labeled_coins) plt.figure(figsize=(6, 3)) plt.subplot(121) @@ -169,7 +172,7 @@ plt.imshow(coins, cmap=plt.cm.gray, interpolation='nearest') plt.contour(segmentation, [0.5], linewidths=1.2, colors='y') plt.axis('off') plt.subplot(122) -plt.imshow(labeled_coins, cmap=plt.cm.spectral, interpolation='nearest') +plt.imshow(image_label_overlay, interpolation='nearest') plt.axis('off') plt.subplots_adjust(**margins) diff --git a/doc/examples/plot_label.py b/doc/examples/plot_label.py index bed7c1f2..6ff61fa6 100644 --- a/doc/examples/plot_label.py +++ b/doc/examples/plot_label.py @@ -21,6 +21,7 @@ from skimage.filter import threshold_otsu from skimage.segmentation import clear_border from skimage.morphology import label, closing, square from skimage.measure import regionprops +from skimage.color import image_label2rgb image = data.coins()[50:-50, 50:-50] @@ -37,9 +38,10 @@ clear_border(cleared) label_image = label(cleared) borders = np.logical_xor(bw, cleared) label_image[borders] = -1 +image_label_overlay = image_label2rgb(image, label_image) fig, ax = plt.subplots(ncols=1, nrows=1, figsize=(6, 6)) -ax.imshow(label_image, cmap='jet') +ax.imshow(image_label_overlay) for region in regionprops(label_image, ['Area', 'BoundingBox']):