RTK  2.0.1
Reconstruction Toolkit
rtkLagCorrectionImageFilter.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 rtkLagCorrectionImageFilter_h
20 #define rtkLagCorrectionImageFilter_h
21 
22 #include <itkInPlaceImageFilter.h>
23 #include <itkVector.h>
24 #include <vector>
25 
26 #include "rtkConfiguration.h"
27 #include "rtkMacro.h"
28 
29 namespace rtk
30 {
31 
53 template< typename TImage, unsigned ModelOrder >
55 : public itk::InPlaceImageFilter < TImage, TImage >
56 {
57 public:
58  ITK_DISALLOW_COPY_AND_ASSIGN(LagCorrectionImageFilter);
59 
65 
67  itkNewMacro(Self)
68 
69 
71 
72  using ImageRegionType = typename TImage::RegionType;
73  using ImageSizeType = typename TImage::SizeType;
74  using PixelType = typename TImage::PixelType;
75  using IndexType = typename TImage::IndexType;
76  using VectorType = typename itk::Vector<float, ModelOrder>;
77  using FloatVectorType = typename std::vector<float>;
78  using OutputImageRegionType = typename TImage::RegionType;
79 
81  itkGetMacro(A, VectorType)
82  itkGetMacro(B, VectorType)
83  virtual void SetCoefficients(const VectorType A, const VectorType B)
84  {
85  if ((this->m_A != A) && (this->m_B != B))
86  {
87  if ((A.Size() == ModelOrder) && (B.Size() == ModelOrder)) {}
88  this->m_A = A;
89  this->m_B = B;
90  this->Modified();
92  }
93  }
95 
96 protected:
98  ~LagCorrectionImageFilter() override = default;
99 
100  void GenerateOutputInformation() override;
101 
102  void GenerateInputRequestedRegion() override;
103 
104  void ThreadedGenerateData(const ImageRegionType & outputRegionForThread, itk::ThreadIdType threadId) override;
105 
109  unsigned int SplitRequestedRegion(unsigned int i, unsigned int num, OutputImageRegionType& splitRegion) override;
110  virtual int SplitRequestedRegion(int i, int num, OutputImageRegionType& splitRegion);
112 
113  VectorType m_A; // a_n coefficients (lag rates)
114  VectorType m_B; // b coefficients (lag coefficients)
115  VectorType m_ExpmA; // exp(-a)
116  float m_SumB; // normalization factor
117 
118 protected:
119  FloatVectorType m_S; // State variable
120 
121 private:
122  bool m_NewParamJustReceived; // For state/correction initialization
123  IndexType m_StartIdx; // To account for cropping
124 };
125 
126 }
127 
128 #ifndef ITK_MANUAL_INSTANTIATION
129 #include "rtkLagCorrectionImageFilter.hxx"
130 #endif
131 
132 #endif
void ThreadedGenerateData(const ImageRegionType &outputRegionForThread, itk::ThreadIdType threadId) override
typename TImage::PixelType PixelType
typename itk::Vector< float, ModelOrder > VectorType
Classical Linear Time Invariant Lag correction.
void GenerateInputRequestedRegion() override
STL namespace.
~LagCorrectionImageFilter() override=default
typename std::vector< float > FloatVectorType
typename TImage::IndexType IndexType
ImageBaseType::SizeType SizeType
typename TImage::RegionType OutputImageRegionType
unsigned int ThreadIdType
virtual void SetCoefficients(const VectorType A, const VectorType B)
void GenerateOutputInformation() override
unsigned int SplitRequestedRegion(unsigned int i, unsigned int num, OutputImageRegionType &splitRegion) override
typename TImage::SizeType ImageSizeType
ImageBaseType::RegionType RegionType
typename TImage::RegionType ImageRegionType