]> Creatis software - CreaPhase.git/blobdiff - utilities_LW/astra_iradon_3d.m
Useful functions for simulations (created by LW, free to use)
[CreaPhase.git] / utilities_LW / astra_iradon_3d.m
diff --git a/utilities_LW/astra_iradon_3d.m b/utilities_LW/astra_iradon_3d.m
new file mode 100644 (file)
index 0000000..ba74957
--- /dev/null
@@ -0,0 +1,32 @@
+function vol = astra_iradon_3d(sino, theta)
+% this function calculates 3D iradon transform of the volume using ASTRA tools
+
+    sz = size(sino);
+    
+    % initialize ASTRA projector:
+    proj_geom = astra_create_proj_geom('parallel3d', 1, 1, sz(3), sz(1), theta);
+    vol_geom = astra_create_vol_geom(sz(1), sz(1), sz(3));
+    %proj_id = astra_create_projector('linear3d', proj_geom, vol_geom);
+    
+    % copy data to GPU:  
+    volume_id = astra_mex_data3d('create','-vol', vol_geom, 0);
+       sino_id = astra_mex_data3d('create','-sino', proj_geom, sino);
+    
+    % initialize algorithm:
+    cfg = astra_struct('BP3D_CUDA');
+    %cfg.ProjectorId = proj_id;
+    cfg.ProjectionDataId = sino_id;
+    cfg.ReconstructionDataId = volume_id;
+    %cfg.FilterType = 'none';
+
+    % run:
+    alg_id = astra_mex_algorithm('create', cfg);
+    astra_mex_algorithm('run', alg_id);
+    vol = astra_mex_data3d('get', volume_id) * 2 * size(proj_geom.ProjectionAngles,2) / pi;
+
+    % kill stuff:
+    astra_mex_data3d('delete', sino_id);
+    astra_mex_data3d('delete', volume_id);
+    astra_mex_algorithm('delete', alg_id);
+    %astra_mex_projector('delete', proj_id);
+end
\ No newline at end of file