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
[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:
[                                        ] | 0% Completed |  0.1s
/home/docs/checkouts/readthedocs.org/user_builds/kikuchipy/envs/stable/lib/python3.9/site-packages/kikuchipy/io/plugins/emsoft_ebsd_master_pattern.py:91: VisibleDeprecationWarning: `hemisphere` parameter options 'north' and 'south' are deprecated and will raise an error in version 0.7, use 'upper' and 'lower' instead. Changed to 'upper' or 'lower'.
  warnings.warn(
[########################################] | 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