18#ifndef itkBSplineKernelFunction_h
19#define itkBSplineKernelFunction_h
42template <
unsigned int VSplineOrder = 3,
typename TRealValueType =
double>
61 static constexpr unsigned int SplineOrder = VSplineOrder;
73 Evaluate(
const TRealValueType & u)
const override
75 return Self::FastEvaluate(u);
84 Superclass::PrintSelf(os, indent);
86 os << indent <<
"SplineOrder: " << SplineOrder << std::endl;
93 template <
unsigned int>
98 inline static TRealValueType
102 if (absValue < TRealValueType{ 0.5 })
104 return TRealValueType{ 1.0 };
108 return TRealValueType{ 0.5 };
112 return TRealValueType{ 0.0 };
118 inline static TRealValueType
122 if (absValue < TRealValueType{ 1.0 })
124 return TRealValueType{ 1.0 } - absValue;
128 return TRealValueType{ 0.0 };
134 inline static TRealValueType
138 if (absValue < TRealValueType{ 0.5 })
140 const TRealValueType sqrValue = itk::Math::sqr(absValue);
141 return TRealValueType{ 0.75 } - sqrValue;
143 else if (absValue < TRealValueType{ 1.5 })
145 const TRealValueType sqrValue = itk::Math::sqr(absValue);
147 return (TRealValueType{ 9.0 } - TRealValueType{ 12.0 } * absValue + TRealValueType{ 4.0 } * sqrValue) *
148 TRealValueType{ 0.125 };
152 return TRealValueType{ 0.0 };
158 inline static TRealValueType
162 if (absValue < TRealValueType{ 1.0 })
164 const TRealValueType sqrValue = itk::Math::sqr(absValue);
165 return (TRealValueType{ 4.0 } - TRealValueType{ 6.0 } * sqrValue + TRealValueType{ 3.0 } * sqrValue * absValue) /
166 TRealValueType{ 6.0 };
168 else if (absValue < TRealValueType{ 2.0 })
170 const TRealValueType sqrValue = itk::Math::sqr(absValue);
171 return (TRealValueType{ 8.0 } - TRealValueType{ 12.0 } * absValue + TRealValueType{ 6.0 } * sqrValue -
172 sqrValue * absValue) /
173 TRealValueType{ 6.0 };
177 return TRealValueType{ 0.0 };
183 inline static TRealValueType
186 itkGenericExceptionMacro(
"Evaluate not implemented for spline order " << SplineOrder);
BSpline kernel used for density estimation and nonparametric regression.
static TRealValueType FastEvaluate(const TRealValueType u)
TRealValueType Evaluate(const TRealValueType &u) const override
~BSplineKernelFunction() override=default
static TRealValueType Evaluate(const Dispatch< 1 > &, const TRealValueType &u)
BSplineKernelFunction()=default
static TRealValueType Evaluate(const Dispatch< 3 > &, const TRealValueType &u)
static TRealValueType Evaluate(const DispatchBase &, const TRealValueType &)
static TRealValueType Evaluate(const Dispatch< 2 > &, const TRealValueType &u)
void PrintSelf(std::ostream &os, Indent indent) const override
static TRealValueType Evaluate(const Dispatch< 0 > &, const TRealValueType &u)
Control indentation during Print() invocation.
Kernel used for density estimation and nonparametric regression.
bool ExactlyEquals(const TInput1 &x1, const TInput2 &x2)
Return the result of an exact comparison between two scalar values of potentially different types.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....