summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cuda/2d/fbp.cu16
-rw-r--r--cuda/2d/fft.cu2
-rw-r--r--include/astra/Filters.h4
-rw-r--r--src/Filters.cpp6
4 files changed, 10 insertions, 18 deletions
diff --git a/cuda/2d/fbp.cu b/cuda/2d/fbp.cu
index e8a224e..a5b8a7a 100644
--- a/cuda/2d/fbp.cu
+++ b/cuda/2d/fbp.cu
@@ -42,20 +42,10 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
namespace astraCUDA {
-
-static int calcNextPowerOfTwo(int n)
-{
- int x = 1;
- while (x < n)
- x *= 2;
-
- return x;
-}
-
// static
int FBP::calcFourierFilterSize(int _iDetectorCount)
{
- int iFFTRealDetCount = calcNextPowerOfTwo(2 * _iDetectorCount);
+ int iFFTRealDetCount = astra::calcNextPowerOfTwo(2 * _iDetectorCount);
int iFreqBinCount = astra::calcFFTFourierSize(iFFTRealDetCount);
// CHECKME: Matlab makes this at least 64. Do we also need to?
@@ -101,7 +91,7 @@ bool FBP::setFilter(const astra::SFilterConfig &_cfg)
return true; // leave D_filter set to 0
- int iFFTRealDetCount = calcNextPowerOfTwo(2 * dims.iProjDets);
+ int iFFTRealDetCount = astra::calcNextPowerOfTwo(2 * dims.iProjDets);
int iFreqBinCount = astra::calcFFTFourierSize(iFFTRealDetCount);
cufftComplex * pHostFilter = new cufftComplex[dims.iProjAngles * iFreqBinCount];
@@ -311,7 +301,7 @@ bool FBP::iterate(unsigned int iterations)
if (D_filter) {
- int iFFTRealDetCount = calcNextPowerOfTwo(2 * dims.iProjDets);
+ int iFFTRealDetCount = astra::calcNextPowerOfTwo(2 * dims.iProjDets);
int iFFTFourDetCount = astra::calcFFTFourierSize(iFFTRealDetCount);
cufftComplex * pDevComplexSinogram = NULL;
diff --git a/cuda/2d/fft.cu b/cuda/2d/fft.cu
index dc0edc3..2e94b79 100644
--- a/cuda/2d/fft.cu
+++ b/cuda/2d/fft.cu
@@ -293,7 +293,7 @@ void genCuFFTFilter(const SFilterConfig &_cfg, int _iProjectionCount,
cufftComplex * _pFilter, int _iFFTRealDetectorCount,
int _iFFTFourierDetectorCount)
{
- float * pfFilt = astra::genFilter(_cfg, _iProjectionCount,
+ float * pfFilt = astra::genFilter(_cfg,
_iFFTRealDetectorCount,
_iFFTFourierDetectorCount);
diff --git a/include/astra/Filters.h b/include/astra/Filters.h
index bf0fb48..a1dec97 100644
--- a/include/astra/Filters.h
+++ b/include/astra/Filters.h
@@ -77,7 +77,7 @@ struct SFilterConfig {
};
// Generate filter of given size and parameters. Returns newly allocated array.
-float *genFilter(const SFilterConfig &_cfg, int _iProjectionCount,
+float *genFilter(const SFilterConfig &_cfg,
int _iFFTRealDetectorCount,
int _iFFTFourierDetectorCount);
@@ -88,6 +88,8 @@ SFilterConfig getFilterConfigForAlgorithm(const Config& _cfg, CAlgorithm *_alg);
bool checkCustomFilterSize(const SFilterConfig &_cfg, const CProjectionGeometry2D &_geom);
+
+int calcNextPowerOfTwo(int _iValue);
int calcFFTFourierSize(int _iFFTRealSize);
diff --git a/src/Filters.cpp b/src/Filters.cpp
index 3ee3749..c13aa6b 100644
--- a/src/Filters.cpp
+++ b/src/Filters.cpp
@@ -38,7 +38,7 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
namespace astra {
-float *genFilter(const SFilterConfig &_cfg, int _iProjectionCount,
+float *genFilter(const SFilterConfig &_cfg,
int _iFFTRealDetectorCount,
int _iFFTFourierDetectorCount)
{
@@ -546,10 +546,10 @@ SFilterConfig getFilterConfigForAlgorithm(const Config& _cfg, CAlgorithm *_alg)
return c;
}
-static int calcNextPowerOfTwo(int n)
+int calcNextPowerOfTwo(int n)
{
int x = 1;
- while (x < n)
+ while (x < n && x > 0)
x *= 2;
return x;