RTK  2.5.0
Reconstruction Toolkit
rtkSpectralForwardModelImageFilter.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 rtkSpectralForwardModelImageFilter_h
20 #define rtkSpectralForwardModelImageFilter_h
21 
24 
25 #include <itkInPlaceImageFilter.h>
26 
27 namespace rtk
28 {
42 template <typename DecomposedProjectionsType,
43  typename MeasuredProjectionsType,
44  typename IncidentSpectrumImageType = itk::VectorImage<float, 2>,
45  typename DetectorResponseImageType = itk::Image<float, 2>,
46  typename MaterialAttenuationsImageType = itk::Image<float, 2>>
47 class ITK_TEMPLATE_EXPORT SpectralForwardModelImageFilter
48  : public itk::InPlaceImageFilter<MeasuredProjectionsType, MeasuredProjectionsType>
49 {
50 public:
51  ITK_DISALLOW_COPY_AND_MOVE(SpectralForwardModelImageFilter);
52 
58 
60  using InputImageType = MeasuredProjectionsType;
61  using OutputImageType = MeasuredProjectionsType;
62 
65  using DetectorResponseType = vnl_matrix<double>;
66  using MaterialAttenuationsType = vnl_matrix<double>;
67 
69  itkNewMacro(Self);
70 
72 #ifdef itkOverrideGetNameOfClassMacro
73  itkOverrideGetNameOfClassMacro(SpectralForwardModelImageFilter);
74 #else
76 #endif
77 
78 
80  void
81  SetInputIncidentSpectrum(const IncidentSpectrumImageType * IncidentSpectrum);
82  void
83  SetInputSecondIncidentSpectrum(const IncidentSpectrumImageType * SecondIncidentSpectrum);
84  typename IncidentSpectrumImageType::ConstPointer
85  GetInputIncidentSpectrum();
86  typename IncidentSpectrumImageType::ConstPointer
87  GetInputSecondIncidentSpectrum();
89 
91  void
92  SetInputDecomposedProjections(const DecomposedProjectionsType * DecomposedProjections);
93  typename DecomposedProjectionsType::ConstPointer
94  GetInputDecomposedProjections();
96 
98  void
99  SetInputMeasuredProjections(const MeasuredProjectionsType * SpectralProjections);
100  typename MeasuredProjectionsType::ConstPointer
101  GetInputMeasuredProjections();
103 
105  void
106  SetDetectorResponse(const DetectorResponseImageType * DetectorResponse);
107  typename DetectorResponseImageType::ConstPointer
108  GetDetectorResponse();
110 
112  void
113  SetMaterialAttenuations(const MaterialAttenuationsImageType * MaterialAttenuations);
114  typename MaterialAttenuationsImageType::ConstPointer
115  GetMaterialAttenuations();
117 
118  itkSetMacro(Thresholds, ThresholdsType);
119  itkGetMacro(Thresholds, ThresholdsType);
120 
121  itkSetMacro(NumberOfSpectralBins, unsigned int);
122  itkGetMacro(NumberOfSpectralBins, unsigned int);
123 
124  itkSetMacro(NumberOfMaterials, unsigned int);
125  itkGetMacro(NumberOfMaterials, unsigned int);
126 
127  itkSetMacro(NumberOfEnergies, unsigned int);
128  itkGetMacro(NumberOfEnergies, unsigned int);
129 
130  itkSetMacro(IsSpectralCT, bool);
131  itkGetMacro(IsSpectralCT, bool);
132 
133  itkSetMacro(ComputeVariances, bool);
134  itkGetMacro(ComputeVariances, bool);
135 
136 protected:
138  ~SpectralForwardModelImageFilter() override = default;
139 
142  using Superclass::MakeOutput;
144  MakeOutput(DataObjectPointerArraySizeType idx) override;
145 
146  void
147  GenerateOutputInformation() override;
148 
149  void
150  GenerateInputRequestedRegion() override;
151 
152  void
153  BeforeThreadedGenerateData() override;
154  void
155  DynamicThreadedGenerateData(const typename OutputImageType::RegionType & outputRegionForThread) override;
156 
159  void
160  VerifyInputInformation() const override
161  {}
162 
165 
168  unsigned int m_NumberOfEnergies;
169 
171  unsigned int m_NumberOfIterations;
172  unsigned int m_NumberOfMaterials;
174  bool m_IsSpectralCT; // If not, it is dual energy CT
175  bool m_ComputeVariances; // Only implemented for dual energy CT
176 
177 }; // end of class
178 
179 // Function to bin a detector response matrix according to given energy thresholds
180 template <typename OutputElementType, typename DetectorResponseImageType, typename ThresholdsType>
181 vnl_matrix<OutputElementType>
182 SpectralBinDetectorResponse(const DetectorResponseImageType * drm,
183  const ThresholdsType & thresholds,
184  const unsigned int numberOfEnergies);
185 
186 } // end namespace rtk
187 
188 
189 #ifndef ITK_MANUAL_INSTANTIATION
190 # include "rtkSpectralForwardModelImageFilter.hxx"
191 #endif
192 
193 #endif
Superclass::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
Forward model for the decomposition of spectral projection images into material projections.
TInputImage InputImageType
#define itkSetMacro(name, type)
TOutputImage OutputImageType
vnl_matrix< OutputElementType > SpectralBinDetectorResponse(const DetectorResponseImageType *drm, const ThresholdsType &thresholds, const unsigned int numberOfEnergies)