{ "cells": [ { "cell_type": "markdown", "id": "224d81d5-6bd5-4b9a-835d-e834b91cfaae", "metadata": { "nbsphinx": "hidden" }, "source": [ "This notebook is part of the `kikuchipy` documentation https://kikuchipy.org.\n", "Links to the documentation won't work from the notebook." ] }, { "cell_type": "markdown", "id": "cedd5286-69f4-476b-8926-43a62ac48c22", "metadata": {}, "source": [ "# Save nice master pattern image\n", "\n", "This example shows how to save a master pattern in the stereographic projection\n", "without a background to file." ] }, { "cell_type": "code", "execution_count": null, "id": "interpreted-fifteen", "metadata": { "tags": [] }, "outputs": [], "source": [ "%matplotlib inline\n", "\n", "import kikuchipy as kp\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "from skimage.color import gray2rgba" ] }, { "cell_type": "code", "execution_count": null, "id": "dab2474d-166c-419c-a9c4-7af18c48d171", "metadata": {}, "outputs": [], "source": [ "mp = kp.data.nickel_ebsd_master_pattern_small(\n", " projection=\"stereographic\",\n", " energy=20,\n", " hemisphere=\"north\"\n", ")\n", "\n", "mp.rescale_intensity(out_range=np.float32)\n", "data = gray2rgba(mp.data)\n", "mask = data[..., 0] == 0\n", "data[mask, -1] = 0" ] }, { "cell_type": "code", "execution_count": null, "id": "43c1376d-1dfa-4f94-8979-f3871dd135d2", "metadata": { "tags": [ "nbsphinx-thumbnail" ] }, "outputs": [], "source": [ "plt.figure()\n", "plt.imshow(data)\n", "plt.axis(\"off\");\n", "\n", "#plt.imsave(\"masterpattern.png\", arr=data, cmap=\"gray\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 5 }