ITK  6.0.0
Insight Toolkit
itkBSplineScatteredDataPointSetToImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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 #ifndef itkBSplineScatteredDataPointSetToImageFilter_h
19 #define itkBSplineScatteredDataPointSetToImageFilter_h
20 
22 
25 #include "itkVectorContainer.h"
26 
27 #include "vnl/vnl_matrix.h"
28 
29 namespace itk
30 {
131 template <typename TInputPointSet, typename TOutputImage>
133  : public PointSetToImageFilter<TInputPointSet, TOutputImage>
134 {
135 public:
136  ITK_DISALLOW_COPY_AND_MOVE(BSplineScatteredDataPointSetToImageFilter);
137 
143 
145  itkNewMacro(Self);
146 
148  itkOverrideGetNameOfClassMacro(BSplineScatteredDataPointSetToImageFilter);
149 
151  static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
152 
153  using ImageType = TOutputImage;
154  using PointSetType = TInputPointSet;
155 
157  using PixelType = typename ImageType::PixelType;
160  using SizeType = typename ImageType::SizeType;
161  using IndexType = typename ImageType::IndexType;
162 
166  using PointDataType = typename PointSetType::PixelType;
167  using PointDataContainerType = typename PointSetType::PointDataContainer;
169 
171  using RealType = float;
173 
181 
188 
189 
194  void
195  SetSplineOrder(unsigned int);
196 
200  void
201  SetSplineOrder(const ArrayType &);
202 
206  itkGetConstReferenceMacro(SplineOrder, ArrayType);
207 
212  itkSetMacro(NumberOfControlPoints, ArrayType);
213  itkGetConstReferenceMacro(NumberOfControlPoints, ArrayType);
220  itkGetConstReferenceMacro(CurrentNumberOfControlPoints, ArrayType);
221 
226  void
227  SetNumberOfLevels(unsigned int);
228 
233  void
234  SetNumberOfLevels(const ArrayType &);
235 
240  itkGetConstReferenceMacro(NumberOfLevels, ArrayType);
241 
248  itkSetMacro(BSplineEpsilon, RealType);
249  itkGetConstMacro(BSplineEpsilon, RealType);
268  itkSetMacro(CloseDimension, ArrayType);
269  itkGetConstReferenceMacro(CloseDimension, ArrayType);
274  void
275  SetPointWeights(WeightsContainerType * weights);
276 
280  itkSetMacro(GenerateOutputImage, bool);
281  itkGetConstReferenceMacro(GenerateOutputImage, bool);
282  itkBooleanMacro(GenerateOutputImage);
288  {
289  return static_cast<PointDataImageType *>(this->ProcessObject::GetOutput(1));
290  }
291 
292 protected:
294  ~BSplineScatteredDataPointSetToImageFilter() override = default;
295 
296  void
297  PrintSelf(std::ostream & os, Indent indent) const override;
298 
299  void
300  ThreadedGenerateData(const RegionType &, ThreadIdType) override;
301 
302  void
304  {
305  itkExceptionMacro("This class requires threadId so it must use classic multi-threading model");
306  }
307 
308  void
309  BeforeThreadedGenerateData() override;
310 
311  void
312  AfterThreadedGenerateData() override;
313 
314  unsigned int
315  SplitRequestedRegion(unsigned int, unsigned int, RegionType &) override;
316 
317  void
318  GenerateData() override;
319 
320 private:
323  void
324  RefineControlPointLattice();
325 
328  void
329  GenerateOutputImage();
330 
332  void
333  ThreadedGenerateDataForFitting(const RegionType &, ThreadIdType);
334 
336  void
337  ThreadedGenerateDataForReconstruction(const RegionType &, ThreadIdType);
338 
340  void
341  ThreadedGenerateDataForUpdatingResidualValues(const RegionType &, ThreadIdType);
342 
345  void
346  CollapsePhiLattice(PointDataImageType *, PointDataImageType *, const RealType, const unsigned int);
347 
350  void
351  SetPhiLatticeParametricDomainParameters();
352 
355  IndexType
356  NumberToIndex(const unsigned int, const SizeType);
357 
358  bool m_DoMultilevel{ false };
359  bool m_GenerateOutputImage{ true };
360  bool m_UsePointWeights{ false };
361  unsigned int m_MaximumNumberOfLevels{ 1 };
362  unsigned int m_CurrentLevel{ 0 };
363  ArrayType m_NumberOfControlPoints{};
364  ArrayType m_CurrentNumberOfControlPoints{};
365  ArrayType m_CloseDimension{};
366  ArrayType m_SplineOrder{};
367  ArrayType m_NumberOfLevels{};
368 
369  typename WeightsContainerType::Pointer m_PointWeights{};
370 
371  typename PointDataImageType::Pointer m_PhiLattice{};
372  typename PointDataImageType::Pointer m_PsiLattice{};
373 
374  vnl_matrix<RealType> m_RefinedLatticeCoefficients[ImageDimension]{};
375 
376  PointDataContainerPointer m_ResidualPointSetValues{};
377 
378  typename KernelType::Pointer m_Kernel[ImageDimension]{};
379 
380  typename KernelOrder0Type::Pointer m_KernelOrder0{};
381  typename KernelOrder1Type::Pointer m_KernelOrder1{};
382  typename KernelOrder2Type::Pointer m_KernelOrder2{};
383  typename KernelOrder3Type::Pointer m_KernelOrder3{};
384 
385  std::vector<RealImagePointer> m_OmegaLatticePerThread{};
386  std::vector<PointDataImagePointer> m_DeltaLatticePerThread{};
387 
388  RealType m_BSplineEpsilon{ static_cast<RealType>(1e-3) };
389  bool m_IsFittingComplete{ false };
390  bool m_DoUpdateResidualValues{ false };
391 };
392 } // end namespace itk
393 
394 #ifndef ITK_MANUAL_INSTANTIATION
395 # include "itkBSplineScatteredDataPointSetToImageFilter.hxx"
396 #endif
397 
398 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::PointSetToImageFilter::SizeType
typename TOutputImage::SizeType SizeType
Definition: itkPointSetToImageFilter.h:45
itk::BSplineKernelFunction
BSpline kernel used for density estimation and nonparametric regression.
Definition: itkBSplineKernelFunction.h:43
itk::BSplineScatteredDataPointSetToImageFilter::PointDataContainerPointer
typename PointDataContainerType::Pointer PointDataContainerPointer
Definition: itkBSplineScatteredDataPointSetToImageFilter.h:168
itk::PointSetToImageFilter::PointType
typename TOutputImage::PointType PointType
Definition: itkPointSetToImageFilter.h:71
itk::BSplineScatteredDataPointSetToImageFilter::ImageType
TOutputImage ImageType
Definition: itkBSplineScatteredDataPointSetToImageFilter.h:153
itk::PointSetToImageFilter
Base class for filters that take a PointSet as input and produce an image as output....
Definition: itkPointSetToImageFilter.h:35
itk::detail::VectorContainer
Define a front-end to the STL "vector" container that conforms to the IndexedContainerInterface.
Definition: itkVectorContainer.h:51
itk::BSplineScatteredDataPointSetToImageFilter::GetPhiLattice
PointDataImagePointer GetPhiLattice()
Definition: itkBSplineScatteredDataPointSetToImageFilter.h:287
itk::BSplineScatteredDataPointSetToImageFilter::PointDataType
typename PointSetType::PixelType PointDataType
Definition: itkBSplineScatteredDataPointSetToImageFilter.h:166
itk::BSplineScatteredDataPointSetToImageFilter::PointSetType
TInputPointSet PointSetType
Definition: itkBSplineScatteredDataPointSetToImageFilter.h:154
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::BSplineScatteredDataPointSetToImageFilter
Image filter which provides a B-spline output approximation.
Definition: itkBSplineScatteredDataPointSetToImageFilter.h:132
itk::ProcessObject::GetOutput
DataObject * GetOutput(const DataObjectIdentifierType &key)
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::BSplineScatteredDataPointSetToImageFilter::RealImagePointer
typename RealImageType::Pointer RealImagePointer
Definition: itkBSplineScatteredDataPointSetToImageFilter.h:177
itk::ThreadIdType
unsigned int ThreadIdType
Definition: itkIntTypes.h:102
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::BSplineScatteredDataPointSetToImageFilter::PointDataContainerType
typename PointSetType::PointDataContainer PointDataContainerType
Definition: itkBSplineScatteredDataPointSetToImageFilter.h:167
itk::BSplineScatteredDataPointSetToImageFilter::DynamicThreadedGenerateData
void DynamicThreadedGenerateData(const RegionType &) override
Definition: itkBSplineScatteredDataPointSetToImageFilter.h:303
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::BSplineScatteredDataPointSetToImageFilter::RealType
float RealType
Definition: itkBSplineScatteredDataPointSetToImageFilter.h:171
itk::FixedArray< unsigned int, Self::ImageDimension >
itk::BSplineScatteredDataPointSetToImageFilter::PointDataImagePointer
typename PointDataImageType::Pointer PointDataImagePointer
Definition: itkBSplineScatteredDataPointSetToImageFilter.h:178
itk::BSplineScatteredDataPointSetToImageFilter::PointSetPointer
typename PointSetType::Pointer PointSetPointer
Definition: itkBSplineScatteredDataPointSetToImageFilter.h:165
itk::BSplineScatteredDataPointSetToImageFilter::IndexType
typename ImageType::IndexType IndexType
Definition: itkBSplineScatteredDataPointSetToImageFilter.h:161
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itkVectorContainer.h
itkCoxDeBoorBSplineKernelFunction.h
itkBSplineKernelFunction.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:139
itk::Math::e
static constexpr double e
Definition: itkMath.h:56
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
itk::BSplineScatteredDataPointSetToImageFilter::PixelType
typename ImageType::PixelType PixelType
Definition: itkBSplineScatteredDataPointSetToImageFilter.h:157
itk::CoxDeBoorBSplineKernelFunction
BSpline kernel used for density estimation and nonparametric regression.
Definition: itkCoxDeBoorBSplineKernelFunction.h:57
itkPointSetToImageFilter.h
itk::BSplineScatteredDataPointSetToImageFilter::RegionType
typename ImageType::RegionType RegionType
Definition: itkBSplineScatteredDataPointSetToImageFilter.h:158