summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <wjp@usecode.org>2015-06-26 12:01:09 +0200
committerWillem Jan Palenstijn <wjp@usecode.org>2015-06-26 12:01:09 +0200
commitba092a5602abba8b1a4bd17988dee6b567f02b7a (patch)
treee7addffc79f6871c4d93338064f08a0347692047
parent62f3aa5792011792db866ce0841c8d164aa9a34d (diff)
parent233331b4a192c0149f58af1d4c89526260cd3a58 (diff)
downloadastra-ba092a5602abba8b1a4bd17988dee6b567f02b7a.tar.gz
astra-ba092a5602abba8b1a4bd17988dee6b567f02b7a.tar.bz2
astra-ba092a5602abba8b1a4bd17988dee6b567f02b7a.tar.xz
astra-ba092a5602abba8b1a4bd17988dee6b567f02b7a.zip
Merge pull request #75 from wjp/cuda_options
Move supersampling options from Algorithm to CudaProjector
-rw-r--r--include/astra/CudaProjector2D.h6
-rw-r--r--include/astra/CudaProjector3D.h5
-rw-r--r--samples/matlab/s010_supersampling.m28
-rw-r--r--src/CudaBackProjectionAlgorithm3D.cpp14
-rw-r--r--src/CudaCglsAlgorithm3D.cpp22
-rw-r--r--src/CudaFDKAlgorithm3D.cpp13
-rw-r--r--src/CudaFilteredBackProjectionAlgorithm.cpp27
-rw-r--r--src/CudaForwardProjectionAlgorithm.cpp38
-rw-r--r--src/CudaForwardProjectionAlgorithm3D.cpp16
-rw-r--r--src/CudaProjector2D.cpp8
-rw-r--r--src/CudaProjector3D.cpp8
-rw-r--r--src/CudaReconstructionAlgorithm2D.cpp44
-rw-r--r--src/CudaSirtAlgorithm3D.cpp23
-rw-r--r--src/ReconstructionAlgorithm3D.cpp18
14 files changed, 197 insertions, 73 deletions
diff --git a/include/astra/CudaProjector2D.h b/include/astra/CudaProjector2D.h
index a571851..ecfca41 100644
--- a/include/astra/CudaProjector2D.h
+++ b/include/astra/CudaProjector2D.h
@@ -121,9 +121,15 @@ public:
virtual std::string description() const;
+ Cuda2DProjectionKernel getProjectionKernel() const { return m_projectionKernel; }
+ int getVoxelSuperSampling() const { return m_iVoxelSuperSampling; }
+ int getDetectorSuperSampling() const { return m_iDetectorSuperSampling; }
+
protected:
Cuda2DProjectionKernel m_projectionKernel;
+ int m_iVoxelSuperSampling;
+ int m_iDetectorSuperSampling;
};
//----------------------------------------------------------------------------------------
diff --git a/include/astra/CudaProjector3D.h b/include/astra/CudaProjector3D.h
index a181531..1d570fe 100644
--- a/include/astra/CudaProjector3D.h
+++ b/include/astra/CudaProjector3D.h
@@ -115,11 +115,14 @@ public:
Cuda3DProjectionKernel getProjectionKernel() const { return m_projectionKernel; }
+ int getVoxelSuperSampling() const { return m_iVoxelSuperSampling; }
+ int getDetectorSuperSampling() const { return m_iDetectorSuperSampling; }
protected:
Cuda3DProjectionKernel m_projectionKernel;
-
+ int m_iVoxelSuperSampling;
+ int m_iDetectorSuperSampling;
};
diff --git a/samples/matlab/s010_supersampling.m b/samples/matlab/s010_supersampling.m
index 80f6f56..148f6ad 100644
--- a/samples/matlab/s010_supersampling.m
+++ b/samples/matlab/s010_supersampling.m
@@ -12,23 +12,15 @@ vol_geom = astra_create_vol_geom(256, 256);
proj_geom = astra_create_proj_geom('parallel', 3.0, 128, linspace2(0,pi,180));
P = phantom(256);
-% Because the astra_create_sino_gpu wrapper does not have support for
-% all possible algorithm options, we manually create a sinogram
-phantom_id = astra_mex_data2d('create', '-vol', vol_geom, P);
-sinogram_id = astra_mex_data2d('create', '-sino', proj_geom);
-cfg = astra_struct('FP_CUDA');
-cfg.VolumeDataId = phantom_id;
-cfg.ProjectionDataId = sinogram_id;
+% We create a projector set up to use 3 rays per detector element
+cfg_proj = astra_struct('cuda');
+cfg_proj.option.DetectorSuperSampling = 3;
+cfg_proj.ProjectionGeometry = proj_geom;
+cfg_proj.VolumeGeometry = vol_geom;
+proj_id = astra_mex_projector('create', cfg_proj);
-% Set up 3 rays per detector element
-cfg.option.DetectorSuperSampling = 3;
-alg_id = astra_mex_algorithm('create', cfg);
-astra_mex_algorithm('run', alg_id);
-astra_mex_algorithm('delete', alg_id);
-astra_mex_data2d('delete', phantom_id);
-
-sinogram3 = astra_mex_data2d('get', sinogram_id);
+[sinogram3 sinogram_id] = astra_create_sino(P, proj_id);
figure(1); imshow(P, []);
figure(2); imshow(sinogram3, []);
@@ -39,14 +31,14 @@ rec_id = astra_mex_data2d('create', '-vol', vol_geom);
cfg = astra_struct('SIRT_CUDA');
cfg.ReconstructionDataId = rec_id;
cfg.ProjectionDataId = sinogram_id;
-% Set up 3 rays per detector element
-cfg.option.DetectorSuperSampling = 3;
+cfg.ProjectorId = proj_id;
+
% There is also an option for supersampling during the backprojection step.
% This should be used if your detector pixels are smaller than the voxels.
% Set up 2 rays per image pixel dimension, for 4 rays total per image pixel.
-% cfg.option.PixelSuperSampling = 2;
+% cfg_proj.option.PixelSuperSampling = 2;
alg_id = astra_mex_algorithm('create', cfg);
diff --git a/src/CudaBackProjectionAlgorithm3D.cpp b/src/CudaBackProjectionAlgorithm3D.cpp
index fbb8f28..e8e0433 100644
--- a/src/CudaBackProjectionAlgorithm3D.cpp
+++ b/src/CudaBackProjectionAlgorithm3D.cpp
@@ -32,6 +32,7 @@ $Id$
#include "astra/AstraObjectManager.h"
+#include "astra/CudaProjector3D.h"
#include "astra/ConeProjectionGeometry3D.h"
#include "astra/ParallelProjectionGeometry3D.h"
#include "astra/ParallelVecProjectionGeometry3D.h"
@@ -102,9 +103,20 @@ bool CCudaBackProjectionAlgorithm3D::initialize(const Config& _cfg)
return false;
}
+ CCudaProjector3D* pCudaProjector = 0;
+ pCudaProjector = dynamic_cast<CCudaProjector3D*>(m_pProjector);
+ if (!pCudaProjector) {
+ // TODO: Report
+ }
+
m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
CC.markOptionParsed("GPUindex");
- m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", 1);
+
+
+ m_iVoxelSuperSampling = 1;
+ if (pCudaProjector)
+ m_iVoxelSuperSampling = pCudaProjector->getVoxelSuperSampling();
+ m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", m_iVoxelSuperSampling);
CC.markOptionParsed("VoxelSuperSampling");
CFloat32ProjectionData3DMemory* pSinoMem = dynamic_cast<CFloat32ProjectionData3DMemory*>(m_pSinogram);
diff --git a/src/CudaCglsAlgorithm3D.cpp b/src/CudaCglsAlgorithm3D.cpp
index 3457b81..f527dc5 100644
--- a/src/CudaCglsAlgorithm3D.cpp
+++ b/src/CudaCglsAlgorithm3D.cpp
@@ -32,6 +32,7 @@ $Id$
#include "astra/AstraObjectManager.h"
+#include "astra/CudaProjector3D.h"
#include "astra/ConeProjectionGeometry3D.h"
#include "astra/ParallelVecProjectionGeometry3D.h"
#include "astra/ConeVecProjectionGeometry3D.h"
@@ -106,12 +107,27 @@ bool CCudaCglsAlgorithm3D::initialize(const Config& _cfg)
return false;
}
+ CCudaProjector3D* pCudaProjector = 0;
+ pCudaProjector = dynamic_cast<CCudaProjector3D*>(m_pProjector);
+ if (!pCudaProjector) {
+ // TODO: Report
+ }
+
m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
CC.markOptionParsed("GPUindex");
- m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", 1);
- CC.markOptionParsed("DetectorSuperSampling");
- m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", 1);
+
+ m_iVoxelSuperSampling = 1;
+ m_iDetectorSuperSampling = 1;
+ if (pCudaProjector) {
+ // New interface
+ m_iVoxelSuperSampling = pCudaProjector->getVoxelSuperSampling();
+ m_iDetectorSuperSampling = pCudaProjector->getDetectorSuperSampling();
+ }
+ // Deprecated options
+ m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", m_iVoxelSuperSampling);
+ m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", m_iDetectorSuperSampling);
CC.markOptionParsed("VoxelSuperSampling");
+ CC.markOptionParsed("DetectorSuperSampling");
m_pCgls = new AstraCGLS3d();
diff --git a/src/CudaFDKAlgorithm3D.cpp b/src/CudaFDKAlgorithm3D.cpp
index 467e641..667d926 100644
--- a/src/CudaFDKAlgorithm3D.cpp
+++ b/src/CudaFDKAlgorithm3D.cpp
@@ -32,6 +32,7 @@ $Id$
#include "astra/AstraObjectManager.h"
+#include "astra/CudaProjector3D.h"
#include "astra/ConeProjectionGeometry3D.h"
#include "../cuda/3d/astra3d.h"
@@ -100,9 +101,19 @@ bool CCudaFDKAlgorithm3D::initialize(const Config& _cfg)
return false;
}
+ CCudaProjector3D* pCudaProjector = 0;
+ pCudaProjector = dynamic_cast<CCudaProjector3D*>(m_pProjector);
+ if (!pCudaProjector) {
+ // TODO: Report
+ }
+
m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
CC.markOptionParsed("GPUindex");
- m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", 1);
+
+ m_iVoxelSuperSampling = 1;
+ if (pCudaProjector)
+ m_iVoxelSuperSampling = pCudaProjector->getVoxelSuperSampling();
+ m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", m_iVoxelSuperSampling);
CC.markOptionParsed("VoxelSuperSampling");
m_bShortScan = _cfg.self.getOptionBool("ShortScan", false);
diff --git a/src/CudaFilteredBackProjectionAlgorithm.cpp b/src/CudaFilteredBackProjectionAlgorithm.cpp
index 5d6c166..aac96d6 100644
--- a/src/CudaFilteredBackProjectionAlgorithm.cpp
+++ b/src/CudaFilteredBackProjectionAlgorithm.cpp
@@ -32,6 +32,7 @@ $Id$
#include <cstring>
#include "astra/AstraObjectManager.h"
+#include "astra/CudaProjector2D.h"
#include "../cuda/2d/astra.h"
#include "astra/Logging.h"
@@ -77,8 +78,22 @@ bool CCudaFilteredBackProjectionAlgorithm::initialize(const Config& _cfg)
clear();
}
+ // Projector
+ XMLNode node = _cfg.self.getSingleNode("ProjectorId");
+ CCudaProjector2D* pCudaProjector = 0;
+ if (node) {
+ int id = boost::lexical_cast<int>(node.getContent());
+ CProjector2D *projector = CProjector2DManager::getSingleton().get(id);
+ pCudaProjector = dynamic_cast<CCudaProjector2D*>(projector);
+ if (!pCudaProjector) {
+ ASTRA_WARN("non-CUDA Projector2D passed");
+ }
+ }
+ CC.markNodeParsed("ProjectorId");
+
+
// sinogram data
- XMLNode node = _cfg.self.getSingleNode("ProjectionDataId");
+ node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "CudaFBP", "No ProjectionDataId tag specified.");
int id = boost::lexical_cast<int>(node.getContent());
m_pSinogram = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
@@ -152,10 +167,16 @@ bool CCudaFilteredBackProjectionAlgorithm::initialize(const Config& _cfg)
m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
CC.markOptionParsed("GPUindex");
- // Pixel supersampling factor
- m_iPixelSuperSampling = (int)_cfg.self.getOptionNumerical("PixelSuperSampling", 1);
+ m_iPixelSuperSampling = 1;
+ if (pCudaProjector) {
+ // New interface
+ m_iPixelSuperSampling = pCudaProjector->getVoxelSuperSampling();
+ }
+ // Deprecated options
+ m_iPixelSuperSampling = (int)_cfg.self.getOptionNumerical("PixelSuperSampling", m_iPixelSuperSampling);
CC.markOptionParsed("PixelSuperSampling");
+
// Fan beam short scan mode
if (m_pSinogram && dynamic_cast<CFanFlatProjectionGeometry2D*>(m_pSinogram->getGeometry())) {
m_bShortScan = (int)_cfg.self.getOptionBool("ShortScan", false);
diff --git a/src/CudaForwardProjectionAlgorithm.cpp b/src/CudaForwardProjectionAlgorithm.cpp
index 0f97d59..b382f2e 100644
--- a/src/CudaForwardProjectionAlgorithm.cpp
+++ b/src/CudaForwardProjectionAlgorithm.cpp
@@ -71,9 +71,24 @@ bool CCudaForwardProjectionAlgorithm::initialize(const Config& _cfg)
{
ASTRA_ASSERT(_cfg.self);
ConfigStackCheck<CAlgorithm> CC("CudaForwardProjectionAlgorithm", this, _cfg);
+
+ // Projector
+ XMLNode node = _cfg.self.getSingleNode("ProjectorId");
+ CCudaProjector2D* pCudaProjector = 0;
+ if (node) {
+ int id = boost::lexical_cast<int>(node.getContent());
+ CProjector2D *projector = CProjector2DManager::getSingleton().get(id);
+ pCudaProjector = dynamic_cast<CCudaProjector2D*>(projector);
+ if (!pCudaProjector) {
+ ASTRA_WARN("non-CUDA Projector2D passed to FP_CUDA");
+ }
+ }
+ CC.markNodeParsed("ProjectorId");
+
+
// sinogram data
- XMLNode node = _cfg.self.getSingleNode("ProjectionDataId");
+ node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "FP_CUDA", "No ProjectionDataId tag specified.");
int id = boost::lexical_cast<int>(node.getContent());
m_pSinogram = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
@@ -94,21 +109,14 @@ bool CCudaForwardProjectionAlgorithm::initialize(const Config& _cfg)
CC.markOptionParsed("GPUIndex");
// Detector supersampling factor
- m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", 1);
- CC.markOptionParsed("DetectorSuperSampling");
-
-
- // This isn't used yet, but passing it is not something to warn about
- node = _cfg.self.getSingleNode("ProjectorId");
- if (node) {
- id = boost::lexical_cast<int>(node.getContent());
- CProjector2D *projector = CProjector2DManager::getSingleton().get(id);
- if (!dynamic_cast<CCudaProjector2D*>(projector)) {
- ASTRA_WARN("non-CUDA Projector2D passed to FP_CUDA");
- }
+ m_iDetectorSuperSampling = 1;
+ if (pCudaProjector) {
+ // New interface
+ m_iDetectorSuperSampling = pCudaProjector->getDetectorSuperSampling();
}
- CC.markNodeParsed("ProjectorId");
-
+ // Deprecated option
+ m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", m_iDetectorSuperSampling);
+ CC.markOptionParsed("DetectorSuperSampling");
// return success
diff --git a/src/CudaForwardProjectionAlgorithm3D.cpp b/src/CudaForwardProjectionAlgorithm3D.cpp
index e29b5a9..46dab12 100644
--- a/src/CudaForwardProjectionAlgorithm3D.cpp
+++ b/src/CudaForwardProjectionAlgorithm3D.cpp
@@ -97,18 +97,28 @@ bool CCudaForwardProjectionAlgorithm3D::initialize(const Config& _cfg)
// optional: projector
node = _cfg.self.getSingleNode("ProjectorId");
+ CCudaProjector3D* pCudaProjector = 0;
+ m_pProjector = 0;
if (node) {
id = boost::lexical_cast<int>(node.getContent());
m_pProjector = CProjector3DManager::getSingleton().get(id);
- } else {
- m_pProjector = 0; // TODO: or manually construct default projector?
+ pCudaProjector = dynamic_cast<CCudaProjector3D*>(CProjector3DManager::getSingleton().get(id));
+ m_pProjector = pCudaProjector;
+ if (!pCudaProjector) {
+ // TODO: Report
+ }
}
CC.markNodeParsed("ProjectorId");
// GPU number
m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
CC.markOptionParsed("GPUindex");
- m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", 1);
+
+
+ m_iDetectorSuperSampling = 1;
+ if (pCudaProjector)
+ m_iDetectorSuperSampling = pCudaProjector->getDetectorSuperSampling();
+ m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", m_iDetectorSuperSampling);
CC.markOptionParsed("DetectorSuperSampling");
// success
diff --git a/src/CudaProjector2D.cpp b/src/CudaProjector2D.cpp
index fa024c8..a26e32d 100644
--- a/src/CudaProjector2D.cpp
+++ b/src/CudaProjector2D.cpp
@@ -59,6 +59,8 @@ void CCudaProjector2D::_clear()
m_bIsInitialized = false;
m_projectionKernel = ker2d_default;
+ m_iVoxelSuperSampling = 1;
+ m_iDetectorSuperSampling = 1;
}
//----------------------------------------------------------------------------------------
@@ -117,6 +119,12 @@ bool CCudaProjector2D::initialize(const Config& _cfg)
}
CC.markNodeParsed("ProjectionKernel");
+ m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", 1);
+ CC.markOptionParsed("VoxelSuperSampling");
+
+ m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", 1);
+ CC.markOptionParsed("DetectorSuperSampling");
+
m_bIsInitialized = _check();
return m_bIsInitialized;
}
diff --git a/src/CudaProjector3D.cpp b/src/CudaProjector3D.cpp
index 41529a5..d2fd74c 100644
--- a/src/CudaProjector3D.cpp
+++ b/src/CudaProjector3D.cpp
@@ -62,6 +62,8 @@ void CCudaProjector3D::_clear()
m_bIsInitialized = false;
m_projectionKernel = ker3d_default;
+ m_iVoxelSuperSampling = 1;
+ m_iDetectorSuperSampling = 1;
}
//----------------------------------------------------------------------------------------
@@ -120,6 +122,12 @@ bool CCudaProjector3D::initialize(const Config& _cfg)
}
CC.markNodeParsed("ProjectionKernel");
+ m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", 1);
+ CC.markOptionParsed("VoxelSuperSampling");
+
+ m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", 1);
+ CC.markOptionParsed("DetectorSuperSampling");
+
m_bIsInitialized = _check();
return m_bIsInitialized;
}
diff --git a/src/CudaReconstructionAlgorithm2D.cpp b/src/CudaReconstructionAlgorithm2D.cpp
index db99d42..71b6637 100644
--- a/src/CudaReconstructionAlgorithm2D.cpp
+++ b/src/CudaReconstructionAlgorithm2D.cpp
@@ -95,8 +95,22 @@ bool CCudaReconstructionAlgorithm2D::initialize(const Config& _cfg)
clear();
}
+ // Projector
+ XMLNode node = _cfg.self.getSingleNode("ProjectorId");
+ CCudaProjector2D* pCudaProjector = 0;
+ if (node) {
+ int id = boost::lexical_cast<int>(node.getContent());
+ CProjector2D *projector = CProjector2DManager::getSingleton().get(id);
+ pCudaProjector = dynamic_cast<CCudaProjector2D*>(projector);
+ if (!pCudaProjector) {
+ ASTRA_WARN("non-CUDA Projector2D passed");
+ }
+ }
+ CC.markNodeParsed("ProjectorId");
+
+
// sinogram data
- XMLNode node = _cfg.self.getSingleNode("ProjectionDataId");
+ node = _cfg.self.getSingleNode("ProjectionDataId");
ASTRA_CONFIG_CHECK(node, "CudaSirt2", "No ProjectionDataId tag specified.");
int id = boost::lexical_cast<int>(node.getContent());
m_pSinogram = dynamic_cast<CFloat32ProjectionData2D*>(CData2DManager::getSingleton().get(id));
@@ -161,27 +175,21 @@ bool CCudaReconstructionAlgorithm2D::initialize(const Config& _cfg)
if (!_cfg.self.hasOption("GPUindex"))
CC.markOptionParsed("GPUIndex");
- // Detector supersampling factor
- m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", 1);
+ // Supersampling factors
+ m_iDetectorSuperSampling = 1;
+ m_iPixelSuperSampling = 1;
+ if (pCudaProjector) {
+ // New interface
+ m_iDetectorSuperSampling = pCudaProjector->getDetectorSuperSampling();
+ m_iPixelSuperSampling = pCudaProjector->getVoxelSuperSampling();
+ }
+ // Deprecated options
+ m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", m_iDetectorSuperSampling);
+ m_iPixelSuperSampling = (int)_cfg.self.getOptionNumerical("PixelSuperSampling", m_iPixelSuperSampling);
CC.markOptionParsed("DetectorSuperSampling");
-
- // Pixel supersampling factor
- m_iPixelSuperSampling = (int)_cfg.self.getOptionNumerical("PixelSuperSampling", 1);
CC.markOptionParsed("PixelSuperSampling");
- // This isn't used yet, but passing it is not something to warn about
- node = _cfg.self.getSingleNode("ProjectorId");
- if (node) {
- id = boost::lexical_cast<int>(node.getContent());
- CProjector2D *projector = CProjector2DManager::getSingleton().get(id);
- if (!dynamic_cast<CCudaProjector2D*>(projector)) {
- ASTRA_WARN("non-CUDA Projector2D passed");
- }
- }
- CC.markNodeParsed("ProjectorId");
-
-
return _check();
}
diff --git a/src/CudaSirtAlgorithm3D.cpp b/src/CudaSirtAlgorithm3D.cpp
index 5ad131b..abbb9fd 100644
--- a/src/CudaSirtAlgorithm3D.cpp
+++ b/src/CudaSirtAlgorithm3D.cpp
@@ -36,6 +36,7 @@ $Id$
#include "astra/ParallelProjectionGeometry3D.h"
#include "astra/ParallelVecProjectionGeometry3D.h"
#include "astra/ConeVecProjectionGeometry3D.h"
+#include "astra/CudaProjector3D.h"
#include "../cuda/3d/astra3d.h"
@@ -107,12 +108,28 @@ bool CCudaSirtAlgorithm3D::initialize(const Config& _cfg)
return false;
}
+ CCudaProjector3D* pCudaProjector = 0;
+ pCudaProjector = dynamic_cast<CCudaProjector3D*>(m_pProjector);
+ if (!pCudaProjector) {
+ // TODO: Report
+ }
+
m_iGPUIndex = (int)_cfg.self.getOptionNumerical("GPUindex", -1);
CC.markOptionParsed("GPUindex");
- m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", 1);
- CC.markOptionParsed("DetectorSuperSampling");
- m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", 1);
+
+
+ m_iVoxelSuperSampling = 1;
+ m_iDetectorSuperSampling = 1;
+ if (pCudaProjector) {
+ // New interface
+ m_iVoxelSuperSampling = pCudaProjector->getVoxelSuperSampling();
+ m_iDetectorSuperSampling = pCudaProjector->getDetectorSuperSampling();
+ }
+ // Deprecated options
+ m_iVoxelSuperSampling = (int)_cfg.self.getOptionNumerical("VoxelSuperSampling", m_iVoxelSuperSampling);
+ m_iDetectorSuperSampling = (int)_cfg.self.getOptionNumerical("DetectorSuperSampling", m_iDetectorSuperSampling);
CC.markOptionParsed("VoxelSuperSampling");
+ CC.markOptionParsed("DetectorSuperSampling");
m_pSirt = new AstraSIRT3d();
diff --git a/src/ReconstructionAlgorithm3D.cpp b/src/ReconstructionAlgorithm3D.cpp
index 86b8ab2..f975ace 100644
--- a/src/ReconstructionAlgorithm3D.cpp
+++ b/src/ReconstructionAlgorithm3D.cpp
@@ -106,14 +106,18 @@ bool CReconstructionAlgorithm3D::initialize(const Config& _cfg)
XMLNode node;
int id;
-#if 0
+
// projector
- node = _cfg.self->getSingleNode("ProjectorId");
- ASTRA_CONFIG_CHECK(node, "Reconstruction3D", "No ProjectorId tag specified.");
- id = boost::lexical_cast<int>(node->getContent());
- m_pProjector = CProjector3DManager::getSingleton().get(id);
- ASTRA_DELETE(node);
-#endif
+ node = _cfg.self.getSingleNode("ProjectorId");
+ m_pProjector = 0;
+ if (node) {
+ id = boost::lexical_cast<int>(node.getContent());
+ m_pProjector = CProjector3DManager::getSingleton().get(id);
+ if (!m_pProjector) {
+ // TODO: Report
+ }
+ }
+ CC.markNodeParsed("ProjectorId");
// sinogram data
node = _cfg.self.getSingleNode("ProjectionDataId");