RTK  2.1.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  * 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 
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_EXPORT FFTProjectionsConvolutionImageFilter : public itk::ImageToImageFilter<TInputImage, TOutputImage>
46 {
47 public:
48  ITK_DISALLOW_COPY_AND_ASSIGN(FFTProjectionsConvolutionImageFilter);
49 
55 
57  using InputImageType = TInputImage;
58  using OutputImageType = TOutputImage;
59  using RegionType = typename InputImageType::RegionType;
60  using IndexType = typename InputImageType::IndexType;
61  using SizeType = typename InputImageType::SizeType;
62 
64  using FFTInputImagePointer = typename FFTInputImageType::Pointer;
65  using FFTOutputImageType = typename itk::Image<std::complex<TFFTPrecision>, TInputImage::ImageDimension>;
66  using FFTOutputImagePointer = typename FFTOutputImageType::Pointer;
68 
70  itkStaticConstMacro(ImageDimension, unsigned int, TOutputImage::ImageDimension);
71 
74 
88  itkGetConstMacro(GreatestPrimeFactor, int);
89  itkSetMacro(GreatestPrimeFactor, int);
91 
95  itkGetConstMacro(TruncationCorrection, double);
96  itkSetMacro(TruncationCorrection, double);
98 
102  itkGetConstMacro(ZeroPadFactors, ZeroPadFactorsType);
103  virtual void
105  {
106  if (m_ZeroPadFactors != _arg)
107  {
108  m_ZeroPadFactors = _arg;
109  m_ZeroPadFactors[0] = std::max(m_ZeroPadFactors[0], 1);
110  m_ZeroPadFactors[1] = std::max(m_ZeroPadFactors[1], 1);
111  m_ZeroPadFactors[0] = std::min(m_ZeroPadFactors[0], 2);
112  m_ZeroPadFactors[1] = std::min(m_ZeroPadFactors[1], 2);
113  this->Modified();
114  }
115  }
117 
118 #ifdef ITK_USE_CONCEPT_CHECKING
120 #endif
121 
122 protected:
124  ~FFTProjectionsConvolutionImageFilter() override = default;
125 
126  void
127  GenerateInputRequestedRegion() override;
128 
129  void
130  BeforeThreadedGenerateData() override;
131 
132  void
133  AfterThreadedGenerateData() override;
134 
135  void
136  ThreadedGenerateData(const RegionType & outputRegionForThread, ThreadIdType threadId) override;
137 
142  virtual FFTInputImagePointer
143  PadInputImageRegion(const RegionType & inputRegion);
144  RegionType
145  GetPaddedImageRegion(const RegionType & inputRegion);
147 
148  void
149  PrintSelf(std::ostream & os, itk::Indent indent) const override;
150 
151  bool
152  IsPrime(int n) const;
153 
154  int
155  GreatestPrimeFactor(int n) const;
156 
159  virtual void
160  UpdateFFTProjectionsConvolutionKernel(const SizeType size) = 0;
161 
167  virtual void
168  UpdateTruncationMirrorWeights();
169  typename std::vector<TFFTPrecision> m_TruncationMirrorWeights;
170 
173  int m_KernelDimension{ 1 };
174 
179 
180 private:
184  double m_TruncationCorrection{ 0. };
185  int
186  GetTruncationCorrectionExtent();
188 
193 
197  int m_GreatestPrimeFactor{ 2 };
198  int m_BackupNumberOfThreads{ 1 };
199 }; // end of class
200 
201 } // end namespace rtk
202 
203 #ifndef ITK_MANUAL_INSTANTIATION
204 # include "rtkFFTProjectionsConvolutionImageFilter.hxx"
205 #endif
206 
207 #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