]> Creatis software - CreaPhase.git/blob - utilities_LW/astra_iradon_3d.m
Useful functions for simulations (created by LW, free to use)
[CreaPhase.git] / utilities_LW / astra_iradon_3d.m
1 function vol = astra_iradon_3d(sino, theta)
2 % this function calculates 3D iradon transform of the volume using ASTRA tools
3
4     sz = size(sino);
5     
6     % initialize ASTRA projector:
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(1), sz(3));
9     %proj_id = astra_create_projector('linear3d', proj_geom, vol_geom);
10     
11     % copy data to GPU:  
12     volume_id = astra_mex_data3d('create','-vol', vol_geom, 0);
13         sino_id = astra_mex_data3d('create','-sino', proj_geom, sino);
14     
15     % initialize algorithm:
16     cfg = astra_struct('BP3D_CUDA');
17     %cfg.ProjectorId = proj_id;
18     cfg.ProjectionDataId = sino_id;
19     cfg.ReconstructionDataId = volume_id;
20     %cfg.FilterType = 'none';
21
22     % run:
23     alg_id = astra_mex_algorithm('create', cfg);
24     astra_mex_algorithm('run', alg_id);
25     vol = astra_mex_data3d('get', volume_id) * 2 * size(proj_geom.ProjectionAngles,2) / pi;
26
27     % kill stuff:
28     astra_mex_data3d('delete', sino_id);
29     astra_mex_data3d('delete', volume_id);
30     astra_mex_algorithm('delete', alg_id);
31     %astra_mex_projector('delete', proj_id);
32 end