summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2020-06-23 13:46:35 +0200
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2020-07-02 15:54:12 +0200
commitecfb65a05b8ed5171ad65173581d5fe328926995 (patch)
tree8b21867065c27e7e9ea22ee9fc94f30801086bef /python
parentb8bf069f375424fd303ad6e594412583633c1110 (diff)
downloadastra-ecfb65a05b8ed5171ad65173581d5fe328926995.tar.gz
astra-ecfb65a05b8ed5171ad65173581d5fe328926995.tar.bz2
astra-ecfb65a05b8ed5171ad65173581d5fe328926995.tar.xz
astra-ecfb65a05b8ed5171ad65173581d5fe328926995.zip
Add python astra.experimental.direct_FP3D/BP3D
Diffstat (limited to 'python')
-rw-r--r--python/astra/experimental.pyx54
1 files changed, 54 insertions, 0 deletions
diff --git a/python/astra/experimental.pyx b/python/astra/experimental.pyx
index 8f8e47d..25ecb24 100644
--- a/python/astra/experimental.pyx
+++ b/python/astra/experimental.pyx
@@ -121,3 +121,57 @@ IF HAVE_CUDA==True:
cdef CProjector3D * projector = manProj.get(projector_id) # may be NULL
if not m.doFDK(projector, pVolObject, pProjObject, False, NULL, MODE_ADD):
raise Exception("Failed to perform FDK")
+
+ cimport utils
+ from .utils cimport linkVolFromGeometry, linkProjFromGeometry
+
+ def direct_FPBP3D(projector_id, vol, proj, t):
+ cdef CProjector3D * projector = manProj.get(projector_id)
+ if projector == NULL:
+ raise Exception("Projector not found")
+ cdef CVolumeGeometry3D *pGeometry = projector.getVolumeGeometry()
+ cdef CProjectionGeometry3D *ppGeometry = projector.getProjectionGeometry()
+ cdef CFloat32VolumeData3D * pVol = linkVolFromGeometry(pGeometry, vol)
+ cdef CFloat32ProjectionData3D * pProj = linkProjFromGeometry(ppGeometry, proj)
+ cdef vector[CFloat32VolumeData3D *] vols
+ cdef vector[CFloat32ProjectionData3D *] projs
+ vols.push_back(pVol)
+ projs.push_back(pProj)
+ cdef CCompositeGeometryManager m
+ try:
+ if t == "FP":
+ if not m.doFP(projector, vols, projs, MODE_SET):
+ raise Exception("Failed to perform FP")
+ elif t == "BP":
+ if not m.doBP(projector, vols, projs, MODE_SET):
+ raise Exception("Failed to perform BP")
+ else:
+ raise RuntimeError("internal error: wrong op type")
+ finally:
+ del pVol
+ del pProj
+
+ def direct_FP3D(projector_id, vol, proj):
+ """Perform a 3D forward projection with pre-allocated input/output.
+
+ :param projector_id: A 3D projector object handle
+ :type datatype: :class:`int`
+ :param vol: The input data, as either a numpy array, or a GPULink object
+ :type datatype: :class:`numpy.ndarray` or :class:`astra.data3d.GPULink`
+ :param proj: The pre-allocated output data, either numpy array or GPULink
+ :type datatype: :class:`numpy.ndarray` or :class:`astra.data3d.GPULink`
+ """
+ direct_FPBP3D(projector_id, vol, proj, "FP")
+
+ def direct_BP3D(projector_id, vol, proj):
+ """Perform a 3D back projection with pre-allocated input/output.
+
+ :param projector_id: A 3D projector object handle
+ :type datatype: :class:`int`
+ :param vol: The input data, as either a numpy array, or a GPULink object
+ :type datatype: :class:`numpy.ndarray` or :class:`astra.data3d.GPULink`
+ :param proj: The pre-allocated output data, either numpy array or GPULink
+ :type datatype: :class:`numpy.ndarray` or :class:`astra.data3d.GPULink`
+ """
+ direct_FPBP3D(projector_id, vol, proj, "BP")
+