summaryrefslogtreecommitdiffstats
path: root/samples/s007_3d_reconstruction.m
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <WillemJan.Palenstijn@uantwerpen.be>2013-07-01 22:34:11 +0000
committerwpalenst <WillemJan.Palenstijn@uantwerpen.be>2013-07-01 22:34:11 +0000
commitb2fc6c70434674d74551c3a6c01ffb3233499312 (patch)
treeb17f080ebc504ab85ebb7c3d89f917fd87ce9e00 /samples/s007_3d_reconstruction.m
downloadastra-b2fc6c70434674d74551c3a6c01ffb3233499312.tar.gz
astra-b2fc6c70434674d74551c3a6c01ffb3233499312.tar.bz2
astra-b2fc6c70434674d74551c3a6c01ffb3233499312.tar.xz
astra-b2fc6c70434674d74551c3a6c01ffb3233499312.zip
Update version to 1.3
Diffstat (limited to 'samples/s007_3d_reconstruction.m')
-rw-r--r--samples/s007_3d_reconstruction.m53
1 files changed, 53 insertions, 0 deletions
diff --git a/samples/s007_3d_reconstruction.m b/samples/s007_3d_reconstruction.m
new file mode 100644
index 0000000..1bc9da3
--- /dev/null
+++ b/samples/s007_3d_reconstruction.m
@@ -0,0 +1,53 @@
+%------------------------------------------------------------------------
+% This file is part of the
+% All Scale Tomographic Reconstruction Antwerp Toolbox ("ASTRA-Toolbox")
+%
+% Copyright: iMinds-Vision Lab, University of Antwerp
+% License: Open Source under GPLv3
+% Contact: mailto:astra@ua.ac.be
+% Website: http://astra.ua.ac.be
+%------------------------------------------------------------------------
+
+vol_geom = astra_create_vol_geom(128, 128, 128);
+
+angles = linspace2(0, pi, 180);
+proj_geom = astra_create_proj_geom('parallel3d', 1.0, 1.0, 128, 192, angles);
+
+% Create a simple hollow cube phantom
+cube = zeros(128,128,128);
+cube(17:112,17:112,17:112) = 1;
+cube(33:96,33:96,33:96) = 0;
+
+% Create projection data from this
+[proj_id, proj_data] = astra_create_sino3d_cuda(cube, proj_geom, vol_geom);
+
+% Display a single projection image
+figure, imshow(squeeze(proj_data(:,20,:))',[])
+
+% Create a data object for the reconstruction
+rec_id = astra_mex_data3d('create', '-vol', vol_geom);
+
+% Set up the parameters for a reconstruction algorithm using the GPU
+cfg = astra_struct('SIRT3D_CUDA');
+cfg.ReconstructionDataId = rec_id;
+cfg.ProjectionDataId = proj_id;
+
+
+% Create the algorithm object from the configuration structure
+alg_id = astra_mex_algorithm('create', cfg);
+
+% Run 150 iterations of the algorithm
+% Note that this requires about 750MB of GPU memory, and has a runtime
+% in the order of 10 seconds.
+astra_mex_algorithm('iterate', alg_id, 150);
+
+% Get the result
+rec = astra_mex_data3d('get', rec_id);
+figure, imshow(squeeze(rec(:,:,65)),[]);
+
+
+% Clean up. Note that GPU memory is tied up in the algorithm object,
+% and main RAM in the data objects.
+astra_mex_algorithm('delete', alg_id);
+astra_mex_data3d('delete', rec_id);
+astra_mex_data3d('delete', proj_id);