]> Creatis software - CreaPhase.git/blobdiff - utilities_LW/astra_radon_3d.m
Useful functions for simulations (created by LW, free to use)
[CreaPhase.git] / utilities_LW / astra_radon_3d.m
diff --git a/utilities_LW/astra_radon_3d.m b/utilities_LW/astra_radon_3d.m
new file mode 100644 (file)
index 0000000..5574a68
--- /dev/null
@@ -0,0 +1,37 @@
+function sino = astra_radon_3d(volume, theta)
+% this function calculates 3D radon transform of the volume using ASTRA tools
+
+    sz = size(volume);
+    
+    % initialize ASTRA geometries:
+    proj_geom = astra_create_proj_geom('parallel3d', 1, 1, sz(3), sz(1), theta);
+    vol_geom = astra_create_vol_geom(sz(1), sz(2), sz(3));
+    %proj_id = astra_create_projector('linear3d', proj_geom, vol_geom);
+    %proj_id = astra_create_projector('cuda3d', proj_geom, vol_geom);
+    
+    % copy data to GPU:  
+    volume_id = astra_mex_data3d('create','-vol', vol_geom, volume);
+       sino_id = astra_mex_data3d('create','-sino', proj_geom, 0);
+    
+    % initialize algorithm:
+    cfg = astra_struct('FP3D_CUDA');
+    %cfg = astra_struct('FP_CUDA');
+    %cfg.ProjectorId = proj_id;
+    %cfg.ProjectionGeometry = proj_geom;
+    %cfg.VolumeGeometry = vol_geom;    
+       cfg.ProjectionDataId = sino_id;
+       cfg.VolumeDataId = volume_id;
+        
+       % run algorithm:
+       alg_id = astra_mex_algorithm('create', cfg);
+       astra_mex_algorithm('iterate', alg_id);
+
+       % get data:
+       sino = astra_mex_data3d('get',sino_id);
+
+    % 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