RTK  2.4.1
Reconstruction Toolkit
rtkJosephForwardProjectionImageFilter.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 rtkJosephForwardProjectionImageFilter_h
20 #define rtkJosephForwardProjectionImageFilter_h
21 
22 #include "rtkConfiguration.h"
24 #include "rtkMacro.h"
25 #include <itkPixelTraits.h>
26 
28 
29 #include <itkVectorImage.h>
30 namespace rtk
31 {
32 namespace Functor
33 {
42 template <class TInput, class TCoordRepType, class TOutput = TInput>
43 class ITK_TEMPLATE_EXPORT InterpolationWeightMultiplication
44 {
45 public:
48  bool
50  {
51  return false;
52  }
53  bool
55  {
56  return !(*this != other);
57  }
58 
59  inline TOutput
60  operator()(const ThreadIdType itkNotUsed(threadId),
61  const double itkNotUsed(stepLengthInVoxel),
62  const TCoordRepType weight,
63  const TInput * p,
64  const int i) const
65  {
66  return weight * p[i];
67  }
68 };
69 
77 template <class TInput, class TOutput>
78 class ITK_TEMPLATE_EXPORT SumAlongRay
79 {
80 public:
82 
83  SumAlongRay() = default;
84  ~SumAlongRay() = default;
85  bool
86  operator!=(const SumAlongRay &) const
87  {
88  return false;
89  }
90  bool
91  operator==(const SumAlongRay & other) const
92  {
93  return !(*this != other);
94  }
95 
96  inline TOutput
97  operator()(const ThreadIdType itkNotUsed(threadId), const TInput volumeValue, const VectorType & itkNotUsed(stepInMM))
98  {
99  return volumeValue;
100  }
101 };
102 
110 template <class TInput, class TOutput>
111 class ITK_TEMPLATE_EXPORT ProjectedValueAccumulation
112 {
113 public:
115 
116  ProjectedValueAccumulation() = default;
117  ~ProjectedValueAccumulation() = default;
118  bool
120  {
121  return false;
122  }
123  bool
125  {
126  return !(*this != other);
127  }
128 
129  inline void
130  operator()(const ThreadIdType itkNotUsed(threadId),
131  const TInput & input,
132  TOutput & output,
133  const TOutput & rayCastValue,
134  const VectorType & stepInMM,
135  const VectorType & itkNotUsed(source),
136  const VectorType & itkNotUsed(sourceToPixel),
137  const VectorType & itkNotUsed(nearestPoint),
138  const VectorType & itkNotUsed(farthestPoint)) const
139  {
140  output = input + rayCastValue * stepInMM.GetNorm();
141  }
142 };
143 
144 } // end namespace Functor
145 
146 
162 template <class TInputImage,
163  class TOutputImage,
164  class TInterpolationWeightMultiplication = Functor::InterpolationWeightMultiplication<
165  typename TInputImage::PixelType,
167  class TProjectedValueAccumulation =
168  Functor::ProjectedValueAccumulation<typename TInputImage::PixelType, typename TOutputImage::PixelType>,
169  class TSumAlongRay = Functor::SumAlongRay<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
170 class ITK_TEMPLATE_EXPORT JosephForwardProjectionImageFilter
171  : public ForwardProjectionImageFilter<TInputImage, TOutputImage>
172 {
173 public:
174  ITK_DISALLOW_COPY_AND_MOVE(JosephForwardProjectionImageFilter);
175 
181  using InputPixelType = typename TInputImage::PixelType;
182  using OutputPixelType = typename TOutputImage::PixelType;
183  using OutputImageRegionType = typename TOutputImage::RegionType;
184  using CoordRepType = double;
186 
188  itkNewMacro(Self);
189 
192 
194  TInterpolationWeightMultiplication &
196  {
197  return m_InterpolationWeightMultiplication;
198  }
199  const TInterpolationWeightMultiplication &
201  {
202  return m_InterpolationWeightMultiplication;
203  }
204  void
205  SetInterpolationWeightMultiplication(const TInterpolationWeightMultiplication & _arg)
206  {
207  if (m_InterpolationWeightMultiplication != _arg)
208  {
209  m_InterpolationWeightMultiplication = _arg;
210  this->Modified();
211  }
212  }
214 
217  TProjectedValueAccumulation &
219  {
220  return m_ProjectedValueAccumulation;
221  }
222  const TProjectedValueAccumulation &
224  {
225  return m_ProjectedValueAccumulation;
226  }
227  void
228  SetProjectedValueAccumulation(const TProjectedValueAccumulation & _arg)
229  {
230  if (m_ProjectedValueAccumulation != _arg)
231  {
232  m_ProjectedValueAccumulation = _arg;
233  this->Modified();
234  }
235  }
237 
239  TSumAlongRay &
241  {
242  return m_SumAlongRay;
243  }
244  const TSumAlongRay &
246  {
247  return m_SumAlongRay;
248  }
249  void
250  SetSumAlongRay(const TSumAlongRay & _arg)
251  {
252  if (m_SumAlongRay != _arg)
253  {
254  m_SumAlongRay = _arg;
255  this->Modified();
256  }
257  }
259 
263  itkGetMacro(InferiorClip, double);
264  itkSetMacro(InferiorClip, double);
265  itkGetMacro(SuperiorClip, double);
266  itkSetMacro(SuperiorClip, double);
268 
269 protected:
271  ~JosephForwardProjectionImageFilter() override = default;
272 
273  void
274  ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, ThreadIdType threadId) override;
275 
278  void
279  VerifyInputInformation() const override
280  {}
281 
282  inline OutputPixelType
283  BilinearInterpolation(const ThreadIdType threadId,
284  const double stepLengthInVoxel,
285  const InputPixelType * pxiyi,
286  const InputPixelType * pxsyi,
287  const InputPixelType * pxiys,
288  const InputPixelType * pxsys,
289  const double x,
290  const double y,
291  const int ox,
292  const int oy);
293 
294  inline OutputPixelType
295  BilinearInterpolationOnBorders(const ThreadIdType threadId,
296  const double stepLengthInVoxel,
297  const InputPixelType * pxiyi,
298  const InputPixelType * pxsyi,
299  const InputPixelType * pxiys,
300  const InputPixelType * pxsys,
301  const double x,
302  const double y,
303  const int ox,
304  const int oy,
305  const double minx,
306  const double miny,
307  const double maxx,
308  const double maxy);
309 
310 private:
311  // Functors
312  TInterpolationWeightMultiplication m_InterpolationWeightMultiplication;
313  TProjectedValueAccumulation m_ProjectedValueAccumulation;
314  TSumAlongRay m_SumAlongRay;
315  double m_InferiorClip{ 0. };
316  double m_SuperiorClip{ 1. };
317 };
318 
319 } // end namespace rtk
320 
321 #ifndef ITK_MANUAL_INSTANTIATION
322 # include "rtkJosephForwardProjectionImageFilter.hxx"
323 #endif
324 
325 #endif
void SetInterpolationWeightMultiplication(const TInterpolationWeightMultiplication &_arg)
Base class for forward projection, i.e. accumulation along x-ray lines.
Function to accumulate the ray casting on the projection.
const TProjectedValueAccumulation & GetProjectedValueAccumulation() const
Function to compute the attenuation correction on the projection.
bool operator==(const SumAlongRay &other) const
const TInterpolationWeightMultiplication & GetInterpolationWeightMultiplication() const
TOutput operator()(const ThreadIdType, const TInput volumeValue, const VectorType &)
bool operator!=(const SumAlongRay &) const
typename TPixelType::ValueType ValueType
#define itkSetMacro(name, type)
bool operator!=(const ProjectedValueAccumulation &) const
TOutput operator()(const ThreadIdType, const double, const TCoordRepType weight, const TInput *p, const int i) const
bool operator==(const InterpolationWeightMultiplication &other) const
Function to multiply the interpolation weights with the projected volume values.
typename OutputImageType::RegionType OutputImageRegionType
void SetProjectedValueAccumulation(const TProjectedValueAccumulation &_arg)
TInterpolationWeightMultiplication m_InterpolationWeightMultiplication
bool operator==(const ProjectedValueAccumulation &other) const
bool operator!=(const InterpolationWeightMultiplication &) const
TInterpolationWeightMultiplication & GetInterpolationWeightMultiplication()
unsigned int ThreadIdType
void operator()(const ThreadIdType, const TInput &input, TOutput &output, const TOutput &rayCastValue, const VectorType &stepInMM, const VectorType &, const VectorType &, const VectorType &, const VectorType &) const