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 };
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);