Static background correction#

This example shows how to remove the static background of an EBSD pattern using remove_static_background().

More details are given in the pattern processing tutorial.

Raw, Static

Out:

[[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 | 806.72 us
[########################################] | 100% Completed | 103.28 ms

import matplotlib.pyplot as plt
import kikuchipy as kp


# Load low resolution Ni patterns and check that the background pattern
# is stored with the signal
s = kp.data.nickel_ebsd_small()
print(s.static_background)

# Keep original for comparison and remove background
s2 = s.deepcopy()
s2.remove_static_background()

# 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, ["Raw", "Static"]):
    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()

Total running time of the script: ( 0 minutes 0.900 seconds)

Estimated memory usage: 9 MB

Gallery generated by Sphinx-Gallery