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
28namespace itk
29{
47template <typename TCoordRep = float, unsigned int VSpaceDimension = 2, unsigned int VSplineOrder = 3>
48class ITK_TEMPLATE_EXPORT BSplineInterpolationWeightFunction
49 : public FunctionBase<ContinuousIndex<TCoordRep, VSpaceDimension>,
50 FixedArray<double, Math::UnsignedPower(VSplineOrder + 1, VSpaceDimension)>>
51{
52public:
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)
109 itkLegacyMacro(SizeType GetSupportSize() const) { return Self::SupportSize; };
110
112 itkLegacyMacro(unsigned int GetNumberOfWeights() const) { return Self::NumberOfWeights; }
113#endif
114
115protected:
118
119private:
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
Returns the weights over the support region used for B-spline interpolation/reconstruction.
~BSplineInterpolationWeightFunction() override=default
WeightsType Evaluate(const ContinuousIndexType &index) const override
virtual void Evaluate(const ContinuousIndexType &index, WeightsType &weights, IndexType &startIndex) const
A templated class holding a point in n-Dimensional image space.
Simulate a standard C array with copy semantics.
Definition: itkFixedArray.h:54
constexpr iterator begin() noexcept
Base class for all ITK function objects.
constexpr TReturnType UnsignedPower(const uintmax_t base, const uintmax_t exponent) noexcept
Definition: itkMath.h:797
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Represent a n-dimensional index in a n-dimensional image.
Definition: itkIndex.h:71
Represent a n-dimensional size (bounds) of a n-dimensional image.
Definition: itkSize.h:72