1 /*=========================================================================
2  *
3  *  Copyright Insight Software Consortium
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at
8  *
9  *         http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkComplexToComplexFFTImageFilter_h
19 #define itkComplexToComplexFFTImageFilter_h
20 
21 #include "itkImageToImageFilter.h"
22 #include <complex>
23 
24 namespace itk
25 {
26 
27 /** \class ComplexToComplexFFTImageFilter
28  *
29  * \brief Implements an API to enable the Fourier transform or the inverse
30  * Fourier transform of images with complex valued voxels to be computed.
31  *
32  * \ingroup FourierTransform
33  *
34  * \author Simon K. Warfield simon.warfield\@childrens.harvard.edu
35  *
36  * \note Attribution Notice. This research work was made possible by
37  * Grant Number R01 RR021885 (PI Simon K. Warfield, Ph.D.) from
38  * the National Center for Research Resources (NCRR), a component of the
39  * National Institutes of Health (NIH).  Its contents are solely the
40  * responsibility of the authors and do not necessarily represent the
41  * official view of NCRR or NIH.
42  *
43  * This class was taken from the Insight Journal paper:
44  * https://hdl.handle.net/1926/326
45  *
46  * \ingroup FourierTransform
47  *
48  * \sa ForwardFFTImageFilter
49  * \ingroup ITKFFT
50  */
51 template< typename TImage >
52 class ITK_TEMPLATE_EXPORT ComplexToComplexFFTImageFilter:
53   public ImageToImageFilter< TImage, TImage >
54 {
55 public:
56   ITK_DISALLOW_COPY_AND_ASSIGN(ComplexToComplexFFTImageFilter);
57 
58   /** Input and output image types. */
59   using ImageType = TImage;
60   using InputImageType = TImage;
61   using OutputImageType = TImage;
62 
63   /** Standard class type aliases. */
64   using Self = ComplexToComplexFFTImageFilter;
65   using Superclass = ImageToImageFilter< InputImageType, OutputImageType >;
66   using Pointer = SmartPointer< Self >;
67   using ConstPointer = SmartPointer< const Self >;
68 
69   static constexpr unsigned int ImageDimension = InputImageType::ImageDimension;
70 
71   /** Run-time type information (and related methods). */
72   itkTypeMacro(ComplexToComplexFFTImageFilter, ImageToImageFilter);
73 
74   /** Customized object creation methods that support configuration-based
75     * selection of FFT implementation.
76     *
77     * Default implementation is FFTW.
78     */
79   static Pointer New();
80 
81   /** Transform Direction */
82   enum TransformDirectionType {
83     FORWARD = 1,
84     INVERSE = 2
85     };
86 
87   /** Image type type alias support */
88   using ImageSizeType = typename ImageType::SizeType;
89 
90   /** Set/Get the direction in which the transform will be applied.
91    * By selecting FORWARD, this filter will perform a direct, i.e. forward, Fourier Transform,
92    * By selecting INVERSE, this filter will perform an inverse, i.e. backward, Fourier Transform,
93    */
94   itkSetMacro(TransformDirection, TransformDirectionType);
95   itkGetConstMacro(TransformDirection, TransformDirectionType);
96 
97 protected:
ComplexToComplexFFTImageFilter()98   ComplexToComplexFFTImageFilter():
99     m_TransformDirection( FORWARD ) {}
100 
101   void GenerateInputRequestedRegion() override;
102 
103 private:
104   TransformDirectionType m_TransformDirection;
105 };
106 
107 } // end namespace itk
108 
109 #ifndef ITK_MANUAL_INSTANTIATION
110 #include "itkComplexToComplexFFTImageFilter.hxx"
111 #endif
112 
113 #endif
114