ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
rtkJosephForwardAttenuatedProjectionImageFilter.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 rtkJosephForwardAttenuatedProjectionImageFilter_h
20#define rtkJosephForwardAttenuatedProjectionImageFilter_h
21
22#include "rtkConfiguration.h"
25#include "rtkMacro.h"
26#include <cmath>
27#include <itkPixelTraits.h>
28#include <vector>
29
30namespace rtk
31{
32namespace Functor
33{
42template <class TInput, class TCoordinateType, class TOutput = TInput>
44{
45public:
47 {
48 for (std::size_t i = 0; i < itk::ITK_MAX_THREADS; i++)
49 {
50 m_AttenuationRay[i] = 0;
51 m_AttenuationPixel[i] = 0;
52 m_Ex1[i] = 1;
53 }
54 }
55
57 bool
59 {
60 return false;
61 }
62
63 bool
65 {
66 return !(*this != other);
67 }
68
69 TOutput
70 operator()(const ThreadIdType threadId,
71 const double stepLengthInVoxel,
72 const TCoordinateType weight,
73 const TInput * p,
74 const ptrdiff_t i)
75 {
76 const double w = weight * stepLengthInVoxel;
77
80 return weight * p[i];
81 }
82
83 void
88 TOutput *
90 {
91 return m_AttenuationRay;
92 }
93 TOutput *
98 TOutput *
100 {
101 return m_Ex1;
102 }
103
104private:
109};
110
118template <class TInput, class TOutput>
119class ITK_TEMPLATE_EXPORT ComputeAttenuationCorrection
120{
121public:
123
126 bool
128 {
129 return false;
130 }
131
132 bool
134 {
135 return !(*this != other);
136 }
137
138 void
139 operator()(const ThreadIdType threadId, TOutput & sumValue, const TInput volumeValue, const VectorType & stepInMM)
140 {
141 TInput ex2 = exp(-m_AttenuationRay[threadId] * stepInMM.GetNorm());
142 TInput wf;
143
144 if (m_AttenuationPixel[threadId] > 0)
145 {
146 wf = (m_Ex1[threadId] - ex2) / m_AttenuationPixel[threadId];
147 }
148 else
149 {
150 wf = m_Ex1[threadId] * stepInMM.GetNorm();
151 }
152
153 m_Ex1[threadId] = ex2;
154 m_AttenuationPixel[threadId] = 0;
155 sumValue += wf * volumeValue;
156 }
157
158 void
159 SetAttenuationRayVector(TInput * attenuationRayVector)
160 {
161 m_AttenuationRay = attenuationRayVector;
162 }
163 void
164 SetAttenuationPixelVector(TInput * attenuationPixelVector)
165 {
166 m_AttenuationPixel = attenuationPixelVector;
167 }
168 void
169 SetEx1(TInput * ex1)
170 {
171 m_Ex1 = ex1;
172 }
173
174private:
177 TInput * m_Ex1;
178};
179
187template <class TInput, class TOutput>
189{
190public:
193
196 bool
198 {
199 return false;
200 }
201
202 bool
204 {
205 return !(*this != other);
206 }
207
208 void
209 operator()(const ThreadIdType threadId,
210 const TInput & input,
211 TOutput & output,
212 const TOutput & rayCastValue,
213 const VectorType & /*stepInMM*/,
214 const PointType & itkNotUsed(source),
215 const VectorType & itkNotUsed(sourceToPixel),
216 const PointType & itkNotUsed(nearestPoint),
217 const PointType & itkNotUsed(farthestPoint))
218 {
219 output = input + rayCastValue;
220 m_Attenuation[threadId] = 0;
221 m_Ex1[threadId] = 1;
222 }
223
224 void
225 SetAttenuationVector(TInput * attenuationVector)
226 {
227 m_Attenuation = attenuationVector;
228 }
229 void
230 SetEx1(TInput * ex1)
231 {
232 m_Ex1 = ex1;
233 }
234
235private:
237 TInput * m_Ex1;
238};
239} // end namespace Functor
240
255
256template <
257 class TInputImage,
258 class TOutputImage,
259 class TInterpolationWeightMultiplication = Functor::InterpolationWeightMultiplicationAttenuated<
260 typename TInputImage::PixelType,
262 class TProjectedValueAccumulation =
264 class TSumAlongRay =
267 : public JosephForwardProjectionImageFilter<TInputImage,
268 TOutputImage,
269 TInterpolationWeightMultiplication,
270 TProjectedValueAccumulation,
271 TSumAlongRay>
272{
273public:
274 ITK_DISALLOW_COPY_AND_MOVE(JosephForwardAttenuatedProjectionImageFilter);
275
279 TOutputImage,
280 TInterpolationWeightMultiplication,
281 TProjectedValueAccumulation,
282 TSumAlongRay>;
285 using InputPixelType = typename TInputImage::PixelType;
286 using OutputPixelType = typename TOutputImage::PixelType;
287 using OutputImageRegionType = typename TOutputImage::RegionType;
288 using CoordinateType = double;
290
292 static constexpr unsigned int InputImageDimension = TInputImage::ImageDimension;
293
295 itkNewMacro(Self);
296
298 itkOverrideGetNameOfClassMacro(JosephForwardAttenuatedProjectionImageFilter);
299
300protected:
303
305 void
307
308 void
310
313 void
314 VerifyInputInformation() const override;
315};
316} // end namespace rtk
317
318#ifndef ITK_MANUAL_INSTANTIATION
319# include "rtkJosephForwardAttenuatedProjectionImageFilter.hxx"
320#endif
321
322#endif
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
Implements transparent reference counting.
A templated class holding a n-Dimensional vector.
Definition itkVector.h:63
RealValueType GetNorm() const
Function to compute the attenuation correction on the projection.
void operator()(const ThreadIdType threadId, TOutput &sumValue, const TInput volumeValue, const VectorType &stepInMM)
bool operator==(const ComputeAttenuationCorrection &other) const
Function to multiply the interpolation weights with the projected volume values and attenuation map.
bool operator!=(const InterpolationWeightMultiplicationAttenuated &) const
bool operator==(const InterpolationWeightMultiplicationAttenuated &other) const
TOutput operator()(const ThreadIdType threadId, const double stepLengthInVoxel, const TCoordinateType weight, const TInput *p, const ptrdiff_t i)
bool operator!=(const ProjectedValueAccumulationAttenuated &) const
void operator()(const ThreadIdType threadId, const TInput &input, TOutput &output, const TOutput &rayCastValue, const VectorType &, const PointType &source, const VectorType &sourceToPixel, const PointType &nearestPoint, const PointType &farthestPoint)
bool operator==(const ProjectedValueAccumulationAttenuated &other) const
itk::Vector< CoordinateType, TInputImage::ImageDimension > VectorType
~JosephForwardAttenuatedProjectionImageFilter() override=default
JosephForwardProjectionImageFilter< TInputImage, TOutputImage, TInterpolationWeightMultiplication, TProjectedValueAccumulation, TSumAlongRay > Superclass
constexpr vcl_size_t ITK_MAX_THREADS
unsigned int ThreadIdType
Definition itkIntTypes.h:98