.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "packages/scikit-image/auto_examples/plot_boundaries.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_packages_scikit-image_auto_examples_plot_boundaries.py: Segmentation contours ===================== Visualize segmentation contours on original grayscale image. .. GENERATED FROM PYTHON SOURCE LINES 7-29 .. image-sg:: /packages/scikit-image/auto_examples/images/sphx_glr_plot_boundaries_001.png :alt: plot boundaries :srcset: /packages/scikit-image/auto_examples/images/sphx_glr_plot_boundaries_001.png :class: sphx-glr-single-img .. code-block:: default from skimage import data, segmentation from skimage import 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(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() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.096 seconds) .. _sphx_glr_download_packages_scikit-image_auto_examples_plot_boundaries.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_boundaries.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_boundaries.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_