RTK  1.4.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  * 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 #include <itkSimpleFastMutexLock.h>
24 
25 #include <vector>
26 
27 #include "rtkMacro.h"
28 
41 namespace rtk
42 {
43 
44 template<class TInputImage, class TOutputImage>
46 public itk::ImageToImageFilter<TInputImage, TOutputImage>
47 {
48 public:
54 
56  typedef TInputImage InputImageType;
57  typedef TOutputImage OutputImageType;
58  typedef typename InputImageType::Pointer InputImagePointer;
59  typedef typename OutputImageType::Pointer OutputImagePointer;
60  typedef typename InputImageType::RegionType InputImageRegionType;
61  typedef typename TOutputImage::RegionType OutputImageRegionType;
62  typedef typename std::vector< float > VectorType;
63  typedef typename OutputImageType::SizeType OutputSizeType;
64 
66  itkNewMacro(Self);
67 
70 
72  void SetDarkImage(const InputImagePointer gain);
73 
76  void SetGainCoefficients(const OutputImagePointer gain);
77 
78  /* if K==0, the filter is bypassed */
79  itkSetMacro(K, float);
80  itkGetMacro(K, float);
81 
82 protected:
84  virtual ~PolynomialGainCorrectionImageFilter() ITK_OVERRIDE {}
85 
86  void GenerateOutputInformation() ITK_OVERRIDE;
87 
88  void GenerateInputRequestedRegion() ITK_OVERRIDE;
89 
90 #if ITK_VERSION_MAJOR<5
91  void ThreadedGenerateData( const OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId ) ITK_OVERRIDE;
92 #else
93  void DynamicThreadedGenerateData( const OutputImageRegionType& outputRegionForThread) ITK_OVERRIDE;
94 #endif
95 
96 private:
97  //purposely not implemented
99  void operator=(const Self&);
100 
101 protected:
102  bool m_MapsLoaded; // True if gain maps loaded
103  int m_ModelOrder; // Polynomial correction order
104  float m_K; // Scaling constant, a 0 means no correction
105  VectorType m_PowerLut; // Vector containing I^n
106  InputImagePointer m_DarkImage; // Dark image
107  OutputImagePointer m_GainImage; // Gain coefficients (A matrix)
108  OutputSizeType m_GainSize; // Gain map size
109 }; // end of class
110 
111 }
112 
113 #ifndef ITK_MANUAL_INSTANTIATION
114 #include "rtkPolynomialGainCorrectionImageFilter.hxx"
115 #endif
116 
117 #endif
itk::ImageToImageFilter< TInputImage, TOutputImage > Superclass
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, itk::ThreadIdType threadId) override
void SetDarkImage(const InputImagePointer gain)
unsigned int ThreadIdType
void SetGainCoefficients(const OutputImagePointer gain)
#define itkSetMacro(name, type)