Line data Source code
1 : #pragma once 2 : 3 : #include <complex> 4 : #include "LinearOperator.h" 5 : 6 : namespace elsa 7 : { 8 : /** 9 : * @brief Operator for applying multi-dimensional fourier transforms. 10 : * 11 : * @author Jonas Jelten - initial code 12 : * 13 : * @tparam data_t data type for the domain and range of the transformation, 14 : * defaulting to complex<real_t> 15 : * 16 : * Implements the n-dimensional signal fourier transformation. 17 : * Can support multiple backends, by default uses Eigen::FFT with FFTW. 18 : */ 19 : template <typename data_t = complex<real_t>> 20 : class FourierTransform : public LinearOperator<data_t> 21 : { 22 : private: 23 : using B = LinearOperator<data_t>; 24 : 25 : /** working data container for the fft. 26 : like in datacontainer, we operate on the vector in n dimensions. */ 27 : using fftvector_t = Eigen::Matrix<data_t, Eigen::Dynamic, 1>; 28 : 29 : public: 30 : /** 31 : * @brief create a fourier transform operator 32 : * 33 : * @param[in] domainDescriptor metadata defining the domain and range of the transformation 34 : * @param[in] norm metadata indicating which forward/inverse transform is scaled and 35 : * on which of the predefined normalization factors 36 : */ 37 : explicit FourierTransform(const DataDescriptor& domainDescriptor, 38 : FFTNorm norm = FFTNorm::BACKWARD); 39 : 40 27 : ~FourierTransform() override = default; 41 : 42 : protected: 43 : /** 44 : * @brief perform the fourier transformation 45 : * @param x inputData (image matrix) 46 : * @param Ax outputData (fourier transformed image matrix) 47 : */ 48 : void applyImpl(const DataContainer<data_t>& x, DataContainer<data_t>& Ax) const override; 49 : 50 : /** 51 : * @brief perform the inverse fourier transformation 52 : * @param y inputData (image matrix in frequency domain) 53 : * @param Aty outputData (inversely fourier transformed image matrix) 54 : */ 55 : void applyAdjointImpl(const DataContainer<data_t>& y, 56 : DataContainer<data_t>& Aty) const override; 57 : 58 : /// implement the polymorphic clone operation 59 : FourierTransform* cloneImpl() const override; 60 : 61 : /// implement the polymorphic comparison operation 62 : bool isEqual(const B& other) const override; 63 : 64 : private: 65 : FFTNorm norm; 66 : }; 67 : 68 : } // namespace elsa