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  itkOverrideGetNameOfClassMacro(PolynomialGainCorrectionImageFilter);
71 
73  void
74  SetDarkImage(InputImageType * darkImage);
75 
78  void
79  SetGainCoefficients(OutputImageType * gain);
80 
81  /* if K==0, the filter is bypassed */
82  itkSetMacro(K, float);
83  itkGetMacro(K, float);
84 
85 protected:
87  ~PolynomialGainCorrectionImageFilter() override = default;
88 
89  void
90  GenerateOutputInformation() override;
91 
92  void
93  GenerateInputRequestedRegion() override;
94 
95  void
96  DynamicThreadedGenerateData(const OutputImageRegionType & outputRegionForThread) override;
97 
98  bool m_MapsLoaded{ false }; // True if gain maps loaded
99  int m_VModelOrder{ 1 }; // Polynomial correction order
100  float m_K{ 1.0f }; // Scaling constant, a 0 means no correction
101  VectorType m_PowerLut; // Vector containing I^n
103  OutputImagePointer m_GainImage; // Gain coefficients (A matrix)
104  OutputSizeType m_GainSize; // Gain map size
105 }; // end of class
106 
107 } // namespace rtk
108 
109 #ifndef ITK_MANUAL_INSTANTIATION
110 # include "rtkPolynomialGainCorrectionImageFilter.hxx"
111 #endif
112 
113 #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