.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "generated/gallery/contours/boundary_contours.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_generated_gallery_contours_boundary_contours.py: =========================================== Adding "Boundary" Contours to an Image =========================================== Ripplemapper has a variety of ways to define the water-air interface, the most simple of which is to use the boundary contours of the image. This example shows how to add boundary contours to an image. What the boundary contour does is the image is first processed to find "edges" in the image, which are then processed to find the contours of the edges. There could be any number of contours but in general, the longest 2 contours will define the "upper" and "lower" boundary. These boundaries are defined as being the top and bottom of the "edge" region respectively. .. GENERATED FROM PYTHON SOURCE LINES 15-16 We can load an image into a RippleImage object using the RippleImage class and then run `add_boundary_contours` to add boundary contours to the image. .. GENERATED FROM PYTHON SOURCE LINES 16-26 .. code-block:: Python import matplotlib.pyplot as plt from ripplemapper.analyse import add_boundary_contours from ripplemapper.classes import RippleImage from ripplemapper.data.example import example_data ripple_img = RippleImage(example_data[-1]) add_boundary_contours(ripple_img, sigma=2) .. GENERATED FROM PYTHON SOURCE LINES 27-28 Plotting the image and its contours .. GENERATED FROM PYTHON SOURCE LINES 28-31 .. code-block:: Python ripple_img.plot(include_contours=True) plt.show() .. image-sg:: /generated/gallery/contours/images/sphx_glr_boundary_contours_001.png :alt: RippleImage: 1_00443_sample.tif :srcset: /generated/gallery/contours/images/sphx_glr_boundary_contours_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.072 seconds) .. _sphx_glr_download_generated_gallery_contours_boundary_contours.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: boundary_contours.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: boundary_contours.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: boundary_contours.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_