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);
85 os << indent <<
"Spline Order: " << SplineOrder << std::endl;
92 template <
unsigned int>
97 inline static TRealValueType
101 if (absValue < TRealValueType{ 0.5 })
103 return TRealValueType{ 1.0 };
107 return TRealValueType{ 0.5 };
111 return TRealValueType{ 0.0 };
117 inline static TRealValueType
121 if (absValue < TRealValueType{ 1.0 })
123 return TRealValueType{ 1.0 } - absValue;
127 return TRealValueType{ 0.0 };
133 inline static TRealValueType
137 if (absValue < TRealValueType{ 0.5 })
139 const TRealValueType sqrValue = itk::Math::sqr(absValue);
140 return TRealValueType{ 0.75 } - sqrValue;
142 else if (absValue < TRealValueType{ 1.5 })
144 const TRealValueType sqrValue = itk::Math::sqr(absValue);
146 return (TRealValueType{ 9.0 } - TRealValueType{ 12.0 } * absValue + TRealValueType{ 4.0 } * sqrValue) *
147 TRealValueType{ 0.125 };
151 return TRealValueType{ 0.0 };
157 inline static TRealValueType
161 if (absValue < TRealValueType{ 1.0 })
163 const TRealValueType sqrValue = itk::Math::sqr(absValue);
164 return (TRealValueType{ 4.0 } - TRealValueType{ 6.0 } * sqrValue + TRealValueType{ 3.0 } * sqrValue * absValue) /
165 TRealValueType{ 6.0 };
167 else if (absValue < TRealValueType{ 2.0 })
169 const TRealValueType sqrValue = itk::Math::sqr(absValue);
170 return (TRealValueType{ 8.0 } - TRealValueType{ 12.0 } * absValue + TRealValueType{ 6.0 } * sqrValue -
171 sqrValue * absValue) /
172 TRealValueType{ 6.0 };
176 return TRealValueType{ 0.0 };
182 inline static TRealValueType
185 itkGenericExceptionMacro(
"Evaluate not implemented for spline order " << SplineOrder);