RTK  2.6.0
Reconstruction Toolkit
rtkPolynomialGainCorrectionImageFilter.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 rtkPolynomialGainCorrectionImageFilter_h
20 #define rtkPolynomialGainCorrectionImageFilter_h
21 
22 #include <itkImageToImageFilter.h>
23 
24 #include <vector>
25 
26 #include "rtkMacro.h"
27 
40 namespace rtk
41 {
42 
43 template <class TInputImage, class TOutputImage>
44 class ITK_TEMPLATE_EXPORT PolynomialGainCorrectionImageFilter
45  : public itk::ImageToImageFilter<TInputImage, TOutputImage>
46 {
47 public:
48  ITK_DISALLOW_COPY_AND_MOVE(PolynomialGainCorrectionImageFilter);
49 
55 
57  using InputImageType = TInputImage;
58  using OutputImageType = TOutputImage;
59  using InputImagePointer = typename InputImageType::Pointer;
60  using OutputImagePointer = typename OutputImageType::Pointer;
61  using InputImageRegionType = typename InputImageType::RegionType;
62  using OutputImageRegionType = typename TOutputImage::RegionType;
63  using VectorType = typename std::vector<float>;
64  using OutputSizeType = typename OutputImageType::SizeType;
65 
67  itkNewMacro(Self);
68 
70 #ifdef itkOverrideGetNameOfClassMacro
71  itkOverrideGetNameOfClassMacro(PolynomialGainCorrectionImageFilter);
72 #else
74 #endif
75 
76 
78  void
79  SetDarkImage(const InputImagePointer darkImage);
80 
83  void
84  SetGainCoefficients(const OutputImagePointer gain);
85 
86  /* if K==0, the filter is bypassed */
87  itkSetMacro(K, float);
88  itkGetMacro(K, float);
89 
90 protected:
92  ~PolynomialGainCorrectionImageFilter() override = default;
93 
94  void
95  GenerateOutputInformation() override;
96 
97  void
98  GenerateInputRequestedRegion() override;
99 
100  void
101  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
102 
103  bool m_MapsLoaded{ false }; // True if gain maps loaded
104  int m_VModelOrder{ 1 }; // Polynomial correction order
105  float m_K{ 1.0f }; // Scaling constant, a 0 means no correction
106  VectorType m_PowerLut; // Vector containing I^n
108  OutputImagePointer m_GainImage; // Gain coefficients (A matrix)
109  OutputSizeType m_GainSize; // Gain map size
110 }; // end of class
111 
112 } // namespace rtk
113 
114 #ifndef ITK_MANUAL_INSTANTIATION
115 # include "rtkPolynomialGainCorrectionImageFilter.hxx"
116 #endif
117 
118 #endif
typename OutputImageType::Pointer OutputImagePointer
TInputImage InputImageType
#define itkSetMacro(name, type)
typename InputImageType::Pointer InputImagePointer
typename OutputImageType::RegionType OutputImageRegionType
TOutputImage OutputImageType
typename InputImageType::RegionType InputImageRegionType