ITK  5.4.0
Insight Toolkit
itkFFTConvolutionImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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 itkFFTConvolutionImageFilter_h
19 #define itkFFTConvolutionImageFilter_h
20 
22 
23 #include "itkProgressAccumulator.h"
27 
28 namespace itk
29 {
56 template <typename TInputImage,
57  typename TKernelImage = TInputImage,
58  typename TOutputImage = TInputImage,
59  typename TInternalPrecision = double>
60 class ITK_TEMPLATE_EXPORT FFTConvolutionImageFilter
61  : public ConvolutionImageFilterBase<TInputImage, TKernelImage, TOutputImage>
62 
63 {
64 public:
65  ITK_DISALLOW_COPY_AND_MOVE(FFTConvolutionImageFilter);
66 
71 
73  itkNewMacro(Self);
74 
76  itkOverrideGetNameOfClassMacro(FFTConvolutionImageFilter);
77 
79  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
80 
81  using InputImageType = TInputImage;
82  using OutputImageType = TOutputImage;
83  using KernelImageType = TKernelImage;
84  using InputPixelType = typename InputImageType::PixelType;
85  using OutputPixelType = typename OutputImageType::PixelType;
86  using KernelPixelType = typename KernelImageType::PixelType;
97 
104  using InternalComplexType = std::complex<TInternalPrecision>;
107 
109  using typename Superclass::BoundaryConditionType;
110  using typename Superclass::BoundaryConditionPointerType;
111 
112  itkSetMacro(SizeGreatestPrimeFactor, SizeValueType);
113  itkGetMacro(SizeGreatestPrimeFactor, SizeValueType);
114 
115 protected:
117  ~FFTConvolutionImageFilter() override = default;
118 
123 
130  void
131  GenerateInputRequestedRegion() override;
132 
134  void
135  GenerateData() override;
136 
141  void
142  PrepareInputs(const InputImageType * input,
143  const KernelImageType * kernel,
144  InternalComplexImagePointerType & preparedInput,
145  InternalComplexImagePointerType & preparedKernel,
146  ProgressAccumulator * progress,
147  float progressWeight);
148 
151  void
152  PrepareInput(const InputImageType * input,
153  InternalComplexImagePointerType & preparedInput,
154  ProgressAccumulator * progress,
155  float progressWeight);
156 
158  void
159  PadInput(const InputImageType * input,
160  InternalImagePointerType & paddedInput,
161  ProgressAccumulator * progress,
162  float progressWeight);
163 
165  void
166  TransformPaddedInput(const InternalImageType * paddedInput,
167  InternalComplexImagePointerType & transformedInput,
168  ProgressAccumulator * progress,
169  float progressWeight);
170 
174  void
175  PrepareKernel(const KernelImageType * kernel,
176  InternalComplexImagePointerType & preparedKernel,
177  ProgressAccumulator * progress,
178  float progressWeight);
179 
181  void
182  ProduceOutput(InternalComplexImageType * paddedOutput, ProgressAccumulator * progress, float progressWeight);
183 
185  void
186  CropOutput(InternalImageType * paddedOutput, ProgressAccumulator * progress, float progressWeight);
187 
191  GetKernelRadius() const;
192 
200  GetFFTPadSize() const;
201 
203  bool
204  GetXDimensionIsOdd() const;
205 
206  void
207  PrintSelf(std::ostream & os, Indent indent) const override;
208 
209 private:
210  SizeValueType m_SizeGreatestPrimeFactor{};
211  InternalSizeType m_FFTPadSize{ { 0 } };
212  InternalRegionType m_PaddedInputRegion{};
213 };
214 } // namespace itk
215 
216 #ifndef ITK_MANUAL_INSTANTIATION
217 # include "itkFFTConvolutionImageFilter.hxx"
218 #endif
219 
220 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::FFTConvolutionImageFilter
Convolve a given image with an arbitrary image kernel using multiplication in the Fourier domain.
Definition: itkFFTConvolutionImageFilter.h:60
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::OutputRegionType
typename OutputImageType::RegionType OutputRegionType
Definition: itkConvolutionImageFilterBase.h:88
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::KernelImageType
TKernelSource::OutputImageType KernelImageType
Definition: itkConvolutionImageFilterBase.h:76
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::SizeValueType
typename InputSizeType::SizeValueType SizeValueType
Definition: itkConvolutionImageFilterBase.h:86
itkConvolutionImageFilterBase.h
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::OutputIndexType
typename OutputImageType::IndexType OutputIndexType
Definition: itkConvolutionImageFilterBase.h:81
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::InputIndexType
typename InputImageType::IndexType InputIndexType
Definition: itkConvolutionImageFilterBase.h:80
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::KernelPixelType
typename KernelImageType::PixelType KernelPixelType
Definition: itkConvolutionImageFilterBase.h:79
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itkRealToHalfHermitianForwardFFTImageFilter.h
itk::RealToHalfHermitianForwardFFTImageFilter
Base class for specialized real-to-complex forward Fast Fourier Transform.
Definition: itkRealToHalfHermitianForwardFFTImageFilter.h:57
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::OutputSizeType
typename OutputImageType::SizeType OutputSizeType
Definition: itkConvolutionImageFilterBase.h:84
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::InputPixelType
typename InputImageType::PixelType InputPixelType
Definition: itkConvolutionImageFilterBase.h:77
itk::FFTConvolutionImageFilter< TInputImage, TKernelSource::OutputImageType, TOutputImage, double >::InternalComplexImagePointerType
typename InternalComplexImageType::Pointer InternalComplexImagePointerType
Definition: itkFFTConvolutionImageFilter.h:106
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::FFTConvolutionImageFilter< TInputImage, TKernelSource::OutputImageType, TOutputImage, double >::InternalComplexType
std::complex< double > InternalComplexType
Definition: itkFFTConvolutionImageFilter.h:104
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::KernelIndexType
typename KernelImageType::IndexType KernelIndexType
Definition: itkConvolutionImageFilterBase.h:82
itk::ImageToImageFilter::InputImageType
TInputImage InputImageType
Definition: itkImageToImageFilter.h:129
itk::FFTConvolutionImageFilter< TInputImage, TKernelSource::OutputImageType, TOutputImage, double >::InternalRegionType
typename InternalImageType::RegionType InternalRegionType
Definition: itkFFTConvolutionImageFilter.h:100
itkHalfHermitianToRealInverseFFTImageFilter.h
itk::ProgressAccumulator
Facilitates progress reporting for filters that wrap around multiple other filters.
Definition: itkProgressAccumulator.h:40
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::OutputPixelType
typename OutputImageType::PixelType OutputPixelType
Definition: itkConvolutionImageFilterBase.h:78
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itkProgressAccumulator.h
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::InputRegionType
typename InputImageType::RegionType InputRegionType
Definition: itkConvolutionImageFilterBase.h:87
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::InputSizeType
typename InputImageType::SizeType InputSizeType
Definition: itkConvolutionImageFilterBase.h:83
itk::FFTConvolutionImageFilter< TInputImage, TKernelSource::OutputImageType, TOutputImage, double >::InternalSizeType
typename InternalImageType::SizeType InternalSizeType
Definition: itkFFTConvolutionImageFilter.h:101
itk::FFTConvolutionImageFilter< TInputImage, TKernelSource::OutputImageType, TOutputImage, double >::InternalIndexType
typename InternalImageType::IndexType InternalIndexType
Definition: itkFFTConvolutionImageFilter.h:102
itk::HalfHermitianToRealInverseFFTImageFilter
Base class for specialized complex-to-real inverse Fast Fourier Transform.
Definition: itkHalfHermitianToRealInverseFFTImageFilter.h:57
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::KernelRegionType
typename KernelImageType::RegionType KernelRegionType
Definition: itkConvolutionImageFilterBase.h:89
itkZeroFluxNeumannBoundaryCondition.h
itk::ConvolutionImageFilterBase
Abstract base class for the convolution image filters.
Definition: itkConvolutionImageFilterBase.h:58
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::FFTConvolutionImageFilter< TInputImage, TKernelSource::OutputImageType, TOutputImage, double >::InternalImagePointerType
typename InternalImageType::Pointer InternalImagePointerType
Definition: itkFFTConvolutionImageFilter.h:103
itk::ImageSource::OutputImageType
TOutputImage OutputImageType
Definition: itkImageSource.h:90
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::KernelSizeType
typename KernelImageType::SizeType KernelSizeType
Definition: itkConvolutionImageFilterBase.h:85