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 itkFullToHalfHermitianImageFilter_h
19 #define itkFullToHalfHermitianImageFilter_h
20 
21 #include "itkImageToImageFilter.h"
22 #include "itkSimpleDataObjectDecorator.h"
23 
24 namespace itk
25 {
26 /** \class FullToHalfHermitianImageFilter
27  *
28  * \brief Reduces the size of a full complex image produced from a
29  * forward discrete Fourier transform of a real image to only the
30  * non-redundant half of the image.
31  *
32  * In particular, this filter reduces the size of the image in the
33  * first dimension to \f$\lfloor N/2 \rfloor + 1 \f$.
34  *
35  * \ingroup FourierTransform
36  *
37  * \sa HalfToFullHermitianImageFilter
38  * \sa ForwardFFTImageFilter
39  * \sa InverseFFTImageFilter
40  * \sa RealToHalfHermitianForwardFFTImageFilter
41  * \sa HalfHermitianToRealInverseFFTImageFilter
42  * \ingroup ITKFFT
43  */
44 template< typename TInputImage >
45 class ITK_TEMPLATE_EXPORT FullToHalfHermitianImageFilter :
46   public ImageToImageFilter< TInputImage, TInputImage >
47 {
48 public:
49   ITK_DISALLOW_COPY_AND_ASSIGN(FullToHalfHermitianImageFilter);
50 
51   /** Standard class type aliases. */
52   using InputImageType = TInputImage;
53   using InputImagePixelType = typename InputImageType::PixelType;
54   using InputImageIndexType = typename InputImageType::IndexType;
55   using InputImageIndexValueType = typename InputImageType::IndexValueType;
56   using InputImageSizeType = typename InputImageType::SizeType;
57   using InputImageSizeValueType = typename InputImageType::SizeValueType;
58   using InputImageRegionType = typename InputImageType::RegionType;
59   using OutputImageType = TInputImage;
60   using OutputImagePixelType = typename OutputImageType::PixelType;
61   using OutputImageIndexType = typename OutputImageType::IndexType;
62   using OutputImageIndexValueType = typename OutputImageType::IndexValueType;
63   using OutputImageSizeType = typename OutputImageType::SizeType;
64   using OutputImageSizeValueType = typename OutputImageType::SizeValueType;
65   using OutputImageRegionType = typename OutputImageType::RegionType;
66 
67   using Self = FullToHalfHermitianImageFilter;
68   using Superclass = ImageToImageFilter< TInputImage, TInputImage >;
69   using Pointer = SmartPointer< Self >;
70   using ConstPointer = SmartPointer< const Self >;
71 
72   /** Method for creation through the object factory. */
73   itkNewMacro(Self);
74 
75   /** Run-time type information (and related methods). */
76   itkTypeMacro(FullToHalfHermitianImageFilter,
77                ImageToImageFilter);
78 
79   /** Extract the dimensionality of the input and output images. */
80   static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
81 
82   /** Get whether the actual X dimension of the image is odd or not in the full
83    * representation */
84   itkGetDecoratedOutputMacro(ActualXDimensionIsOdd, bool);
85 
86 protected:
87   FullToHalfHermitianImageFilter();
88   ~FullToHalfHermitianImageFilter() override = default;
89 
90   void DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
91 
92 
93   /** The output is a different size from the input. */
94   void GenerateOutputInformation() override;
95 
96   /** This class requires the entire input. */
97   void GenerateInputRequestedRegion() override;
98 
99   itkSetDecoratedOutputMacro(ActualXDimensionIsOdd, bool);
100 };
101 } // end namespace itk
102 
103 #ifndef ITK_MANUAL_INSTANTIATION
104 #include "itkFullToHalfHermitianImageFilter.hxx"
105 #endif
106 
107 #endif // itkFullToHalfHermitianImageFilter_h
108