RTK  2.6.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  * 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 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>
45 class ITK_TEMPLATE_EXPORT ObiAttenuation
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_TEMPLATE_EXPORT VarianObiRawImageFilter
94  TInputImage,
95  TOutputImage,
96  Function::ObiAttenuation<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
97 {
98 public:
99  ITK_DISALLOW_COPY_AND_MOVE(VarianObiRawImageFilter);
100 
104  TInputImage,
105  TOutputImage,
109 
111  itkNewMacro(Self);
112 
114 #ifdef itkOverrideGetNameOfClassMacro
115  itkOverrideGetNameOfClassMacro(VarianObiRawImageFilter);
116 #else
118 #endif
119 
120 
121  itkGetMacro(I0, double);
122  itkSetMacro(I0, double);
123 
124  itkGetMacro(IDark, double);
125  itkSetMacro(IDark, double);
126 
127  void
128  BeforeThreadedGenerateData() override;
129 
130 protected:
132  ~VarianObiRawImageFilter() override = default;
133 
134 private:
135  double m_I0{ 139000. };
136  double m_IDark{ 0. };
137 };
138 
139 } // end namespace rtk
140 
141 #ifndef ITK_MANUAL_INSTANTIATION
142 # include "rtkVarianObiRawImageFilter.hxx"
143 #endif
144 
145 #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.