mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-10 03:30:46 +08:00
DOC: Change more examples to use image_label2rgb
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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']):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user