.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "generated/gallery/contours/removing_small_bumps.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_removing_small_bumps.py: =========================================== Removing "bumps" from a computed boundary =========================================== Since many of the methods for computing boundaries rely on contouring data, it is possible that the contours may have small "bumps" in them. This happens when the contouring "jumps" from one parallel line to the next and back again, it looks like a small discontinuity when plotted. These can sometimes be removed using ripplemapper. .. GENERATED FROM PYTHON SOURCE LINES 14-15 We load our image into a RippleImage and then run `add_boundary_contours` to add boundary contours to the image. .. GENERATED FROM PYTHON SOURCE LINES 15-25 .. code-block:: Python import matplotlib.pyplot as plt from ripplemapper.analyse import add_boundary_contours, remove_small_bumps 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 26-27 Plotting the contour .. GENERATED FROM PYTHON SOURCE LINES 27-31 .. code-block:: Python ripple_img.contours[0].plot() plt.show() .. image-sg:: /generated/gallery/contours/images/sphx_glr_removing_small_bumps_001.png :alt: /home/docs/checkouts/readthedocs.org/user_builds/ripplemapper/envs/latest/lib/python3.12/site-packages/ripplemapper/data/example/1_00443_sample.tif - Contour: Upper Boundary :srcset: /generated/gallery/contours/images/sphx_glr_removing_small_bumps_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 32-33 We can remove the small bumps by running `remove_small_bumps`. .. GENERATED FROM PYTHON SOURCE LINES 33-36 .. code-block:: Python remove_small_bumps(ripple_img.contours[0]) .. rst-class:: sphx-glr-script-out .. code-block:: none num removed (41,) .. GENERATED FROM PYTHON SOURCE LINES 37-38 Plotting the now smoothed contour, this is not perfectly smooth but does have some of the abrupt discontoniuties removed. .. GENERATED FROM PYTHON SOURCE LINES 38-41 .. code-block:: Python ripple_img.contours[0].plot() plt.show() .. image-sg:: /generated/gallery/contours/images/sphx_glr_removing_small_bumps_002.png :alt: /home/docs/checkouts/readthedocs.org/user_builds/ripplemapper/envs/latest/lib/python3.12/site-packages/ripplemapper/data/example/1_00443_sample.tif - Contour: Upper Boundary :srcset: /generated/gallery/contours/images/sphx_glr_removing_small_bumps_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.115 seconds) .. _sphx_glr_download_generated_gallery_contours_removing_small_bumps.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: removing_small_bumps.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: removing_small_bumps.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: removing_small_bumps.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_