summaryrefslogtreecommitdiffstats
path: root/python/astra/data3d.py
diff options
context:
space:
mode:
authorDaniel M. Pelt <D.M.Pelt@cwi.nl>2015-04-09 15:44:01 +0200
committerDaniel M. Pelt <D.M.Pelt@cwi.nl>2015-04-09 15:44:01 +0200
commit1b32573046f33050b9300324e6c74e10abb6caaf (patch)
treec211a5d749faabfbe36fa4b93dd3482328fc4715 /python/astra/data3d.py
parent3042b1369a96eef4798ea4280dd7aa1a8be2fcca (diff)
downloadastra-1b32573046f33050b9300324e6c74e10abb6caaf.tar.gz
astra-1b32573046f33050b9300324e6c74e10abb6caaf.tar.bz2
astra-1b32573046f33050b9300324e6c74e10abb6caaf.tar.xz
astra-1b32573046f33050b9300324e6c74e10abb6caaf.zip
Add 'link' feature to Python (for 2D and 3D data)
Diffstat (limited to 'python/astra/data3d.py')
-rw-r--r--python/astra/data3d.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/python/astra/data3d.py b/python/astra/data3d.py
index a2e9201..4fdf9d7 100644
--- a/python/astra/data3d.py
+++ b/python/astra/data3d.py
@@ -24,6 +24,7 @@
#
#-----------------------------------------------------------------------
from . import data3d_c as d
+import numpy as np
def create(datatype,geometry,data=None):
"""Create a 3D object.
@@ -39,6 +40,27 @@ def create(datatype,geometry,data=None):
"""
return d.create(datatype,geometry,data)
+def link(datatype, geometry, data):
+ """Link a 3D numpy array with the toolbox.
+
+ :param datatype: Data object type, '-vol' or '-sino'.
+ :type datatype: :class:`string`
+ :param geometry: Volume or projection geometry.
+ :type geometry: :class:`dict`
+ :param data: Numpy array to link
+ :type data: :class:`numpy.ndarray`
+ :returns: :class:`int` -- the ID of the constructed object.
+
+ """
+ if not isinstance(data,np.ndarray):
+ raise ValueError("Input should be a numpy array")
+ if not data.dtype==np.float32:
+ raise ValueError("Numpy array should be float32")
+ if not (data.flags['C_CONTIGUOUS'] and data.flags['ALIGNED']):
+ raise ValueError("Numpy array should be C_CONTIGUOUS and ALIGNED")
+ return d.create(datatype,geometry,data,True)
+
+
def get(i):
"""Get a 3D object.