ITK  6.0.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 
111  itkSetMacro(SizeGreatestPrimeFactor, SizeValueType);
112  itkGetMacro(SizeGreatestPrimeFactor, SizeValueType);
113 
114 protected:
116  ~FFTConvolutionImageFilter() override = default;
117 
122 
129  void
130  GenerateInputRequestedRegion() override;
131 
133  void
134  GenerateData() override;
135 
140  void
141  PrepareInputs(const InputImageType * input,
142  const KernelImageType * kernel,
143  InternalComplexImagePointerType & preparedInput,
144  InternalComplexImagePointerType & preparedKernel,
145  ProgressAccumulator * progress,
146  float progressWeight);
147 
150  void
151  PrepareInput(const InputImageType * input,
152  InternalComplexImagePointerType & preparedInput,
153  ProgressAccumulator * progress,
154  float progressWeight);
155 
157  void
158  PadInput(const InputImageType * input,
159  InternalImagePointerType & paddedInput,
160  ProgressAccumulator * progress,
161  float progressWeight);
162 
164  void
165  TransformPaddedInput(const InternalImageType * paddedInput,
166  InternalComplexImagePointerType & transformedInput,
167  ProgressAccumulator * progress,
168  float progressWeight);
169 
173  void
174  PrepareKernel(const KernelImageType * kernel,
175  InternalComplexImagePointerType & preparedKernel,
176  ProgressAccumulator * progress,
177  float progressWeight);
178 
180  void
181  ProduceOutput(InternalComplexImageType * paddedOutput, ProgressAccumulator * progress, float progressWeight);
182 
184  void
185  CropOutput(InternalImageType * paddedOutput, ProgressAccumulator * progress, float progressWeight);
186 
190  GetKernelRadius() const;
191 
199  GetFFTPadSize() const;
200 
202  bool
203  GetXDimensionIsOdd() const;
204 
205  void
206  PrintSelf(std::ostream & os, Indent indent) const override;
207 
208 private:
209  SizeValueType m_SizeGreatestPrimeFactor{};
210  InternalSizeType m_FFTPadSize{ { 0 } };
211  InternalRegionType m_PaddedInputRegion{};
212 };
213 } // namespace itk
214 
215 #ifndef ITK_MANUAL_INSTANTIATION
216 # include "itkFFTConvolutionImageFilter.hxx"
217 #endif
218 
219 #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:87
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::KernelImageType
TKernelSource::OutputImageType KernelImageType
Definition: itkConvolutionImageFilterBase.h:75
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::SizeValueType
typename InputSizeType::SizeValueType SizeValueType
Definition: itkConvolutionImageFilterBase.h:85
itkConvolutionImageFilterBase.h
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::OutputIndexType
typename OutputImageType::IndexType OutputIndexType
Definition: itkConvolutionImageFilterBase.h:80
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::InputIndexType
typename InputImageType::IndexType InputIndexType
Definition: itkConvolutionImageFilterBase.h:79
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::KernelPixelType
typename KernelImageType::PixelType KernelPixelType
Definition: itkConvolutionImageFilterBase.h:78
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:83
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::InputPixelType
typename InputImageType::PixelType InputPixelType
Definition: itkConvolutionImageFilterBase.h:76
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:81
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:77
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itkProgressAccumulator.h
itk::ConvolutionImageFilterBase< TInputImage, TKernelSource::OutputImageType, TOutputImage >::InputRegionType
typename InputImageType::RegionType InputRegionType
Definition: itkConvolutionImageFilterBase.h:86
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:82
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:88
itkZeroFluxNeumannBoundaryCondition.h
itk::ConvolutionImageFilterBase
Abstract base class for the convolution image filters.
Definition: itkConvolutionImageFilterBase.h:57
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86
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:84