Segementation contours

Visualize segmentation contours on original grayscale image.

../../../_images/plot_boundaries_1.png

Python ソースコード: plot_boundaries.py

from skimage import data, segmentation
# scikit-image has changed its API
try:
from skimage import filters
except ImportError:
from skimage import filter as filters
import matplotlib.pyplot as plt
import numpy as np
coins = data.coins()
mask = coins > filters.threshold_otsu(coins)
clean_border = segmentation.clear_border(mask).astype(np.int)
coins_edges = segmentation.mark_boundaries(coins, clean_border)
plt.figure(figsize=(8, 3.5))
plt.subplot(121)
plt.imshow(clean_border, cmap='gray')
plt.axis('off')
plt.subplot(122)
plt.imshow(coins_edges)
plt.axis('off')
plt.tight_layout()
plt.show()

Total running time of the example: 0.23 seconds ( 0 minutes 0.23 seconds)