18 #ifndef itkBSplineKernelFunction_h
19 #define itkBSplineKernelFunction_h
42 template <
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 };
134 static inline 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 static inline 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 static inline TRealValueType
186 itkGenericExceptionMacro(
"Evaluate not implemented for spline order " << SplineOrder);