RTK  2.6.0
Reconstruction Toolkit
rtkJosephBackAttenuatedProjectionImageFilter.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 rtkJosephBackAttenuatedProjectionImageFilter_h
20 #define rtkJosephBackAttenuatedProjectionImageFilter_h
21 
22 #include "rtkConfiguration.h"
25 
26 namespace rtk
27 {
28 namespace Functor
29 {
38 template <class TInput, class TCoordRepType, class TOutput = TInput>
40 {
41 public:
43 
45  bool
47  {
48  return false;
49  }
50 
51  bool
53  {
54  return !(*this != other);
55  }
56 
57  inline TOutput
58  operator()(const double stepLengthInVoxel, const TCoordRepType weight, const TInput * p, const int i)
59  {
60  const double w = weight * stepLengthInVoxel;
61 
62  m_AttenuationPixel += w * (p + m_AttenuationMinusEmissionMapsPtrDiff)[i];
63  return w * (p + m_AttenuationMinusEmissionMapsPtrDiff)[i];
64  }
65 
66  void
68  {
69  m_AttenuationMinusEmissionMapsPtrDiff = pd;
70  }
71  TOutput *
73  {
74  return &m_AttenuationPixel;
75  }
76 
77 private:
80 };
81 
89 template <class TInput, class TOutput>
91 {
92 public:
94 
96 
98  bool
100  {
101  return false;
102  }
103 
104  bool
106  {
107  return !(*this != other);
108  }
109 
110  inline TOutput
111  operator()(const TInput rayValue, const TInput attenuationRay, const VectorType & stepInMM, bool & isNewRay)
112  {
113  if (isNewRay)
114  {
115  m_Ex1 = 1;
116  isNewRay = false;
117  }
118  TInput ex2 = exp(-attenuationRay * stepInMM.GetNorm());
119  TInput wf;
120  if (*m_AttenuationPixel > 0)
121  {
122  wf = (m_Ex1 - ex2) / *m_AttenuationPixel;
123  }
124  else
125  {
126  wf = m_Ex1 * stepInMM.GetNorm();
127  }
128 
129  m_Ex1 = ex2;
130  *m_AttenuationPixel = 0;
131  return wf * rayValue;
132  }
133 
134  void
135  SetAttenuationPixel(TInput * attenuationPixel)
136  {
137  m_AttenuationPixel = attenuationPixel;
138  }
139 
140 private:
141  TInput m_Ex1;
143 };
144 
153 template <class TInput, class TCoordRepType, class TOutput = TCoordRepType>
154 class ITK_TEMPLATE_EXPORT SplatWeightMultiplicationAttenuated
155 {
156 public:
159  bool
161  {
162  return false;
163  }
164 
165  bool
167  {
168  return !(*this != other);
169  }
170 
171  inline void
172  operator()(const TInput & rayValue,
173  TOutput & output,
174  const double stepLengthInVoxel,
175  const double itkNotUsed(voxelSize),
176  const TCoordRepType weight) const
177  {
178  output += rayValue * weight * stepLengthInVoxel;
179  }
180 };
181 } // end namespace Functor
182 
197 template <
198  class TInputImage,
199  class TOutputImage,
200  class TInterpolationWeightMultiplication = Functor::InterpolationWeightMultiplicationAttenuatedBackProjection<
201  typename TInputImage::PixelType,
203  class TSplatWeightMultiplication = Functor::
204  SplatWeightMultiplicationAttenuated<typename TInputImage::PixelType, double, typename TOutputImage::PixelType>,
205  class TSumAlongRay = Functor::ComputeAttenuationCorrectionBackProjection<typename TInputImage::PixelType,
206  typename TOutputImage::PixelType>>
208  : public JosephBackProjectionImageFilter<TInputImage,
209  TOutputImage,
210  TInterpolationWeightMultiplication,
211  TSplatWeightMultiplication,
212  TSumAlongRay>
213 {
214 public:
215  ITK_DISALLOW_COPY_AND_MOVE(JosephBackAttenuatedProjectionImageFilter);
216 
219  using Superclass = JosephBackProjectionImageFilter<TInputImage,
220  TOutputImage,
221  TInterpolationWeightMultiplication,
222  TSplatWeightMultiplication,
223  TSumAlongRay>;
226  using InputPixelType = typename TInputImage::PixelType;
227  using OutputPixelType = typename TOutputImage::PixelType;
228  using OutputImageRegionType = typename TOutputImage::RegionType;
229  using CoordRepType = double;
233 
235  static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
236 
238  itkNewMacro(Self);
239 
241 #ifdef itkOverrideGetNameOfClassMacro
242  itkOverrideGetNameOfClassMacro(JosephBackAttenuatedProjectionImageFilter);
243 #else
245 #endif
246 
247 
248 protected:
250  ~JosephBackAttenuatedProjectionImageFilter() override = default;
251 
253  void
254  GenerateInputRequestedRegion() override;
255 
258  void
259  VerifyInputInformation() const override;
260 
261  void
262  GenerateData() override;
263 
264  void
265  Init();
266 };
267 } // end namespace rtk
268 
269 #ifndef ITK_MANUAL_INSTANTIATION
270 # include "rtkJosephBackAttenuatedProjectionImageFilter.hxx"
271 #endif
272 
273 #endif
Function to multiply the interpolation weights with the projected volume values and attenuation map...
bool operator!=(const InterpolationWeightMultiplicationAttenuatedBackProjection &) const
TOutput operator()(const double stepLengthInVoxel, const TCoordRepType weight, const TInput *p, const int i)
typename TInputImage::PixelType InputPixelType
TOutput operator()(const TInput rayValue, const TInput attenuationRay, const VectorType &stepInMM, bool &isNewRay)
typename TPixelType::ValueType ValueType
Projection geometry for a source and a 2-D flat panel.
bool operator==(const SplatWeightMultiplicationAttenuated &other) const
bool operator==(const ComputeAttenuationCorrectionBackProjection &other) const
typename OutputImageType::RegionType OutputImageRegionType
Function to compute the attenuation correction on the projection.
bool operator==(const InterpolationWeightMultiplicationAttenuatedBackProjection &other) const
bool operator!=(const ComputeAttenuationCorrectionBackProjection &) const
Function to multiply the interpolation weights with the projection values.
bool operator!=(const SplatWeightMultiplicationAttenuated &) const
void operator()(const TInput &rayValue, TOutput &output, const double stepLengthInVoxel, const double, const TCoordRepType weight) const