RTK  2.0.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  * 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>
46  public itk::ImageToImageFilter<TInputImage, TOutputImage>
47 {
48 public:
49  ITK_DISALLOW_COPY_AND_ASSIGN(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 
64  using FFTInputImageType = typename itk::Image<TFFTPrecision,
65  TInputImage::ImageDimension >;
66  using FFTInputImagePointer = typename FFTInputImageType::Pointer;
68  TInputImage::ImageDimension >;
69  using FFTOutputImagePointer = typename FFTOutputImageType::Pointer;
71 
73  itkStaticConstMacro(ImageDimension, unsigned int,
74  TOutputImage::ImageDimension);
75 
78 
92  itkGetConstMacro(GreatestPrimeFactor, int);
93  itkSetMacro(GreatestPrimeFactor, int);
95 
99  itkGetConstMacro(TruncationCorrection, double);
100  itkSetMacro(TruncationCorrection, double);
102 
106  itkGetConstMacro(ZeroPadFactors, ZeroPadFactorsType);
108  {
109  if (m_ZeroPadFactors != _arg)
110  {
111  m_ZeroPadFactors = _arg;
112  m_ZeroPadFactors[0] = std::max(m_ZeroPadFactors[0], 1);
113  m_ZeroPadFactors[1] = std::max(m_ZeroPadFactors[1], 1);
114  m_ZeroPadFactors[0] = std::min(m_ZeroPadFactors[0], 2);
115  m_ZeroPadFactors[1] = std::min(m_ZeroPadFactors[1], 2);
116  this->Modified();
117  }
118  }
120 
121 protected:
123  ~FFTProjectionsConvolutionImageFilter() override = default;
124 
125  void GenerateInputRequestedRegion() override;
126 
127  void BeforeThreadedGenerateData() override;
128 
129  void AfterThreadedGenerateData() override;
130 
131 #if ITK_VERSION_MAJOR<5
132  void ThreadedGenerateData( const RegionType& outputRegionForThread, ThreadIdType threadId ) override;
133 #else
134  void DynamicThreadedGenerateData( const RegionType& outputRegionForThread) override;
135 #endif
136 
141  virtual FFTInputImagePointer PadInputImageRegion(const RegionType &inputRegion);
142  RegionType GetPaddedImageRegion(const RegionType &inputRegion);
144 
145  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
146 
147  bool IsPrime( int n ) const;
148 
149  int GreatestPrimeFactor( int n ) const;
150 
153  virtual void UpdateFFTProjectionsConvolutionKernel(const SizeType size) = 0;
154 
160  virtual void UpdateTruncationMirrorWeights();
161  typename std::vector<TFFTPrecision> m_TruncationMirrorWeights;
162 
165  int m_KernelDimension{1};
166 
171 
172 private:
176  double m_TruncationCorrection{0.};
177  int GetTruncationCorrectionExtent();
179 
184 
188  int m_GreatestPrimeFactor{2};
189  int m_BackupNumberOfThreads{1};
190 }; // end of class
191 
192 } // end namespace rtk
193 
194 #ifndef ITK_MANUAL_INSTANTIATION
195 #include "rtkFFTProjectionsConvolutionImageFilter.hxx"
196 #endif
197 
198 #endif
Base class for 1D or 2D FFT based convolution of projections.
typename itk::Image< TFFTPrecision, TInputImage::ImageDimension > FFTInputImageType
ITKCommon_EXPORT unsigned short GreatestPrimeFactor(unsigned short n)
unsigned int ThreadIdType
ITKCommon_EXPORT bool IsPrime(unsigned short n)
typename itk::Image< std::complex< TFFTPrecision >, TInputImage::ImageDimension > FFTOutputImageType
#define itkSetMacro(name, type)