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 TCoordRepType, 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 TCoordRepType 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 TCoordRepType, class TOutput = TCoordRepType>
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 TCoordRepType 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 CoordRepType = double;
181 
183  itkNewMacro(Self);
184 
186 #ifdef itkOverrideGetNameOfClassMacro
187  itkOverrideGetNameOfClassMacro(JosephBackProjectionImageFilter);
188 #else
190 #endif
191 
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 
216  TSplatWeightMultiplication &
218  {
219  return m_SplatWeightMultiplication;
220  }
221  const TSplatWeightMultiplication &
223  {
224  return m_SplatWeightMultiplication;
225  }
226  void
227  SetSplatWeightMultiplication(const TSplatWeightMultiplication & _arg)
228  {
229  if (m_SplatWeightMultiplication != _arg)
230  {
231  m_SplatWeightMultiplication = _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  ~JosephBackProjectionImageFilter() override = default;
271 
272  void
273  GenerateData() override;
274 
277  void
278  VerifyInputInformation() const override
279  {}
280 
281  inline void
282  BilinearSplat(const InputPixelType & rayValue,
283  const double stepLengthInVoxel,
284  const double voxelSize,
285  OutputPixelType * pxiyi,
286  OutputPixelType * pxsyi,
287  OutputPixelType * pxiys,
288  OutputPixelType * pxsys,
289  const double x,
290  const double y,
291  const int ox,
292  const int oy);
293 
294  inline void
295  BilinearSplatOnBorders(const InputPixelType & rayValue,
296  const double stepLengthInVoxel,
297  const double voxelSize,
298  OutputPixelType * pxiyi,
299  OutputPixelType * pxsyi,
300  OutputPixelType * pxiys,
301  OutputPixelType * pxsys,
302  const double x,
303  const double y,
304  const int ox,
305  const int oy,
306  const CoordRepType minx,
307  const CoordRepType miny,
308  const CoordRepType maxx,
309  const CoordRepType maxy);
310 
311  inline OutputPixelType
312  BilinearInterpolation(const double stepLengthInVoxel,
313  const InputPixelType * pxiyi,
314  const InputPixelType * pxsyi,
315  const InputPixelType * pxiys,
316  const InputPixelType * pxsys,
317  const double x,
318  const double y,
319  const int ox,
320  const int oy);
321 
322  inline OutputPixelType
323  BilinearInterpolationOnBorders(const double stepLengthInVoxel,
324  const InputPixelType * pxiyi,
325  const InputPixelType * pxsyi,
326  const InputPixelType * pxiys,
327  const InputPixelType * pxsys,
328  const double x,
329  const double y,
330  const int ox,
331  const int oy,
332  const double minx,
333  const double miny,
334  const double maxx,
335  const double maxy);
336 
338  TSplatWeightMultiplication m_SplatWeightMultiplication;
339  TInterpolationWeightMultiplication m_InterpolationWeightMultiplication;
340  TSumAlongRay m_SumAlongRay;
341  double m_InferiorClip{ 0. };
342  double m_SuperiorClip{ 1. };
343 };
344 
345 } // end namespace rtk
346 
347 #ifndef ITK_MANUAL_INSTANTIATION
348 # include "rtkJosephBackProjectionImageFilter.hxx"
349 #endif
350 
351 #endif
bool operator!=(const ValueAlongRay &) const
bool operator!=(const InterpolationWeightMultiplicationBackProjection &) const
void SetInterpolationWeightMultiplication(const TInterpolationWeightMultiplication &_arg)
TInterpolationWeightMultiplication & GetInterpolationWeightMultiplication()
typename TInputImage::PixelType InputPixelType
bool operator==(const InterpolationWeightMultiplicationBackProjection &other) const
void SetSplatWeightMultiplication(const TSplatWeightMultiplication &_arg)
bool operator!=(const SplatWeightMultiplication &) const
typename TPixelType::ValueType ValueType
Projection geometry for a source and a 2-D flat panel.
#define itkSetMacro(name, type)
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.
bool operator==(const SplatWeightMultiplication &other) const
const TSplatWeightMultiplication & GetSplatWeightMultiplication() const
TSplatWeightMultiplication & GetSplatWeightMultiplication()
TInterpolationWeightMultiplication m_InterpolationWeightMultiplication
const TInterpolationWeightMultiplication & GetInterpolationWeightMultiplication() const
TOutput operator()(const double, const TCoordRepType, const TInput *, const int) const
void operator()(const TInput &rayValue, TOutput &output, const double stepLengthInVoxel, const double voxelSize, const TCoordRepType weight) const