]> Creatis software - CreaPhase.git/blob - utilities_LW/astra_radon_3d.m
Useful functions for simulations (created by LW, free to use)
[CreaPhase.git] / utilities_LW / astra_radon_3d.m
1 function sino = astra_radon_3d(volume, theta)
2 % this function calculates 3D radon transform of the volume using ASTRA tools
3
4     sz = size(volume);
5     
6     % initialize ASTRA geometries:
7     proj_geom = astra_create_proj_geom('parallel3d', 1, 1, sz(3), sz(1), theta);
8     vol_geom = astra_create_vol_geom(sz(1), sz(2), sz(3));
9     %proj_id = astra_create_projector('linear3d', proj_geom, vol_geom);
10     %proj_id = astra_create_projector('cuda3d', proj_geom, vol_geom);
11     
12     % copy data to GPU:  
13     volume_id = astra_mex_data3d('create','-vol', vol_geom, volume);
14         sino_id = astra_mex_data3d('create','-sino', proj_geom, 0);
15     
16     % initialize algorithm:
17     cfg = astra_struct('FP3D_CUDA');
18     %cfg = astra_struct('FP_CUDA');
19     %cfg.ProjectorId = proj_id;
20     %cfg.ProjectionGeometry = proj_geom;
21     %cfg.VolumeGeometry = vol_geom;     
22         cfg.ProjectionDataId = sino_id;
23         cfg.VolumeDataId = volume_id;
24         
25         % run algorithm:
26         alg_id = astra_mex_algorithm('create', cfg);
27         astra_mex_algorithm('iterate', alg_id);
28
29         % get data:
30         sino = astra_mex_data3d('get',sino_id);
31
32     % kill stuff:
33     astra_mex_data3d('delete', sino_id);
34     astra_mex_data3d('delete', volume_id);
35     astra_mex_algorithm('delete', alg_id);
36    % astra_mex_projector('delete', proj_id);
37 end