.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_09_reconstruct_astra.py: Example 09: Reconstruct data using ASTRA ======================================== .. code-block:: default import foam_ct_phantom import astra import numpy as np import h5py import pylab as pl pl.gray() # Run 03_generate_projections_parallel.py and 04_generate_projections_cone first projs = foam_ct_phantom.load_projections('test_projs_par.h5') vol_geom = foam_ct_phantom.VolumeGeometry(256, 256, 256, 3/256) proj_geom = foam_ct_phantom.ParallelGeometry.from_file('test_projs_par.h5') pg = proj_geom.to_astra(single_slice=True) vg = vol_geom.to_astra(single_slice=True) pid = astra.create_projector('cuda', pg, vg) w = astra.OpTomo(pid) mid_slice = w.reconstruct('FBP_CUDA', projs[:,projs.shape[1]//2]) pl.imshow(mid_slice) pl.show() astra.projector.delete(pid) projs = foam_ct_phantom.load_projections('test_projs_cone.h5') proj_geom = foam_ct_phantom.ConeGeometry.from_file('test_projs_cone.h5', usecuda=False) pg3d = proj_geom.to_astra() vg3d = vol_geom.to_astra() pid = astra.create_projector('cuda3d', pg3d, vg3d) w = astra.OpTomo(pid) cone_rec = w.reconstruct('FDK_CUDA', projs.swapaxes(0,1)) pl.imshow(cone_rec[cone_rec.shape[0]//2],vmin=0,vmax=3/256) pl.show() .. _sphx_glr_download_auto_examples_09_reconstruct_astra.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: 09_reconstruct_astra.py <09_reconstruct_astra.py>` .. container:: sphx-glr-download :download:`Download Jupyter notebook: 09_reconstruct_astra.ipynb <09_reconstruct_astra.ipynb>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_