33#ifndef itkBSplineKernelFunction2_h
34#define itkBSplineKernelFunction2_h
37#include <vnl/vnl_math.h>
57template <
unsigned int VSplineOrder = 3>
85 return Self::Evaluate(Dispatch<VSplineOrder>(), u);
95 Self::Evaluate(Dispatch<VSplineOrder>(), u, weights);
103 return Self::FastEvaluate(u);
111 Evaluate(
const double & u,
double * weights)
const override
113 Self::FastEvaluate(u, weights);
122 PrintSelf(std::ostream & os, Indent indent)
const override
124 Superclass::PrintSelf(os, indent);
125 os << indent <<
"Spline Order: " << SplineOrder << std::endl;
131 template <
unsigned int>
132 struct ITK_TEMPLATE_EXPORT Dispatch
143 const double absValue = std::abs(u);
149 else if (absValue == 0.5)
164 const double absValue = std::abs(u);
168 return 1.0 - absValue;
181 const double absValue = std::abs(u);
185 return 0.75 - absValue * absValue;
187 else if (absValue < 1.5)
189 return (9.0 - 12.0 * absValue + 4.0 * absValue * absValue) / 8.0;
202 const double absValue = std::abs(u);
203 const double sqrValue = u * u;
207 return (4.0 - 6.0 * sqrValue + 3.0 * sqrValue * absValue) / 6.0;
209 else if (absValue < 2.0)
211 return (8.0 - 12.0 * absValue + 6.0 * sqrValue - sqrValue * absValue) / 6.0;
226 Evaluate(
const Dispatch<0> &,
const double u,
double * weights)
228 const double absValue = std::abs(u);
234 else if (absValue == 0.5)
247 Evaluate(
const Dispatch<1> &,
const double u,
double * weights)
249 const double absValue = std::abs(u);
251 weights[0] = 1.0 - absValue;
252 weights[1] = absValue;
258 Evaluate(
const Dispatch<2> &,
const double u,
double * weights)
260 const double absValue = std::abs(u);
261 const double sqrValue = u * u;
263 weights[0] = (9.0 - 12.0 * absValue + 4.0 * sqrValue) / 8.0;
264 weights[1] = -0.25 + 2.0 * absValue - sqrValue;
265 weights[2] = (1.0 - 4.0 * absValue + 4.0 * sqrValue) / 8.0;
271 Evaluate(
const Dispatch<3> &,
const double u,
double * weights)
273 const double absValue = std::abs(u);
274 const double sqrValue = u * u;
275 const double uuu = sqrValue * absValue;
279 static const double onesixth = 1.0 / 6.0;
280 weights[0] = (8.0 - 12.0 * absValue + 6.0 * sqrValue - uuu) * onesixth;
281 weights[1] = (-5.0 + 21.0 * absValue - 15.0 * sqrValue + 3.0 * uuu) * onesixth;
282 weights[2] = (4.0 - 12.0 * absValue + 12.0 * sqrValue - 3.0 * uuu) * onesixth;
283 weights[3] = (-1.0 + 3.0 * absValue - 3.0 * sqrValue + uuu) * onesixth;
B-spline kernel used for density estimation and nonparameteric regression.
FixedArray< double, VSplineOrder+1 > WeightArrayType
~BSplineKernelFunction2() override=default
static void Evaluate(const Dispatch< 2 > &, const double u, double *weights)
void Evaluate(const double &u, double *weights) const override
static void Evaluate(const Dispatch< 1 > &, const double u, double *weights)
void PrintSelf(std::ostream &os, Indent indent) const override
static double Evaluate(const Dispatch< 1 > &, const double u)
static void FastEvaluate(const double u, double *const weights)
static double Evaluate(const Dispatch< 0 > &, const double u)
static void Evaluate(const Dispatch< 3 > &, const double u, double *weights)
static void Evaluate(const Dispatch< 0 > &, const double u, double *weights)
static double Evaluate(const Dispatch< 3 > &, const double u)
BSplineKernelFunction2()=default
ITK_DISALLOW_COPY_AND_MOVE(BSplineKernelFunction2)
static double Evaluate(const Dispatch< 2 > &, const double u)
itkStaticConstMacro(SplineOrder, unsigned int, VSplineOrder)
static double FastEvaluate(const double u)
double Evaluate(const double &u) const override
Kernel used for density estimation and nonparameteric regression.