summaryrefslogtreecommitdiffstats
path: root/Wrappers
diff options
context:
space:
mode:
authorjakobsj <jakobsj@users.noreply.github.com>2018-03-06 13:16:24 +0000
committerEdoardo Pasca <edo.paskino@gmail.com>2018-03-06 13:16:24 +0000
commit3762017c49a8ba9e5a5adecdf15abd8c0b775e96 (patch)
treec00dcb88de96b1588f7dee4ce6e3b5427ba38c16 /Wrappers
parent5b209188e476bbd177d97d0e5010a5d1417c453d (diff)
downloadframework-3762017c49a8ba9e5a5adecdf15abd8c0b775e96.tar.gz
framework-3762017c49a8ba9e5a5adecdf15abd8c0b775e96.tar.bz2
framework-3762017c49a8ba9e5a5adecdf15abd8c0b775e96.tar.xz
framework-3762017c49a8ba9e5a5adecdf15abd8c0b775e96.zip
Added all parallel/cone/2D/3D operators and updated simple_demo to test cone 2D (#35)
Diffstat (limited to 'Wrappers')
-rw-r--r--Wrappers/Python/ccpi/reconstruction/astra_ops.py60
-rw-r--r--Wrappers/Python/test/simple_demo.py27
2 files changed, 74 insertions, 13 deletions
diff --git a/Wrappers/Python/ccpi/reconstruction/astra_ops.py b/Wrappers/Python/ccpi/reconstruction/astra_ops.py
index 6d527ba..452c86a 100644
--- a/Wrappers/Python/ccpi/reconstruction/astra_ops.py
+++ b/Wrappers/Python/ccpi/reconstruction/astra_ops.py
@@ -33,21 +33,61 @@ class AstraProjectorSimple(Operator):
self.volume_geometry = geomv
# ASTRA Volume geometry
- self.vol_geom = astra.create_vol_geom(geomv.voxel_num_x, \
- geomv.voxel_num_y, \
- geomv.getMinX(), \
- geomv.getMaxX(), \
- geomv.getMinY(), \
- geomv.getMaxY())
+ if geomp.dimension == '2D':
+ self.vol_geom = astra.create_vol_geom(geomv.voxel_num_x,
+ geomv.voxel_num_y,
+ geomv.getMinX(),
+ geomv.getMaxX(),
+ geomv.getMinY(),
+ geomv.getMaxY())
+ elif geomp.dimension == '3D':
+ self.vol_geom = astra.create_vol_geom(geomv.voxel_num_x,
+ geomv.voxel_num_y,
+ geomv.voxel_num_z,
+ geomv.getMinX(),
+ geomv.getMaxX(),
+ geomv.getMinY(),
+ geomv.getMaxY(),
+ geomv.getMinZ(),
+ geomv.getMaxZ())
+ else:
+ NotImplemented
+
# ASTRA Projections geometry
if geomp.dimension == '2D':
if geomp.geom_type == 'parallel':
- self.proj_geom = astra.create_proj_geom('parallel', \
- geomp.pixel_size_h, \
- geomp.pixel_num_h, \
- geomp.angles)
+ self.proj_geom = astra.create_proj_geom('parallel',
+ geomp.pixel_size_h,
+ geomp.pixel_num_h,
+ geomp.angles)
+ elif geomp.geom_type == 'cone':
+ self.proj_geom = astra.create_proj_geom('fanflat',
+ geomp.pixel_size_h,
+ geomp.pixel_num_h,
+ geomp.angles,
+ geomp.dist_source_center,
+ geomp.dist_center_detector)
+ else:
+ NotImplemented
+ elif geomp.dimension == '3D':
+ if geomp.proj_geom == 'parallel':
+ self.proj_geom = astra.create_proj_geom('parallel3d',
+ geomp.pixel_size_h,
+ geomp.pixel_size_v,
+ geomp.pixel_num_v,
+ geomp.pixel_num_h,
+ geomp.angles)
elif geomp.geom_type == 'cone':
+ self.proj_geom = astra.create_proj_geom('cone',
+ geomp.pixel_size_h,
+ geomp.pixel_size_v,
+ geomp.pixel_num_v,
+ geomp.pixel_num_h,
+ geomp.angles,
+ geomp.dist_source_center,
+ geomp.dist_center_detector)
+ else:
NotImplemented
else:
NotImplemented
diff --git a/Wrappers/Python/test/simple_demo.py b/Wrappers/Python/test/simple_demo.py
index 7a28ae9..1046e7b 100644
--- a/Wrappers/Python/test/simple_demo.py
+++ b/Wrappers/Python/test/simple_demo.py
@@ -13,6 +13,8 @@ from ccpi.reconstruction.geoms import *
import numpy as np
import matplotlib.pyplot as plt
+test_case = 2 # 1=parallel2D, 2=cone2D
+
# Set up phantom
N = 128
@@ -29,14 +31,33 @@ Phantom = VolumeData(x,geometry=vg)
# Set up measurement geometry
angles_num = 20; # angles number
-angles = np.linspace(0,np.pi,angles_num,endpoint=False)
+
+if test_case==1:
+ angles = np.linspace(0,np.pi,angles_num,endpoint=False)
+elif test_case==2:
+ angles = np.linspace(0,2*np.pi,angles_num,endpoint=False)
+else:
+ NotImplemented
+
det_w = 1.0
det_num = N
-SourceOrig = 500
+SourceOrig = 200
OrigDetec = 0
# Parallelbeam geometry test
-pg = SinogramGeometry('parallel','2D',angles,det_num,det_w)
+if test_case==1:
+ pg = SinogramGeometry('parallel',
+ '2D',
+ angles,
+ det_num,det_w)
+elif test_case==2:
+ pg = SinogramGeometry('cone',
+ '2D',
+ angles,
+ det_num,
+ det_w,
+ dist_source_center=SourceOrig,
+ dist_center_detector=OrigDetec)
# ASTRA operator using volume and sinogram geometries
Aop = AstraProjectorSimple(vg, pg, 'gpu')