ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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>
30namespace rtk
31{
32namespace Functor
33{
42template <class TInput, class TCoordinateType, class TOutput = TInput>
43class ITK_TEMPLATE_EXPORT InterpolationWeightMultiplication
44{
45public:
48 bool
50 {
51 return false;
52 }
53 bool
55 {
56 return !(*this != other);
57 }
58
59 TOutput
60 operator()(const ThreadIdType itkNotUsed(threadId),
61 const double itkNotUsed(stepLengthInVoxel),
62 const TCoordinateType weight,
63 const TInput * p,
64 const ptrdiff_t i) const
65 {
66 return weight * p[i];
67 }
68};
69
77template <class TInput, class TOutput>
78class ITK_TEMPLATE_EXPORT SumAlongRay
79{
80public:
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 void
97 operator()(const ThreadIdType itkNotUsed(threadId),
98 TOutput & sumValue,
99 const TInput volumeValue,
100 const VectorType & itkNotUsed(stepInMM))
101 {
102 sumValue += static_cast<TOutput>(volumeValue);
103 }
104};
105
113template <class TInput, class TOutput>
114class ITK_TEMPLATE_EXPORT ProjectedValueAccumulation
115{
116public:
119
122 bool
124 {
125 return false;
126 }
127 bool
129 {
130 return !(*this != other);
131 }
132
133 void
134 operator()(const ThreadIdType itkNotUsed(threadId),
135 const TInput & input,
136 TOutput & output,
137 const TOutput & rayCastValue,
138 const VectorType & stepInMM,
139 const PointType & itkNotUsed(source),
140 const VectorType & itkNotUsed(sourceToPixel),
141 const PointType & itkNotUsed(nearestPoint),
142 const PointType & itkNotUsed(farthestPoint)) const
143 {
144 output = input + rayCastValue * stepInMM.GetNorm();
145 }
146};
147
148} // end namespace Functor
149
150
165
166template <class TInputImage,
167 class TOutputImage,
168 class TInterpolationWeightMultiplication = Functor::InterpolationWeightMultiplication<
169 typename TInputImage::PixelType,
171 class TProjectedValueAccumulation =
172 Functor::ProjectedValueAccumulation<typename TInputImage::PixelType, typename TOutputImage::PixelType>,
173 class TSumAlongRay = Functor::SumAlongRay<typename TInputImage::PixelType, typename TOutputImage::PixelType>>
174class ITK_TEMPLATE_EXPORT JosephForwardProjectionImageFilter
175 : public ForwardProjectionImageFilter<TInputImage, TOutputImage>
176{
177public:
178 ITK_DISALLOW_COPY_AND_MOVE(JosephForwardProjectionImageFilter);
179
185 using InputPixelType = typename TInputImage::PixelType;
186 using OutputPixelType = typename TOutputImage::PixelType;
187 using OutputImageRegionType = typename TOutputImage::RegionType;
188 using CoordinateType = double;
192
194 itkNewMacro(Self);
195
197 itkOverrideGetNameOfClassMacro(JosephForwardProjectionImageFilter);
198
200 TInterpolationWeightMultiplication &
205 const TInterpolationWeightMultiplication &
210 void
211 SetInterpolationWeightMultiplication(const TInterpolationWeightMultiplication & _arg)
212 {
214 {
216 this->Modified();
217 }
218 }
219
222 TProjectedValueAccumulation &
227 const TProjectedValueAccumulation &
232 void
233 SetProjectedValueAccumulation(const TProjectedValueAccumulation & _arg)
234 {
236 {
238 this->Modified();
239 }
240 }
241
243 TSumAlongRay &
245 {
246 return m_SumAlongRay;
247 }
248 const TSumAlongRay &
250 {
251 return m_SumAlongRay;
252 }
253 void
254 SetSumAlongRay(const TSumAlongRay & _arg)
255 {
256 if (m_SumAlongRay != _arg)
257 {
258 m_SumAlongRay = _arg;
259 this->Modified();
260 }
261 }
262
266 void
267 SetInferiorClipImage(const TClipImageType * inferiorClipImage)
268 {
269 // Process object is not const-correct so the const casting is required.
270 this->SetInput("InferiorClipImage", const_cast<TClipImageType *>(inferiorClipImage));
271 }
272 typename TClipImageType::ConstPointer
274 {
275 return static_cast<const TClipImageType *>(this->itk::ProcessObject::GetInput("InferiorClipImage"));
276 }
277
281 void
282 SetSuperiorClipImage(const TClipImageType * superiorClipImage)
283 {
284 // Process object is not const-correct so the const casting is required.
285 this->SetInput("SuperiorClipImage", const_cast<TClipImageType *>(superiorClipImage));
286 }
287 typename TClipImageType::ConstPointer
289 {
290 return static_cast<const TClipImageType *>(this->itk::ProcessObject::GetInput("SuperiorClipImage"));
291 }
292
296 itkGetMacro(InferiorClip, double);
297 itkSetMacro(InferiorClip, double);
298 itkGetMacro(SuperiorClip, double);
299 itkSetMacro(SuperiorClip, double);
300
301protected:
304
306 void
308
309 void
310 ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, ThreadIdType threadId) override;
311
314 void
315 VerifyInputInformation() const override;
316
317 inline OutputPixelType
319 double stepLengthInVoxel,
320 const InputPixelType * pxiyi,
321 const InputPixelType * pxsyi,
322 const InputPixelType * pxiys,
323 const InputPixelType * pxsys,
324 double x,
325 double y,
326 ptrdiff_t ox,
327 ptrdiff_t oy);
328
329 inline OutputPixelType
331 double stepLengthInVoxel,
332 const InputPixelType * pxiyi,
333 const InputPixelType * pxsyi,
334 const InputPixelType * pxiys,
335 const InputPixelType * pxsys,
336 double x,
337 double y,
338 ptrdiff_t ox,
339 ptrdiff_t oy,
340 double minx,
341 double miny,
342 double maxx,
343 double maxy);
344
345private:
346 // Functors
347 TInterpolationWeightMultiplication m_InterpolationWeightMultiplication;
348 TProjectedValueAccumulation m_ProjectedValueAccumulation;
349 TSumAlongRay m_SumAlongRay;
350 double m_InferiorClip{ 0. };
351 double m_SuperiorClip{ 1. };
352};
353
354} // end namespace rtk
355
356#ifndef ITK_MANUAL_INSTANTIATION
357# include "rtkJosephForwardProjectionImageFilter.hxx"
358#endif
359
360#endif
virtual void SetInput(const InputImageType *input)
Templated n-dimensional image class.
Definition itkImage.h:89
virtual void Modified() const
Traits for a pixel that define the dimension and component type.
A templated class holding a geometric point in n-Dimensional space.
Definition itkPoint.h:54
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
Implements transparent reference counting.
A templated class holding a n-Dimensional vector.
Definition itkVector.h:63
RealValueType GetNorm() const
TOutput operator()(const ThreadIdType threadId, const double stepLengthInVoxel, const TCoordinateType weight, const TInput *p, const ptrdiff_t i) const
bool operator!=(const InterpolationWeightMultiplication &) const
bool operator==(const InterpolationWeightMultiplication &other) const
bool operator!=(const ProjectedValueAccumulation &) const
void operator()(const ThreadIdType threadId, const TInput &input, TOutput &output, const TOutput &rayCastValue, const VectorType &stepInMM, const PointType &source, const VectorType &sourceToPixel, const PointType &nearestPoint, const PointType &farthestPoint) const
bool operator==(const ProjectedValueAccumulation &other) const
void operator()(const ThreadIdType threadId, TOutput &sumValue, const TInput volumeValue, const VectorType &stepInMM)
bool operator==(const SumAlongRay &other) const
bool operator!=(const SumAlongRay &) const
OutputPixelType BilinearInterpolationOnBorders(ThreadIdType threadId, double stepLengthInVoxel, const InputPixelType *pxiyi, const InputPixelType *pxsyi, const InputPixelType *pxiys, const InputPixelType *pxsys, double x, double y, ptrdiff_t ox, ptrdiff_t oy, double minx, double miny, double maxx, double maxy)
void SetInferiorClipImage(const TClipImageType *inferiorClipImage)
OutputPixelType BilinearInterpolation(ThreadIdType threadId, double stepLengthInVoxel, const InputPixelType *pxiyi, const InputPixelType *pxsyi, const InputPixelType *pxiys, const InputPixelType *pxsys, double x, double y, ptrdiff_t ox, ptrdiff_t oy)
void SetProjectedValueAccumulation(const TProjectedValueAccumulation &_arg)
void SetSuperiorClipImage(const TClipImageType *superiorClipImage)
void SetInterpolationWeightMultiplication(const TInterpolationWeightMultiplication &_arg)
const TInterpolationWeightMultiplication & GetInterpolationWeightMultiplication() const
const TProjectedValueAccumulation & GetProjectedValueAccumulation() const
void VerifyInputInformation() const override
~JosephForwardProjectionImageFilter() override=default
void ThreadedGenerateData(const OutputImageRegionType &outputRegionForThread, ThreadIdType threadId) override
TInterpolationWeightMultiplication & GetInterpolationWeightMultiplication()
unsigned int ThreadIdType
Definition itkIntTypes.h:98
#define itkSetMacro(name, type)