RTK  2.4.1
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 
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 
119 #ifdef ITK_USE_CONCEPT_CHECKING
121 #endif
122 
123 protected:
125  ~FFTProjectionsConvolutionImageFilter() override = default;
126 
127  void
128  GenerateInputRequestedRegion() override;
129 
130  void
131  BeforeThreadedGenerateData() override;
132 
133  void
134  AfterThreadedGenerateData() override;
135 
136  void
137  ThreadedGenerateData(const RegionType & outputRegionForThread, ThreadIdType threadId) override;
138 
143  virtual FFTInputImagePointer
144  PadInputImageRegion(const RegionType & inputRegion);
145  RegionType
146  GetPaddedImageRegion(const RegionType & inputRegion);
148 
149  void
150  PrintSelf(std::ostream & os, itk::Indent indent) const override;
151 
152  bool
153  IsPrime(int n) const;
154 
155  int
156  GreatestPrimeFactor(int n) const;
157 
160  virtual void
161  UpdateFFTProjectionsConvolutionKernel(const SizeType size) = 0;
162 
168  virtual void
169  UpdateTruncationMirrorWeights();
170  typename std::vector<TFFTPrecision> m_TruncationMirrorWeights;
171 
174  int m_KernelDimension{ 1 };
175 
180 
181 private:
185  double m_TruncationCorrection{ 0. };
186  int
187  GetTruncationCorrectionExtent();
189 
194 
198  int m_GreatestPrimeFactor{ 2 };
199  int m_BackupNumberOfThreads{ 1 };
200 }; // end of class
201 
202 } // end namespace rtk
203 
204 #ifndef ITK_MANUAL_INSTANTIATION
205 # include "rtkFFTProjectionsConvolutionImageFilter.hxx"
206 #endif
207 
208 #endif
Base class for 1D or 2D FFT based convolution of projections.
ITKCommon_EXPORT bool IsPrime(unsigned int n)
TInputImage InputImageType
#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