RTK  1.4.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>
46  public itk::ImageToImageFilter<TInputImage, TOutputImage>
47 {
48 public:
54 
56  typedef TInputImage InputImageType;
57  typedef TOutputImage OutputImageType;
58  typedef typename InputImageType::RegionType RegionType;
59  typedef typename InputImageType::IndexType IndexType;
60  typedef typename InputImageType::SizeType SizeType;
61 
62  typedef typename itk::Image<TFFTPrecision,
63  TInputImage::ImageDimension > FFTInputImageType;
64  typedef typename FFTInputImageType::Pointer FFTInputImagePointer;
66  TInputImage::ImageDimension > FFTOutputImageType;
67  typedef typename FFTOutputImageType::Pointer FFTOutputImagePointer;
69 
71  itkStaticConstMacro(ImageDimension, unsigned int,
72  TOutputImage::ImageDimension);
73 
76 
90  itkGetConstMacro(GreatestPrimeFactor, int);
91  itkSetMacro(GreatestPrimeFactor, int);
93 
97  itkGetConstMacro(TruncationCorrection, double);
98  itkSetMacro(TruncationCorrection, double);
100 
104  itkGetConstMacro(ZeroPadFactors, ZeroPadFactorsType);
105  virtual void SetZeroPadFactors (ZeroPadFactorsType _arg)
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 protected:
121  virtual ~FFTProjectionsConvolutionImageFilter() ITK_OVERRIDE {}
122 
123  void GenerateInputRequestedRegion() ITK_OVERRIDE;
124 
125  void BeforeThreadedGenerateData() ITK_OVERRIDE;
126 
127  void AfterThreadedGenerateData() ITK_OVERRIDE;
128 
129 #if ITK_VERSION_MAJOR<5
130  void ThreadedGenerateData( const RegionType& outputRegionForThread, ThreadIdType threadId ) ITK_OVERRIDE;
131 #else
132  void DynamicThreadedGenerateData( const RegionType& outputRegionForThread) ITK_OVERRIDE;
133 #endif
134 
139  virtual FFTInputImagePointer PadInputImageRegion(const RegionType &inputRegion);
140  RegionType GetPaddedImageRegion(const RegionType &inputRegion);
142 
143  void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
144 
145  bool IsPrime( int n ) const;
146 
147  int GreatestPrimeFactor( int n ) const;
148 
151  virtual void UpdateFFTProjectionsConvolutionKernel(const SizeType size) = 0;
152 
158  virtual void UpdateTruncationMirrorWeights();
159  typename std::vector<TFFTPrecision> m_TruncationMirrorWeights;
160 
164 
168  FFTOutputImagePointer m_KernelFFT;
169 
170 private:
171  FFTProjectionsConvolutionImageFilter(const Self&); //purposely not implemented
172  void operator=(const Self&); //purposely not implemented
173 
178  int GetTruncationCorrectionExtent();
180 
184  ZeroPadFactorsType m_ZeroPadFactors;
185 
191 }; // end of class
192 
193 } // end namespace rtk
194 
195 #ifndef ITK_MANUAL_INSTANTIATION
196 #include "rtkFFTProjectionsConvolutionImageFilter.hxx"
197 #endif
198 
199 #endif
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
Base class for 1D or 2D FFT based convolution of projections.
ITKCommon_EXPORT unsigned short GreatestPrimeFactor(unsigned short n)
itk::Image< std::complex< TFFTPrecision >, TInputImage::ImageDimension > FFTOutputImageType
itk::Image< TFFTPrecision, TInputImage::ImageDimension > FFTInputImageType
unsigned int ThreadIdType
ITKCommon_EXPORT bool IsPrime(unsigned short n)
#define itkSetMacro(name, type)