RTK  2.1.0
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  * 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 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>
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>
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>
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_EXPORT JosephForwardProjectionImageFilter : public ForwardProjectionImageFilter<TInputImage, TOutputImage>
171 {
172 public:
173  ITK_DISALLOW_COPY_AND_ASSIGN(JosephForwardProjectionImageFilter);
174 
180  using InputPixelType = typename TInputImage::PixelType;
181  using OutputPixelType = typename TOutputImage::PixelType;
182  using OutputImageRegionType = typename TOutputImage::RegionType;
183  using CoordRepType = double;
185 
187  itkNewMacro(Self);
188 
191 
193  TInterpolationWeightMultiplication &
195  {
196  return m_InterpolationWeightMultiplication;
197  }
198  const TInterpolationWeightMultiplication &
200  {
201  return m_InterpolationWeightMultiplication;
202  }
203  void
204  SetInterpolationWeightMultiplication(const TInterpolationWeightMultiplication & _arg)
205  {
206  if (m_InterpolationWeightMultiplication != _arg)
207  {
208  m_InterpolationWeightMultiplication = _arg;
209  this->Modified();
210  }
211  }
213 
216  TProjectedValueAccumulation &
218  {
219  return m_ProjectedValueAccumulation;
220  }
221  const TProjectedValueAccumulation &
223  {
224  return m_ProjectedValueAccumulation;
225  }
226  void
227  SetProjectedValueAccumulation(const TProjectedValueAccumulation & _arg)
228  {
229  if (m_ProjectedValueAccumulation != _arg)
230  {
231  m_ProjectedValueAccumulation = _arg;
232  this->Modified();
233  }
234  }
236 
238  TSumAlongRay &
240  {
241  return m_SumAlongRay;
242  }
243  const TSumAlongRay &
245  {
246  return m_SumAlongRay;
247  }
248  void
249  SetSumAlongRay(const TSumAlongRay & _arg)
250  {
251  if (m_SumAlongRay != _arg)
252  {
253  m_SumAlongRay = _arg;
254  this->Modified();
255  }
256  }
258 
262  itkGetMacro(InferiorClip, double);
263  itkSetMacro(InferiorClip, double);
264  itkGetMacro(SuperiorClip, double);
265  itkSetMacro(SuperiorClip, double);
267 
268 protected:
270  ~JosephForwardProjectionImageFilter() override = default;
271 
272  void
273  ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, ThreadIdType threadId) override;
274 
277  void
278  VerifyInputInformation() const override
279  {}
280 
281  inline OutputPixelType
282  BilinearInterpolation(const ThreadIdType threadId,
283  const double stepLengthInVoxel,
284  const InputPixelType * pxiyi,
285  const InputPixelType * pxsyi,
286  const InputPixelType * pxiys,
287  const InputPixelType * pxsys,
288  const double x,
289  const double y,
290  const int ox,
291  const int oy);
292 
293  inline OutputPixelType
294  BilinearInterpolationOnBorders(const ThreadIdType threadId,
295  const double stepLengthInVoxel,
296  const InputPixelType * pxiyi,
297  const InputPixelType * pxsyi,
298  const InputPixelType * pxiys,
299  const InputPixelType * pxsys,
300  const double x,
301  const double y,
302  const int ox,
303  const int oy,
304  const double minx,
305  const double miny,
306  const double maxx,
307  const double maxy);
308 
309 private:
310  // Functors
311  TInterpolationWeightMultiplication m_InterpolationWeightMultiplication;
312  TProjectedValueAccumulation m_ProjectedValueAccumulation;
313  TSumAlongRay m_SumAlongRay;
314  double m_InferiorClip{ 0. };
315  double m_SuperiorClip{ 1. };
316 };
317 
318 } // end namespace rtk
319 
320 #ifndef ITK_MANUAL_INSTANTIATION
321 # include "rtkJosephForwardProjectionImageFilter.hxx"
322 #endif
323 
324 #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