From d32df3bcd1910f56195e828a0f7fba8fc04b90ab Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Thu, 12 Jul 2018 12:11:52 +0200 Subject: Refactor filter config --- include/astra/CudaFilteredBackProjectionAlgorithm.h | 6 +----- include/astra/Filters.h | 21 +++++++++++++++++++-- include/astra/cuda/2d/fbp.h | 4 +--- include/astra/cuda/2d/fft.h | 4 ++-- 4 files changed, 23 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/astra/CudaFilteredBackProjectionAlgorithm.h b/include/astra/CudaFilteredBackProjectionAlgorithm.h index 974914a..8ef5a57 100644 --- a/include/astra/CudaFilteredBackProjectionAlgorithm.h +++ b/include/astra/CudaFilteredBackProjectionAlgorithm.h @@ -46,11 +46,7 @@ public: static std::string type; private: - E_FBPFILTER m_eFilter; - float * m_pfFilter; - int m_iFilterWidth; // number of elements per projection direction in filter - float m_fFilterParameter; // some filters allow for parameterization (value < 0.0f -> no parameter) - float m_fFilterD; // frequency cut-off + SFilterConfig m_filterConfig; bool m_bShortScan; // short-scan mode for fan beam public: diff --git a/include/astra/Filters.h b/include/astra/Filters.h index ff3f5c8..eec2ba2 100644 --- a/include/astra/Filters.h +++ b/include/astra/Filters.h @@ -30,6 +30,9 @@ along with the ASTRA Toolbox. If not, see . namespace astra { +struct Config; +class CAlgorithm; + enum E_FBPFILTER { FILTER_ERROR, //< not a valid filter @@ -58,14 +61,28 @@ enum E_FBPFILTER }; +struct SFilterConfig { + E_FBPFILTER m_eType; + float m_fD; + float m_fParameter; + + float *m_pfCustomFilter; + int m_iCustomFilterWidth; + + SFilterConfig() : m_eType(FILTER_ERROR), m_fD(1.0f), m_fParameter(-1.0f), + m_pfCustomFilter(0), m_iCustomFilterWidth(0) { }; +}; + // Generate filter of given size and parameters. Returns newly allocated array. -float *genFilter(E_FBPFILTER _eFilter, float _fD, int _iProjectionCount, +float *genFilter(const SFilterConfig &_cfg, int _iProjectionCount, int _iFFTRealDetectorCount, - int _iFFTFourierDetectorCount, float _fParameter = -1.0f); + int _iFFTFourierDetectorCount); // Convert string to filter type. Returns FILTER_ERROR if unrecognized. E_FBPFILTER convertStringToFilter(const char * _filterType); +SFilterConfig getFilterConfigForAlgorithm(const Config& _cfg, CAlgorithm *_alg); + } #endif diff --git a/include/astra/cuda/2d/fbp.h b/include/astra/cuda/2d/fbp.h index 7febe69..1adf3b1 100644 --- a/include/astra/cuda/2d/fbp.h +++ b/include/astra/cuda/2d/fbp.h @@ -75,9 +75,7 @@ public: // FILTER_COSINE, FILTER_HAMMING, and FILTER_HANN) // have a D variable, which gives the cutoff point in the frequency domain. // Setting this value to 1.0 will include the whole filter - bool setFilter(astra::E_FBPFILTER _eFilter, - const float * _pfHostFilter = NULL, - int _iFilterWidth = 0, float _fD = 1.0f, float _fFilterParameter = -1.0f); + bool setFilter(const astra::SFilterConfig &_cfg); bool setShortScan(bool ss) { m_bShortScan = ss; return true; } diff --git a/include/astra/cuda/2d/fft.h b/include/astra/cuda/2d/fft.h index f5f8477..33612a0 100644 --- a/include/astra/cuda/2d/fft.h +++ b/include/astra/cuda/2d/fft.h @@ -60,9 +60,9 @@ void applyFilter(int _iProjectionCount, int _iFreqBinCount, int calcFFTFourierSize(int _iFFTRealSize); -void genCuFFTFilter(astra::E_FBPFILTER _eFilter, float _fD, int _iProjectionCount, +void genCuFFTFilter(const astra::SFilterConfig &_cfg, int _iProjectionCount, cufftComplex * _pFilter, int _iFFTRealDetectorCount, - int _iFFTFourierDetectorCount, float _fParameter = -1.0f); + int _iFFTFourierDetectorCount); void genIdenFilter(int _iProjectionCount, cufftComplex * _pFilter, int _iFFTRealDetectorCount, int _iFFTFourierDetectorCount); -- cgit v1.2.3