RTK  2.6.0
Reconstruction Toolkit
rtkJosephBackProjectionImageFilter.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 rtkJosephBackProjectionImageFilter_h
20 #define rtkJosephBackProjectionImageFilter_h
21 
22 #include "rtkConfiguration.h"
25 
26 #include <itkVectorImage.h>
27 
28 namespace rtk
29 {
30 namespace Functor
31 {
40 template <class TInput, class TCoordinateType, class TOutput = TInput>
42 {
43 public:
46  bool
48  {
49  return false;
50  }
51  bool
53  {
54  return !(*this != other);
55  }
56 
57  inline TOutput
58  operator()(const double itkNotUsed(stepLengthInVoxel),
59  const TCoordinateType itkNotUsed(weight),
60  const TInput * itkNotUsed(p),
61  const int itkNotUsed(i)) const
62  {
63  return {};
64  }
65 };
66 
74 template <class TInput, class TOutput>
75 class ITK_TEMPLATE_EXPORT ValueAlongRay
76 {
77 public:
79 
80  ValueAlongRay() = default;
81  ~ValueAlongRay() = default;
82  bool
83  operator!=(const ValueAlongRay &) const
84  {
85  return false;
86  }
87  bool
88  operator==(const ValueAlongRay & other) const
89  {
90  return !(*this != other);
91  }
92 
93  inline const TOutput &
94  operator()(const TInput & rayValue,
95  const TInput itkNotUsed(attenuationRay),
96  const VectorType & itkNotUsed(stepInMM),
97  bool itkNotUsed(isEndRay)) const
98  {
99  return rayValue;
100  }
101 };
110 template <class TInput, class TCoordinateType, class TOutput = TCoordinateType>
111 class ITK_TEMPLATE_EXPORT SplatWeightMultiplication
112 {
113 public:
114  SplatWeightMultiplication() = default;
115  ~SplatWeightMultiplication() = default;
116  bool
118  {
119  return false;
120  }
121  bool
123  {
124  return !(*this != other);
125  }
126 
127  inline void
128  operator()(const TInput & rayValue,
129  TOutput & output,
130  const double stepLengthInVoxel,
131  const double voxelSize,
132  const TCoordinateType weight) const
133  {
134  output += rayValue * weight * voxelSize * stepLengthInVoxel;
135  }
136 };
137 
138 } // end namespace Functor
139 
140 
155 template <
156  class TInputImage,
157  class TOutputImage,
158  class TInterpolationWeightMultiplication = Functor::InterpolationWeightMultiplicationBackProjection<
159  typename TInputImage::PixelType,
161  class TSplatWeightMultiplication =
162  Functor::SplatWeightMultiplication<typename TInputImage::PixelType, double, typename TOutputImage::PixelType>,
163  class TSumAlongRay = Functor::ValueAlongRay<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
164 class ITK_TEMPLATE_EXPORT JosephBackProjectionImageFilter : public BackProjectionImageFilter<TInputImage, TOutputImage>
165 {
166 public:
167  ITK_DISALLOW_COPY_AND_MOVE(JosephBackProjectionImageFilter);
168 
174  using InputPixelType = typename TInputImage::PixelType;
175  using OutputPixelType = typename TOutputImage::PixelType;
176  using OutputImageRegionType = typename TOutputImage::RegionType;
177  using CoordinateType = double;
181 
183  itkNewMacro(Self);
184 
186  itkOverrideGetNameOfClassMacro(JosephBackProjectionImageFilter);
187 
189  TInterpolationWeightMultiplication &
191  {
192  return m_InterpolationWeightMultiplication;
193  }
194  const TInterpolationWeightMultiplication &
196  {
197  return m_InterpolationWeightMultiplication;
198  }
199  void
200  SetInterpolationWeightMultiplication(const TInterpolationWeightMultiplication & _arg)
201  {
202  if (m_InterpolationWeightMultiplication != _arg)
203  {
204  m_InterpolationWeightMultiplication = _arg;
205  this->Modified();
206  }
207  }
209 
211  TSplatWeightMultiplication &
213  {
214  return m_SplatWeightMultiplication;
215  }
216  const TSplatWeightMultiplication &
218  {
219  return m_SplatWeightMultiplication;
220  }
221  void
222  SetSplatWeightMultiplication(const TSplatWeightMultiplication & _arg)
223  {
224  if (m_SplatWeightMultiplication != _arg)
225  {
226  m_SplatWeightMultiplication = _arg;
227  this->Modified();
228  }
229  }
231 
233  TSumAlongRay &
235  {
236  return m_SumAlongRay;
237  }
238  const TSumAlongRay &
240  {
241  return m_SumAlongRay;
242  }
243  void
244  SetSumAlongRay(const TSumAlongRay & _arg)
245  {
246  if (m_SumAlongRay != _arg)
247  {
248  m_SumAlongRay = _arg;
249  this->Modified();
250  }
251  }
253 
257  itkGetMacro(InferiorClip, double);
258  itkSetMacro(InferiorClip, double);
259  itkGetMacro(SuperiorClip, double);
260  itkSetMacro(SuperiorClip, double);
262 
263 protected:
265  ~JosephBackProjectionImageFilter() override = default;
266 
267  void
268  GenerateData() override;
269 
272  void
273  VerifyInputInformation() const override
274  {}
275 
276  inline void
277  BilinearSplat(const InputPixelType & rayValue,
278  const double stepLengthInVoxel,
279  const double voxelSize,
280  OutputPixelType * pxiyi,
281  OutputPixelType * pxsyi,
282  OutputPixelType * pxiys,
283  OutputPixelType * pxsys,
284  const double x,
285  const double y,
286  const int ox,
287  const int oy);
288 
289  inline void
290  BilinearSplatOnBorders(const InputPixelType & rayValue,
291  const double stepLengthInVoxel,
292  const double voxelSize,
293  OutputPixelType * pxiyi,
294  OutputPixelType * pxsyi,
295  OutputPixelType * pxiys,
296  OutputPixelType * pxsys,
297  const double x,
298  const double y,
299  const int ox,
300  const int oy,
301  const CoordinateType minx,
302  const CoordinateType miny,
303  const CoordinateType maxx,
304  const CoordinateType maxy);
305 
306  inline OutputPixelType
307  BilinearInterpolation(const double stepLengthInVoxel,
308  const InputPixelType * pxiyi,
309  const InputPixelType * pxsyi,
310  const InputPixelType * pxiys,
311  const InputPixelType * pxsys,
312  const double x,
313  const double y,
314  const int ox,
315  const int oy);
316 
317  inline OutputPixelType
318  BilinearInterpolationOnBorders(const double stepLengthInVoxel,
319  const InputPixelType * pxiyi,
320  const InputPixelType * pxsyi,
321  const InputPixelType * pxiys,
322  const InputPixelType * pxsys,
323  const double x,
324  const double y,
325  const int ox,
326  const int oy,
327  const double minx,
328  const double miny,
329  const double maxx,
330  const double maxy);
331 
333  TSplatWeightMultiplication m_SplatWeightMultiplication;
334  TInterpolationWeightMultiplication m_InterpolationWeightMultiplication;
335  TSumAlongRay m_SumAlongRay;
336  double m_InferiorClip{ 0. };
337  double m_SuperiorClip{ 1. };
338 };
339 
340 } // end namespace rtk
341 
342 #ifndef ITK_MANUAL_INSTANTIATION
343 # include "rtkJosephBackProjectionImageFilter.hxx"
344 #endif
345 
346 #endif
bool operator!=(const ValueAlongRay &) const
void SetInterpolationWeightMultiplication(const TInterpolationWeightMultiplication &_arg)
TInterpolationWeightMultiplication & GetInterpolationWeightMultiplication()
bool operator==(const InterpolationWeightMultiplicationBackProjection &other) const
bool operator!=(const InterpolationWeightMultiplicationBackProjection &) const
void operator()(const TInput &rayValue, TOutput &output, const double stepLengthInVoxel, const double voxelSize, const TCoordinateType weight) const
typename TInputImage::PixelType InputPixelType
void SetSplatWeightMultiplication(const TSplatWeightMultiplication &_arg)
TOutput operator()(const double, const TCoordinateType, const TInput *, const int) const
typename TPixelType::ValueType ValueType
Projection geometry for a source and a 2-D flat panel.
#define itkSetMacro(name, type)
bool operator!=(const SplatWeightMultiplication &) const
Function to multiply the interpolation weights with the projected volume values.
typename OutputImageType::RegionType OutputImageRegionType
bool operator==(const ValueAlongRay &other) const
const TOutput & operator()(const TInput &rayValue, const TInput, const VectorType &, bool) const
Function to multiply the interpolation weights with the projection values.
const TSplatWeightMultiplication & GetSplatWeightMultiplication() const
bool operator==(const SplatWeightMultiplication &other) const
TSplatWeightMultiplication & GetSplatWeightMultiplication()
TInterpolationWeightMultiplication m_InterpolationWeightMultiplication
const TInterpolationWeightMultiplication & GetInterpolationWeightMultiplication() const