RTK  2.1.0
Reconstruction Toolkit
rtkVarianObiRawImageFilter.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 rtkVarianObiRawImageFilter_h
20 #define rtkVarianObiRawImageFilter_h
21 
23 #include <itkConceptChecking.h>
24 #include <itkNumericTraits.h>
25 
26 #include "rtkMacro.h"
27 
28 namespace rtk
29 {
30 
31 namespace Function
32 {
33 
44 template <class TInput, class TOutput>
46 {
47 public:
48  ObiAttenuation() = default;
49  ~ObiAttenuation() = default;
50  bool
51  operator!=(const ObiAttenuation &) const
52  {
53  return false;
54  }
55  bool
56  operator==(const ObiAttenuation & other) const
57  {
58  return !(*this != other);
59  }
60  inline TOutput
61  operator()(const TInput & A) const
62  {
63  return (!A) ? 0. : TOutput(std::log((m_I0 - m_IDark) / (A - m_IDark)));
64  }
65  void
66  SetI0(double i0)
67  {
68  m_I0 = i0;
69  }
70  void
71  SetIDark(double idark)
72  {
73  m_IDark = idark;
74  }
75 
76 private:
77  double m_I0;
78  double m_IDark;
79 };
80 } // namespace Function
81 
91 template <class TInputImage, class TOutputImage>
92 class ITK_EXPORT VarianObiRawImageFilter
94  TInputImage,
95  TOutputImage,
96  Function::ObiAttenuation<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
97 {
98 public:
99  ITK_DISALLOW_COPY_AND_ASSIGN(VarianObiRawImageFilter);
100 
104  TInputImage,
105  TOutputImage,
109 
111  itkNewMacro(Self);
112 
115 
116  itkGetMacro(I0, double);
117  itkSetMacro(I0, double);
118 
119  itkGetMacro(IDark, double);
120  itkSetMacro(IDark, double);
121 
122  void
123  BeforeThreadedGenerateData() override;
124 
125 protected:
127  ~VarianObiRawImageFilter() override = default;
128 
129 private:
130  double m_I0{ 139000. };
131  double m_IDark{ 0. };
132 };
133 
134 } // end namespace rtk
135 
136 #ifndef ITK_MANUAL_INSTANTIATION
137 # include "rtkVarianObiRawImageFilter.hxx"
138 #endif
139 
140 #endif
Converts a raw value measured by the Varian OBI system to attenuation.
TOutput operator()(const TInput &A) const
bool operator==(const ObiAttenuation &other) const
#define itkSetMacro(name, type)
bool operator!=(const ObiAttenuation &) const
Converts raw images measured by the Varian OBI system to attenuation.