RTK  2.6.0
Reconstruction Toolkit
rtkFFTProjectionsConvolutionImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright RTK 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  * 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 
19 #ifndef rtkFFTProjectionsConvolutionImageFilter_h
20 #define rtkFFTProjectionsConvolutionImageFilter_h
21 
22 #include <itkImageToImageFilter.h>
23 #include <itkConceptChecking.h>
24 
25 #include "rtkConfiguration.h"
26 #include "rtkMacro.h"
27 
28 namespace rtk
29 {
30 
44 template <class TInputImage, class TOutputImage, class TFFTPrecision>
45 class ITK_TEMPLATE_EXPORT FFTProjectionsConvolutionImageFilter
46  : public itk::ImageToImageFilter<TInputImage, TOutputImage>
47 {
48 public:
49  ITK_DISALLOW_COPY_AND_MOVE(FFTProjectionsConvolutionImageFilter);
50 
56 
58  using InputImageType = TInputImage;
59  using OutputImageType = TOutputImage;
60  using RegionType = typename InputImageType::RegionType;
61  using IndexType = typename InputImageType::IndexType;
62  using SizeType = typename InputImageType::SizeType;
63 
65  using FFTInputImagePointer = typename FFTInputImageType::Pointer;
66  using FFTOutputImageType = typename itk::Image<std::complex<TFFTPrecision>, TInputImage::ImageDimension>;
67  using FFTOutputImagePointer = typename FFTOutputImageType::Pointer;
69 
71  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
72 
74  itkOverrideGetNameOfClassMacro(FFTProjectionsConvolutionImageFilter);
75 
89  itkGetConstMacro(GreatestPrimeFactor, int);
90  itkSetMacro(GreatestPrimeFactor, int);
92 
96  itkGetConstMacro(TruncationCorrection, double);
97  itkSetMacro(TruncationCorrection, double);
99 
103  itkGetConstMacro(ZeroPadFactors, ZeroPadFactorsType);
104  virtual void
106  {
107  if (m_ZeroPadFactors != _arg)
108  {
109  m_ZeroPadFactors = _arg;
110  m_ZeroPadFactors[0] = std::max(m_ZeroPadFactors[0], 1);
111  m_ZeroPadFactors[1] = std::max(m_ZeroPadFactors[1], 1);
112  m_ZeroPadFactors[0] = std::min(m_ZeroPadFactors[0], 2);
113  m_ZeroPadFactors[1] = std::min(m_ZeroPadFactors[1], 2);
114  this->Modified();
115  }
116  }
118 
120 
121 protected:
123  ~FFTProjectionsConvolutionImageFilter() override = default;
124 
125  void
126  GenerateInputRequestedRegion() override;
127 
128  void
129  BeforeThreadedGenerateData() override;
130 
131  void
132  AfterThreadedGenerateData() override;
133 
134  void
135  ThreadedGenerateData(const RegionType & outputRegionForThread, ThreadIdType threadId) override;
136 
141  virtual FFTInputImagePointer
142  PadInputImageRegion(const RegionType & inputRegion);
143  RegionType
144  GetPaddedImageRegion(const RegionType & inputRegion);
146 
147  void
148  PrintSelf(std::ostream & os, itk::Indent indent) const override;
149 
150  bool
151  IsPrime(int n) const;
152 
153  int
154  GreatestPrimeFactor(int n) const;
155 
158  virtual void
159  UpdateFFTProjectionsConvolutionKernel(const SizeType size) = 0;
160 
166  virtual void
167  UpdateTruncationMirrorWeights();
168  typename std::vector<TFFTPrecision> m_TruncationMirrorWeights;
169 
172  int m_KernelDimension{ 1 };
173 
178 
179 private:
183  double m_TruncationCorrection{ 0. };
184  int
185  GetTruncationCorrectionExtent();
187 
192 
196  int m_GreatestPrimeFactor{ 2 };
197  int m_BackupNumberOfThreads{ 1 };
198 }; // end of class
199 
200 } // end namespace rtk
201 
202 #ifndef ITK_MANUAL_INSTANTIATION
203 # include "rtkFFTProjectionsConvolutionImageFilter.hxx"
204 #endif
205 
206 #endif
Base class for 1D or 2D FFT based convolution of projections.
ITKCommon_EXPORT bool IsPrime(unsigned int n)
#define itkSetMacro(name, type)
TOutputImage OutputImageType
typename itk::Image< TFFTPrecision, TInputImage::ImageDimension > FFTInputImageType
ITKCommon_EXPORT unsigned int GreatestPrimeFactor(unsigned int n)
unsigned int ThreadIdType
#define itkConceptMacro(name, concept)
typename itk::Image< std::complex< TFFTPrecision >, TInputImage::ImageDimension > FFTOutputImageType