ITK  5.4.0
Insight Toolkit
itkBSplineInterpolationWeightFunction.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 itkBSplineInterpolationWeightFunction_h
19 #define itkBSplineInterpolationWeightFunction_h
20 
21 #include "itkFunctionBase.h"
22 #include "itkContinuousIndex.h"
23 #include "itkArray.h"
24 #include "itkArray2D.h"
25 #include "itkIndexRange.h"
26 #include "itkMath.h"
27 
28 namespace itk
29 {
47 template <typename TCoordRep = float, unsigned int VSpaceDimension = 2, unsigned int VSplineOrder = 3>
48 class ITK_TEMPLATE_EXPORT BSplineInterpolationWeightFunction
49  : public FunctionBase<ContinuousIndex<TCoordRep, VSpaceDimension>,
50  FixedArray<double, Math::UnsignedPower(VSplineOrder + 1, VSpaceDimension)>>
51 {
52 public:
53  ITK_DISALLOW_COPY_AND_MOVE(BSplineInterpolationWeightFunction);
54 
58  FixedArray<double, Math::UnsignedPower(VSplineOrder + 1, VSpaceDimension)>>;
59 
62 
64  itkNewMacro(Self);
65 
67  itkOverrideGetNameOfClassMacro(BSplineInterpolationWeightFunction);
68 
70  static constexpr unsigned int SpaceDimension = VSpaceDimension;
71 
73  static constexpr unsigned int SplineOrder = VSplineOrder;
74 
77 
79  static constexpr unsigned int NumberOfWeights{ WeightsType::Length };
80 
84 
87 
89  static constexpr SizeType SupportSize{ SizeType::Filled(VSplineOrder + 1) };
90 
93  WeightsType
94  Evaluate(const ContinuousIndexType & index) const override;
95 
104  virtual void
105  Evaluate(const ContinuousIndexType & index, WeightsType & weights, IndexType & startIndex) const;
106 
107 #if !defined(ITK_LEGACY_REMOVE)
108 
109  itkLegacyMacro(SizeType GetSupportSize() const) { return Self::SupportSize; };
110 
112  itkLegacyMacro(unsigned int GetNumberOfWeights() const) { return Self::NumberOfWeights; }
113 #endif
114 
115 protected:
116  BSplineInterpolationWeightFunction() = default;
117  ~BSplineInterpolationWeightFunction() override = default;
118 
119 private:
122 
124  const TableType m_OffsetToIndexTable{ [] {
125  TableType table;
126  // Note: Copied the constexpr value `SupportSize` to a local variable, to prevent a GCC
127  // (Ubuntu 7.5.0-3ubuntu1~18.04) link error, "undefined reference to `SupportSize`", and Clang
128  // (Mac10.13-AppleClang-dbg-x86_64-static) "Undefined symbols for architecture x86_64".
129  const auto supportSize = SupportSize;
130  std::copy_n(ZeroBasedIndexRange<SpaceDimension>(supportSize).cbegin(), NumberOfWeights, table.begin());
131  return table;
132  }() };
133 };
134 } // end namespace itk
137 #ifndef ITK_MANUAL_INSTANTIATION
138 # include "itkBSplineInterpolationWeightFunction.hxx"
139 #endif
140 
141 #endif
itk::BSplineInterpolationWeightFunction
Returns the weights over the support region used for B-spline interpolation/reconstruction.
Definition: itkBSplineInterpolationWeightFunction.h:48
itkIndexRange.h
itk::Index
Represent a n-dimensional index in a n-dimensional image.
Definition: itkIndex.h:70
itkContinuousIndex.h
itk::Size
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:71
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SmartPointer< Self >
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itkFunctionBase.h
itk::BSplineInterpolationWeightFunction::WeightsType
typename Superclass::OutputType WeightsType
Definition: itkBSplineInterpolationWeightFunction.h:76
itk::Math::UnsignedPower
constexpr TReturnType UnsignedPower(const uintmax_t base, const uintmax_t exponent) noexcept
Definition: itkMath.h:797
itk::FixedArray
Simulate a standard C array with copy semantics.
Definition: itkFixedArray.h:53
itkArray.h
itk::FunctionBase
Base class for all ITK function objects.
Definition: itkFunctionBase.h:44
itkArray2D.h
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ContinuousIndex
A templated class holding a point in n-Dimensional image space.
Definition: itkContinuousIndex.h:46
itk::FixedArray::begin
constexpr iterator begin() noexcept
Definition: itkFixedArray.h:353
itk::IndexRange
Definition: itkIndexRange.h:78
itkMath.h