RTK  2.5.0
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  * 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 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 
54 template <typename TImage, unsigned VModelOrder>
55 class ITK_TEMPLATE_EXPORT LagCorrectionImageFilter : public itk::InPlaceImageFilter<TImage, TImage>
56 {
57 public:
58  ITK_DISALLOW_COPY_AND_MOVE(LagCorrectionImageFilter);
59 
65 
67  itkNewMacro(Self);
68 
70 #ifdef itkOverrideGetNameOfClassMacro
71  itkOverrideGetNameOfClassMacro(LagCorrectionImageFilter);
72 #else
74 #endif
75 
76 
77  using ImageRegionType = typename TImage::RegionType;
78  using ImageSizeType = typename TImage::SizeType;
79  using PixelType = typename TImage::PixelType;
80  using IndexType = typename TImage::IndexType;
82  using FloatVectorType = typename std::vector<float>;
83  using OutputImageRegionType = typename TImage::RegionType;
84 
86  itkGetMacro(A, VectorType);
87  itkGetMacro(B, VectorType);
88  virtual void
90  {
91  if ((this->m_A != A) && (this->m_B != B))
92  {
93  if ((A.Size() == VModelOrder) && (B.Size() == VModelOrder))
94  {
95  }
96  this->m_A = A;
97  this->m_B = B;
98  this->Modified();
99  m_NewParamJustReceived = true;
100  }
101  }
103 
104 protected:
106  ~LagCorrectionImageFilter() override = default;
107 
108  void
109  GenerateOutputInformation() override;
110 
111  void
112  GenerateInputRequestedRegion() override;
113 
114  void
115  ThreadedGenerateData(const ImageRegionType & thRegion, itk::ThreadIdType threadId) override;
116 
120  unsigned int
121  SplitRequestedRegion(unsigned int i, unsigned int num, OutputImageRegionType & splitRegion) override;
122  virtual int
123  SplitRequestedRegion(int i, int num, OutputImageRegionType & splitRegion);
125 
126  VectorType m_A; // a_n coefficients (lag rates)
127  VectorType m_B; // b coefficients (lag coefficients)
128  VectorType m_ExpmA; // exp(-a)
129  float m_SumB; // normalization factor
130 
131 protected:
132  FloatVectorType m_S; // State variable
133 
134 private:
135  bool m_NewParamJustReceived; // For state/correction initialization
136  IndexType m_StartIdx; // To account for cropping
137 };
138 
139 } // namespace rtk
140 
141 #ifndef ITK_MANUAL_INSTANTIATION
142 # include "rtkLagCorrectionImageFilter.hxx"
143 #endif
144 
145 #endif
typename TImage::PixelType PixelType
virtual void SetCoefficients(const VectorType A, const VectorType B)
Classical Linear Time Invariant Lag correction.
typename itk::Vector< float, VModelOrder > VectorType
typename std::vector< float > FloatVectorType
typename OutputImageType::RegionType OutputImageRegionType
typename TImage::SizeType ImageSizeType
typename TImage::RegionType ImageRegionType
unsigned int ThreadIdType
typename TImage::IndexType IndexType