RTK  2.0.1
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  * 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 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>
45 public itk::ImageToImageFilter<TInputImage, TOutputImage>
46 {
47 public:
48  ITK_DISALLOW_COPY_AND_ASSIGN(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 
71 
73  void SetDarkImage(const InputImagePointer gain);
74 
77  void SetGainCoefficients(const OutputImagePointer gain);
78 
79  /* if K==0, the filter is bypassed */
80  itkSetMacro(K, float);
81  itkGetMacro(K, float);
82 
83 protected:
85  ~PolynomialGainCorrectionImageFilter() override = default;
86 
87  void GenerateOutputInformation() override;
88 
89  void GenerateInputRequestedRegion() override;
90 
91 #if ITK_VERSION_MAJOR<5
92  void ThreadedGenerateData( const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId ) override;
93 #else
94  void DynamicThreadedGenerateData( const OutputImageRegionType& outputRegionForThread) override;
95 #endif
96 
97  bool m_MapsLoaded{false}; // True if gain maps loaded
98  int m_ModelOrder{1}; // Polynomial correction order
99  float m_K{1.0f}; // Scaling constant, a 0 means no correction
100  VectorType m_PowerLut; // Vector containing I^n
102  OutputImagePointer m_GainImage; // Gain coefficients (A matrix)
103  OutputSizeType m_GainSize; // Gain map size
104 }; // end of class
105 
106 }
107 
108 #ifndef ITK_MANUAL_INSTANTIATION
109 #include "rtkPolynomialGainCorrectionImageFilter.hxx"
110 #endif
111 
112 #endif
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, itk::ThreadIdType threadId) override
~PolynomialGainCorrectionImageFilter() override=default
void SetDarkImage(const InputImagePointer gain)
unsigned int ThreadIdType
void SetGainCoefficients(const OutputImagePointer gain)
#define itkSetMacro(name, type)