DOC: Change more examples to use image_label2rgb

This commit is contained in:
Tony S Yu
2013-04-01 22:33:10 -05:00
parent 6360240c38
commit 29a29721c8
2 changed files with 7 additions and 2 deletions
@@ -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)
+3 -1
View File
@@ -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']):