summaryrefslogtreecommitdiffstats
path: root/src
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 /src
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
Diffstat (limited to 'src')
-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
11 files changed, 177 insertions, 54 deletions
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");