summaryrefslogtreecommitdiffstats
path: root/src/SartAlgorithm.cpp
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <wjp@usecode.org>2016-04-14 13:12:32 +0200
committerWillem Jan Palenstijn <wjp@usecode.org>2016-04-14 13:12:32 +0200
commita7c4275ee8cd90b4ecf7fbca5d9571aae62a2931 (patch)
tree57ac0ca54d4742eef7ae2cdd408fd226b79e47b2 /src/SartAlgorithm.cpp
parent37951c09410545f3795887052681ee668368c8d0 (diff)
parentf9cc36d3507f7cde4d20165836d65a584ced720f (diff)
downloadastra-a7c4275ee8cd90b4ecf7fbca5d9571aae62a2931.tar.gz
astra-a7c4275ee8cd90b4ecf7fbca5d9571aae62a2931.tar.bz2
astra-a7c4275ee8cd90b4ecf7fbca5d9571aae62a2931.tar.xz
astra-a7c4275ee8cd90b4ecf7fbca5d9571aae62a2931.zip
Merge pull request #36 from wjp/sart_raylength
Fix accumulating multiple raylengths in SART
Diffstat (limited to 'src/SartAlgorithm.cpp')
-rw-r--r--src/SartAlgorithm.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/SartAlgorithm.cpp b/src/SartAlgorithm.cpp
index 9346160..f80df61 100644
--- a/src/SartAlgorithm.cpp
+++ b/src/SartAlgorithm.cpp
@@ -272,9 +272,8 @@ void CSartAlgorithm::run(int _iNrIterations)
m_bShouldAbort = false;
- int iIteration = 0;
-
// data projectors
+ CDataProjectorInterface* pFirstForwardProjector;
CDataProjectorInterface* pForwardProjector;
CDataProjectorInterface* pBackProjector;
@@ -292,7 +291,7 @@ void CSartAlgorithm::run(int _iNrIterations)
// first time forward projection data projector,
// also computes total pixel weight and total ray length
- pForwardProjector = dispatchDataProjector(
+ pFirstForwardProjector = dispatchDataProjector(
m_pProjector,
SinogramMaskPolicy(m_pSinogramMask), // sinogram mask
ReconstructionMaskPolicy(m_pReconstructionMask), // reconstruction mask
@@ -303,16 +302,30 @@ void CSartAlgorithm::run(int _iNrIterations)
m_bUseSinogramMask, m_bUseReconstructionMask, true // options on/off
);
+ // forward projection data projector
+ pForwardProjector = dispatchDataProjector(
+ m_pProjector,
+ SinogramMaskPolicy(m_pSinogramMask), // sinogram mask
+ ReconstructionMaskPolicy(m_pReconstructionMask), // reconstruction mask
+ CombinePolicy<DiffFPPolicy, TotalPixelWeightPolicy>( // 2 basic operations
+ DiffFPPolicy(m_pReconstruction, m_pDiffSinogram, m_pSinogram), // forward projection with difference calculation
+ TotalPixelWeightPolicy(m_pTotalPixelWeight)), // calculate the total pixel weights
+ m_bUseSinogramMask, m_bUseReconstructionMask, true // options on/off
+ );
+
// iteration loop
- for (; iIteration < _iNrIterations && !m_bShouldAbort; ++iIteration) {
+ for (int iIteration = 0; iIteration < _iNrIterations && !m_bShouldAbort; ++iIteration) {
int iProjection = m_piProjectionOrder[m_iIterationCount % m_iProjectionCount];
// forward projection and difference calculation
m_pTotalPixelWeight->setData(0.0f);
- pForwardProjector->projectSingleProjection(iProjection);
+ if (iIteration < m_iProjectionCount)
+ pFirstForwardProjector->projectSingleProjection(iProjection);
+ else
+ pForwardProjector->projectSingleProjection(iProjection);
// backprojection
pBackProjector->projectSingleProjection(iProjection);
// update iteration count
@@ -325,6 +338,7 @@ void CSartAlgorithm::run(int _iNrIterations)
}
+ ASTRA_DELETE(pFirstForwardProjector);
ASTRA_DELETE(pForwardProjector);
ASTRA_DELETE(pBackProjector);