From d58f6b51493c7931cbc02feb3ffeb0eca6ea3a4e Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Thu, 5 Jul 2018 16:13:37 +0200 Subject: Refactor a few filter-related functions out of cuda code --- .../astra/CudaFilteredBackProjectionAlgorithm.h | 3 +- include/astra/Filters.h | 71 ++++++++++++++++++++++ include/astra/cuda/2d/astra.h | 1 - include/astra/cuda/2d/fbp.h | 2 +- include/astra/cuda/2d/fbp_filters.h | 61 ------------------- include/astra/cuda/2d/fft.h | 8 +-- 6 files changed, 77 insertions(+), 69 deletions(-) create mode 100644 include/astra/Filters.h delete mode 100644 include/astra/cuda/2d/fbp_filters.h (limited to 'include/astra') diff --git a/include/astra/CudaFilteredBackProjectionAlgorithm.h b/include/astra/CudaFilteredBackProjectionAlgorithm.h index 1280e9a..974914a 100644 --- a/include/astra/CudaFilteredBackProjectionAlgorithm.h +++ b/include/astra/CudaFilteredBackProjectionAlgorithm.h @@ -33,6 +33,7 @@ along with the ASTRA Toolbox. If not, see . #include "Float32ProjectionData2D.h" #include "Float32VolumeData2D.h" #include "CudaReconstructionAlgorithm2D.h" +#include "Filters.h" #include "cuda/2d/astra.h" @@ -52,8 +53,6 @@ private: float m_fFilterD; // frequency cut-off bool m_bShortScan; // short-scan mode for fan beam - static E_FBPFILTER _convertStringToFilter(const char * _filterType); - public: CCudaFilteredBackProjectionAlgorithm(); virtual ~CCudaFilteredBackProjectionAlgorithm(); diff --git a/include/astra/Filters.h b/include/astra/Filters.h new file mode 100644 index 0000000..ff3f5c8 --- /dev/null +++ b/include/astra/Filters.h @@ -0,0 +1,71 @@ +/* +----------------------------------------------------------------------- +Copyright: 2010-2018, imec Vision Lab, University of Antwerp + 2014-2018, CWI, Amsterdam + +Contact: astra@astra-toolbox.com +Website: http://www.astra-toolbox.com/ + +This file is part of the ASTRA Toolbox. + + +The ASTRA Toolbox is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +The ASTRA Toolbox is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with the ASTRA Toolbox. If not, see . + +----------------------------------------------------------------------- +*/ + +#ifndef _INC_ASTRA_FILTERS_H +#define _INC_ASTRA_FILTERS_H + +namespace astra { + +enum E_FBPFILTER +{ + FILTER_ERROR, //< not a valid filter + FILTER_NONE, //< no filter (regular BP) + FILTER_RAMLAK, //< default FBP filter + FILTER_SHEPPLOGAN, //< Shepp-Logan + FILTER_COSINE, //< Cosine + FILTER_HAMMING, //< Hamming filter + FILTER_HANN, //< Hann filter + FILTER_TUKEY, //< Tukey filter + FILTER_LANCZOS, //< Lanczos filter + FILTER_TRIANGULAR, //< Triangular filter + FILTER_GAUSSIAN, //< Gaussian filter + FILTER_BARTLETTHANN, //< Bartlett-Hann filter + FILTER_BLACKMAN, //< Blackman filter + FILTER_NUTTALL, //< Nuttall filter, continuous first derivative + FILTER_BLACKMANHARRIS, //< Blackman-Harris filter + FILTER_BLACKMANNUTTALL, //< Blackman-Nuttall filter + FILTER_FLATTOP, //< Flat top filter + FILTER_KAISER, //< Kaiser filter + FILTER_PARZEN, //< Parzen filter + FILTER_PROJECTION, //< all projection directions share one filter + FILTER_SINOGRAM, //< every projection direction has its own filter + FILTER_RPROJECTION, //< projection filter in real space (as opposed to fourier space) + FILTER_RSINOGRAM, //< sinogram filter in real space + +}; + +// Generate filter of given size and parameters. Returns newly allocated array. +float *genFilter(E_FBPFILTER _eFilter, float _fD, int _iProjectionCount, + int _iFFTRealDetectorCount, + int _iFFTFourierDetectorCount, float _fParameter = -1.0f); + +// Convert string to filter type. Returns FILTER_ERROR if unrecognized. +E_FBPFILTER convertStringToFilter(const char * _filterType); + +} + +#endif diff --git a/include/astra/cuda/2d/astra.h b/include/astra/cuda/2d/astra.h index 6f0e2f0..a2f2219 100644 --- a/include/astra/cuda/2d/astra.h +++ b/include/astra/cuda/2d/astra.h @@ -28,7 +28,6 @@ along with the ASTRA Toolbox. If not, see . #ifndef _CUDA_ASTRA_H #define _CUDA_ASTRA_H -#include "fbp_filters.h" #include "dims.h" #include "algo.h" diff --git a/include/astra/cuda/2d/fbp.h b/include/astra/cuda/2d/fbp.h index 8666646..7febe69 100644 --- a/include/astra/cuda/2d/fbp.h +++ b/include/astra/cuda/2d/fbp.h @@ -26,7 +26,7 @@ along with the ASTRA Toolbox. If not, see . */ #include "algo.h" -#include "fbp_filters.h" +#include "astra/Filters.h" namespace astraCUDA { diff --git a/include/astra/cuda/2d/fbp_filters.h b/include/astra/cuda/2d/fbp_filters.h deleted file mode 100644 index 7c1121a..0000000 --- a/include/astra/cuda/2d/fbp_filters.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ------------------------------------------------------------------------ -Copyright: 2010-2018, imec Vision Lab, University of Antwerp - 2014-2018, CWI, Amsterdam - -Contact: astra@astra-toolbox.com -Website: http://www.astra-toolbox.com/ - -This file is part of the ASTRA Toolbox. - - -The ASTRA Toolbox is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -The ASTRA Toolbox is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with the ASTRA Toolbox. If not, see . - ------------------------------------------------------------------------ -*/ - -#ifndef FBP_FILTERS_H -#define FBP_FILTERS_H - -namespace astra { - -enum E_FBPFILTER -{ - FILTER_NONE, //< no filter (regular BP) - FILTER_RAMLAK, //< default FBP filter - FILTER_SHEPPLOGAN, //< Shepp-Logan - FILTER_COSINE, //< Cosine - FILTER_HAMMING, //< Hamming filter - FILTER_HANN, //< Hann filter - FILTER_TUKEY, //< Tukey filter - FILTER_LANCZOS, //< Lanczos filter - FILTER_TRIANGULAR, //< Triangular filter - FILTER_GAUSSIAN, //< Gaussian filter - FILTER_BARTLETTHANN, //< Bartlett-Hann filter - FILTER_BLACKMAN, //< Blackman filter - FILTER_NUTTALL, //< Nuttall filter, continuous first derivative - FILTER_BLACKMANHARRIS, //< Blackman-Harris filter - FILTER_BLACKMANNUTTALL, //< Blackman-Nuttall filter - FILTER_FLATTOP, //< Flat top filter - FILTER_KAISER, //< Kaiser filter - FILTER_PARZEN, //< Parzen filter - FILTER_PROJECTION, //< all projection directions share one filter - FILTER_SINOGRAM, //< every projection direction has its own filter - FILTER_RPROJECTION, //< projection filter in real space (as opposed to fourier space) - FILTER_RSINOGRAM, //< sinogram filter in real space -}; - -} - -#endif /* FBP_FILTERS_H */ diff --git a/include/astra/cuda/2d/fft.h b/include/astra/cuda/2d/fft.h index d36cae2..f5f8477 100644 --- a/include/astra/cuda/2d/fft.h +++ b/include/astra/cuda/2d/fft.h @@ -31,7 +31,7 @@ along with the ASTRA Toolbox. If not, see . #include #include -#include "fbp_filters.h" +#include "astra/Filters.h" namespace astraCUDA { @@ -60,9 +60,9 @@ void applyFilter(int _iProjectionCount, int _iFreqBinCount, int calcFFTFourierSize(int _iFFTRealSize); -void genFilter(astra::E_FBPFILTER _eFilter, float _fD, int _iProjectionCount, - cufftComplex * _pFilter, int _iFFTRealDetectorCount, - int _iFFTFourierDetectorCount, float _fParameter = -1.0f); +void genCuFFTFilter(astra::E_FBPFILTER _eFilter, float _fD, int _iProjectionCount, + cufftComplex * _pFilter, int _iFFTRealDetectorCount, + int _iFFTFourierDetectorCount, float _fParameter = -1.0f); void genIdenFilter(int _iProjectionCount, cufftComplex * _pFilter, int _iFFTRealDetectorCount, int _iFFTFourierDetectorCount); -- cgit v1.2.3