18#ifndef itkBSplineKernelFunction_h
19#define itkBSplineKernelFunction_h
42template <
unsigned int VSplineOrder = 3,
typename TRealValueType =
double>
73 Evaluate(
const TRealValueType & u)
const override
86 os << indent <<
"SplineOrder: " <<
SplineOrder << std::endl;
93 template <
unsigned int>
98 static inline TRealValueType
99 Evaluate(
const Dispatch<0> &,
const TRealValueType & u)
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
119 Evaluate(
const Dispatch<1> &,
const TRealValueType & u)
122 if (absValue < TRealValueType{ 1.0 })
124 return TRealValueType{ 1.0 } - absValue;
128 return TRealValueType{ 0.0 };
132 static inline TRealValueType
133 Evaluate(
const Dispatch<2> &,
const TRealValueType & u)
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
157 Evaluate(
const Dispatch<3> &,
const TRealValueType & u)
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
182 Evaluate(
const DispatchBase &,
const TRealValueType &)
184 itkGenericExceptionMacro(
"Evaluate not implemented for spline order " <<
SplineOrder);
KernelFunctionBase< TRealValueType > Superclass
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 constexpr unsigned int SplineOrder
static TRealValueType Evaluate(const Dispatch< 3 > &, const TRealValueType &u)
SmartPointer< Self > Pointer
static TRealValueType Evaluate(const DispatchBase &, const TRealValueType &)
BSplineKernelFunction Self
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.
KernelFunctionBase()=default
virtual void PrintSelf(std::ostream &os, Indent indent) const
Implements transparent reference counting.
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....