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 static inline TRealValueType
102 if (absValue < TRealValueType{ 0.5 })
104 return TRealValueType{ 1.0 };
108 return TRealValueType{ 0.5 };
112 return TRealValueType{ 0.0 };
118 static inline TRealValueType
122 if (absValue < TRealValueType{ 1.0 })
124 return TRealValueType{ 1.0 } - absValue;
128 return TRealValueType{ 0.0 };
132 static inline TRealValueType
136 if (absValue < TRealValueType{ 0.5 })
138 const TRealValueType sqrValue = itk::Math::sqr(absValue);
139 return TRealValueType{ 0.75 } - sqrValue;
141 if (absValue < TRealValueType{ 1.5 })
143 const TRealValueType sqrValue = itk::Math::sqr(absValue);
145 return (TRealValueType{ 9.0 } - TRealValueType{ 12.0 } * absValue + TRealValueType{ 4.0 } * sqrValue) *
146 TRealValueType{ 0.125 };
150 return TRealValueType{ 0.0 };
156 static inline TRealValueType
160 if (absValue < TRealValueType{ 1.0 })
162 const TRealValueType sqrValue = itk::Math::sqr(absValue);
163 return (TRealValueType{ 4.0 } - TRealValueType{ 6.0 } * sqrValue + TRealValueType{ 3.0 } * sqrValue * absValue) /
164 TRealValueType{ 6.0 };
166 if (absValue < TRealValueType{ 2.0 })
168 const TRealValueType sqrValue = itk::Math::sqr(absValue);
169 return (TRealValueType{ 8.0 } - TRealValueType{ 12.0 } * absValue + TRealValueType{ 6.0 } * sqrValue -
170 sqrValue * absValue) /
171 TRealValueType{ 6.0 };
175 return TRealValueType{ 0.0 };
181 static inline TRealValueType
184 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....