{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Ch2" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "import SimpleITK as sitk" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "image = sitk.Image(256, 128, 64, sitk.sitkInt16)\n", "image_2D = sitk.Image(64, 64, sitk.sitkFloat32)\n", "image_2D = sitk.Image([32,32], sitk.sitkUInt32)\n", "image_RGB = sitk.Image([128,128], sitk.sitkVectorUInt8, 3)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "nda = sitk.GetArrayFromImage(image)\n", "print(nda)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.imshow(nda[0,:,:])" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.9.5" } }, "nbformat": 4, "nbformat_minor": 4 }