.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "generated/gallery/contours/boundary_a_star.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_a_star.py: ===================================== Adding Chan-Vese Contours to an Image ===================================== This example shows how to add a contour based on an A-star traversal of the image in an area between two existing contours. This is useful as a method to produce an average path between two contours, for example the 'upper' and 'lower' boundaries of a ripple. Since it is common for waves to have a shape that is multivalued then a normal averaging method will not effectivey capture the average shape of the two contours. .. GENERATED FROM PYTHON SOURCE LINES 13-14 We can load an image into a RippleImage object using the RippleImage class and then run `add_boundary_contours` to add our limits for the A* contour to the image. .. GENERATED FROM PYTHON SOURCE LINES 14-24 .. code-block:: Python import matplotlib.pyplot as plt from ripplemapper.analyse import add_a_star_contours, 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) .. GENERATED FROM PYTHON SOURCE LINES 25-26 From here we can run `add_a_star_contours` to add the A* contour that uses these two boundaries as its limits. .. GENERATED FROM PYTHON SOURCE LINES 26-29 .. code-block:: Python add_a_star_contours(ripple_img) .. GENERATED FROM PYTHON SOURCE LINES 30-31 Plotting the image and its contours .. GENERATED FROM PYTHON SOURCE LINES 31-34 .. code-block:: Python ripple_img.plot(include_contours=True) plt.show() .. image-sg:: /generated/gallery/contours/images/sphx_glr_boundary_a_star_001.png :alt: RippleImage: 1_00205_sample.tif :srcset: /generated/gallery/contours/images/sphx_glr_boundary_a_star_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.099 seconds) .. _sphx_glr_download_generated_gallery_contours_boundary_a_star.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: boundary_a_star.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: boundary_a_star.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: boundary_a_star.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_