File: s008_gpu_selection.m

package info (click to toggle)
astra-toolbox 2.3.0-5
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 4,972 kB
  • sloc: cpp: 24,378; python: 5,048; sh: 3,514; ansic: 1,181; makefile: 518
file content (37 lines) | stat: -rw-r--r-- 1,253 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
% -----------------------------------------------------------------------
% This file is part of the ASTRA Toolbox
% 
% Copyright: 2010-2022, imec Vision Lab, University of Antwerp
%            2014-2022, CWI, Amsterdam
% License: Open Source under GPLv3
% Contact: astra@astra-toolbox.com
% Website: http://www.astra-toolbox.com/
% -----------------------------------------------------------------------

% Switch to GPU #1. The default is GPU #0.
astra_set_gpu_index(1);

vol_geom = astra_create_vol_geom(256, 256);
proj_geom = astra_create_proj_geom('parallel', 1.0, 384, linspace2(0,pi,180));
P = phantom(256);

% Create a sinogram from a phantom.
[sinogram_id, sinogram] = astra_create_sino_gpu(P, proj_geom, vol_geom);


% Set up the parameters for a reconstruction algorithm using the GPU
rec_id = astra_mex_data2d('create', '-vol', vol_geom);
cfg = astra_struct('SIRT_CUDA');
cfg.ReconstructionDataId = rec_id;
cfg.ProjectionDataId = sinogram_id;

% Run 150 iterations of the algorithm
alg_id = astra_mex_algorithm('create', cfg);
astra_mex_algorithm('iterate', alg_id, 150);
rec = astra_mex_data2d('get', rec_id);


% Clean up.
astra_mex_algorithm('delete', alg_id);
astra_mex_data2d('delete', rec_id);
astra_mex_data2d('delete', sinogram_id);