.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/pattern_processing/dynamic_background_correction.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_examples_pattern_processing_dynamic_background_correction.py: ============================= Dynamic background correction ============================= This example shows how to remove the dynamic background of an EBSD pattern using :meth:`~kikuchipy.signals.EBSD.remove_dynamic_background`. More details are given in the :doc:`pattern processing tutorial `. .. GENERATED FROM PYTHON SOURCE LINES 12-35 .. image-sg:: /examples/pattern_processing/images/sphx_glr_dynamic_background_correction_001.png :alt: Static, Dynamic :srcset: /examples/pattern_processing/images/sphx_glr_dynamic_background_correction_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [[84 87 90 ... 27 29 30] [87 90 93 ... 27 28 30] [92 94 97 ... 39 28 29] ... [80 82 84 ... 36 30 26] [79 80 82 ... 28 26 26] [76 78 80 ... 26 26 25]] [ ] | 0% Completed | 383.81 us [########################################] | 100% Completed | 100.73 ms [ ] | 0% Completed | 139.64 us [########################################] | 100% Completed | 100.37 ms | .. code-block:: default import matplotlib.pyplot as plt import kikuchipy as kp # Load low resolution Ni patterns and check that the *static* background # pattern is stored with the signal s = kp.data.nickel_ebsd_small() print(s.static_background) s.remove_static_background() s2 = s.remove_dynamic_background(inplace=False) # Plot pattern before and after correction and the intensity histograms patterns = [s.inav[0, 0].data, s2.inav[0, 0].data] fig, axes = plt.subplots(2, 2, height_ratios=[3, 1.5]) for ax, pattern, title in zip(axes[0], patterns, ["Static", "Dynamic"]): ax.imshow(pattern, cmap="gray") ax.set_title(title) ax.axis("off") for ax, pattern in zip(axes[1], patterns): ax.hist(pattern.ravel(), bins=100) fig.tight_layout() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.561 seconds) **Estimated memory usage:** 10 MB .. _sphx_glr_download_examples_pattern_processing_dynamic_background_correction.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: dynamic_background_correction.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: dynamic_background_correction.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_