{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import tomopy\n", "import matplotlib.pyplot as plt\n", "\n", "rec = dict() # Store all of the different reconstructions here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Data import\n", "\n", "Common tomography data formats are imported through [DXchange](http://dxchange.readthedocs.org/en/latest/source/api/dxchange.exchange.html) (available through Conda):\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import dxchange as dx" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "prj, flat, dark, ang = dx.read_aps_32id('data/data-simulated.h5')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "rec = dict()\n", "rec['before'] = tomopy.recon(prj, ang, algorithm='gridrec', num_gridx=128, num_gridy=128)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Poisson noise and zinger removal" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "z = 1 # slice that has the poisson noise\n", "prj_corrected = tomopy.median_filter(prj, axis=0)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "z = 1\n", "plt.figure(dpi=150)\n", "plt.subplot(1, 2, 1)\n", "plt.title('before')\n", "plt.imshow(prj[:, z, :])\n", "plt.subplot(1, 2, 2)\n", "plt.title('after')\n", "plt.imshow(prj_corrected[:, z, :])\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "rec['after'] = tomopy.recon(prj_corrected, ang, algorithm='gridrec', num_gridx=128, num_gridy=128)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.figure(dpi=150)\n", "plt.subplot(1, 2, 1)\n", "plt.title('before')\n", "plt.imshow(rec['before'][z], vmin=0, vmax=255)\n", "plt.subplot(1, 2, 2)\n", "plt.title('after')\n", "plt.imshow(rec['after'][z], vmin=0, vmax=255)\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "z = 2 # slice that has the zingers" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.figure(dpi=150)\n", "plt.subplot(1, 2, 1)\n", "plt.title('before')\n", "plt.imshow(prj[:, z, :])\n", "plt.subplot(1, 2, 2)\n", "plt.title('after')\n", "plt.imshow(prj_corrected[:, z, :])\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.figure(dpi=150)\n", "plt.subplot(1, 2, 1)\n", "plt.title('before')\n", "plt.imshow(rec['before'][z], vmin=0, vmax=255)\n", "plt.subplot(1, 2, 2)\n", "plt.title('after')\n", "plt.imshow(rec['after'][z], vmin=0, vmax=255)\n", "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Ring Removal" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "z = 3 # slice that has the rings\n", "prj_corrected = tomopy.remove_stripe_based_filtering(prj)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.figure(dpi=150)\n", "plt.subplot(1, 2, 1)\n", "plt.title('before')\n", "plt.imshow(prj[:, z, :])\n", "plt.subplot(1, 2, 2)\n", "plt.title('after')\n", "plt.imshow(prj_corrected[:, z, :])\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "rec['after'] = tomopy.recon(prj_corrected, ang, algorithm='gridrec', num_gridx=128, num_gridy=128)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.figure(dpi=150)\n", "plt.subplot(1, 2, 1)\n", "plt.title('before')\n", "plt.imshow(rec['before'][z], vmin=0, vmax=255)\n", "plt.subplot(1, 2, 2)\n", "plt.title('after')\n", "plt.imshow(rec['after'][z], vmin=0, vmax=255)\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "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.6.7" } }, "nbformat": 4, "nbformat_minor": 1 }