RTK  2.0.1
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 
43 template< class TInput, class TOutput>
45 {
46 public:
47  ObiAttenuation() = default;
48  ~ObiAttenuation() = default;
49  bool operator!=( const ObiAttenuation & ) const
50  {
51  return false;
52  }
53  bool operator==( const ObiAttenuation & other ) const
54  {
55  return !(*this != other);
56  }
57  inline TOutput operator()( const TInput & A ) const
58  {
59  return (!A)?0.:TOutput( std::log( (m_I0-m_IDark) / ( A-m_IDark ) ) );
60  }
61  void SetI0(double i0) {m_I0 = i0;}
62  void SetIDark(double idark) {m_IDark = idark;}
63 
64 private:
65  double m_I0;
66  double m_IDark;
67 };
68 }
69 
79 template <class TInputImage, class TOutputImage>
80 class ITK_EXPORT VarianObiRawImageFilter :
81  public
82 itk::UnaryFunctorImageFilter<TInputImage,TOutputImage,
83  Function::ObiAttenuation<
84  typename TInputImage::PixelType,
85  typename TOutputImage::PixelType> >
86 {
87 public:
88  ITK_DISALLOW_COPY_AND_ASSIGN(VarianObiRawImageFilter);
89 
92  using Superclass = itk::UnaryFunctorImageFilter<TInputImage,TOutputImage,
93  Function::ObiAttenuation< typename TInputImage::PixelType,
94  typename TOutputImage::PixelType> >;
97 
99  itkNewMacro(Self);
100 
102  itkTypeMacro(VarianObiRawImageFilter,
104 
105  itkGetMacro(I0, double);
106  itkSetMacro(I0, double);
107 
108  itkGetMacro(IDark, double);
109  itkSetMacro(IDark, double);
110 
111  void BeforeThreadedGenerateData() override;
112 
113 protected:
115  ~VarianObiRawImageFilter() override = default;
116 
117 private:
118  double m_I0{139000.};
119  double m_IDark{0.};
120 };
121 
122 } // end namespace rtk
123 
124 #ifndef ITK_MANUAL_INSTANTIATION
125 #include "rtkVarianObiRawImageFilter.hxx"
126 #endif
127 
128 #endif
Converts a raw value measured by the Varian OBI system to attenuation.
TOutput operator()(const TInput &A) const
Converts raw images measured by the Varian OBI system to attenuation.
bool operator==(const ObiAttenuation &other) const
#define itkSetMacro(name, type)
bool operator!=(const ObiAttenuation &) const