This page was generated from doc/examples/save_nice_master_pattern_image.ipynb. Interactive online version: Binder badge.

Save nice master pattern imageΒΆ

This example shows how to save a master pattern in the stereographic projection without a background to file.

[1]:
%matplotlib inline

import kikuchipy as kp
import matplotlib.pyplot as plt
import numpy as np
from skimage.color import gray2rgba
WARNING:hyperspy.api:The ipywidgets GUI elements are not available, probably because the hyperspy_gui_ipywidgets package is not installed.
WARNING:hyperspy.api:The traitsui GUI elements are not available, probably because the hyperspy_gui_traitsui package is not installed.
[2]:
mp = kp.data.nickel_ebsd_master_pattern_small(
    projection="stereographic",
    energy=20,
    hemisphere="north"
)

mp.rescale_intensity(out_range=np.float32)
data = gray2rgba(mp.data)
mask = data[..., 0] == 0
data[mask, -1] = 0
Rescaling the image intensities:
[########################################] | 100% Completed |  0.3s
[3]:
plt.figure()
plt.imshow(data)
plt.axis("off");

#plt.imsave("masterpattern.png", arr=data, cmap="gray")
../_images/examples_save_nice_master_pattern_image_4_0.png