18 #ifndef __itkBSplineKernelFunction_h
19 #define __itkBSplineKernelFunction_h
41 template<
unsigned int VSplineOrder = 3,
typename TRealValueType =
double >
58 itkStaticConstMacro(SplineOrder,
unsigned int, VSplineOrder);
61 inline TRealValueType Evaluate(
const TRealValueType & u)
const
69 void PrintSelf(std::ostream & os,
Indent indent)
const
71 Superclass::PrintSelf(os, indent);
72 os << indent <<
"Spline Order: " << SplineOrder << std::endl;
77 void operator=(
const Self &);
81 template<
unsigned int >
85 inline TRealValueType Evaluate(
const Dispatch< 0 > &,
const TRealValueType & u)
const
87 const TRealValueType absValue = vnl_math_abs(u);
88 if ( absValue < static_cast< TRealValueType >(0.5) )
92 else if ( absValue == static_cast< TRealValueType >(0.5) )
94 return static_cast< TRealValueType
>(0.5);
104 inline TRealValueType Evaluate(
const Dispatch< 1 > &,
const TRealValueType & u)
const
106 const TRealValueType absValue = vnl_math_abs(u);
119 inline TRealValueType Evaluate(
const Dispatch< 2 > &,
const TRealValueType & u)
const
121 const TRealValueType absValue = vnl_math_abs(u);
122 if ( absValue < static_cast< TRealValueType >(0.5) )
124 const TRealValueType sqrValue = vnl_math_sqr(absValue);
125 return static_cast< TRealValueType
>(0.75) - sqrValue;
127 else if ( absValue < static_cast< TRealValueType >(1.5) )
129 const TRealValueType sqrValue = vnl_math_sqr(absValue);
131 return ( static_cast< TRealValueType >(9.0) - static_cast< TRealValueType >(12.0) * absValue
132 + static_cast< TRealValueType >(4.0) * sqrValue ) *
static_cast< TRealValueType
>(0.125);
142 inline TRealValueType Evaluate(
const Dispatch< 3 > &,
const TRealValueType & u)
const
144 const TRealValueType absValue = vnl_math_abs(u);
147 const TRealValueType sqrValue = vnl_math_sqr(absValue);
148 return ( static_cast< TRealValueType >(4.0) - static_cast< TRealValueType >(6.0) * sqrValue
149 + static_cast< TRealValueType >(3.0) * sqrValue * absValue ) /
static_cast< TRealValueType
>(6.0);
151 else if ( absValue < static_cast< TRealValueType >(2.0) )
153 const TRealValueType sqrValue = vnl_math_sqr(absValue);
154 return ( static_cast< TRealValueType >(8.0) - static_cast< TRealValueType >(12.0) * absValue + static_cast< TRealValueType >(6.0) * sqrValue
155 - sqrValue * absValue ) /
static_cast< TRealValueType
>(6.0);
165 inline TRealValueType Evaluate(
const DispatchBase &,
const TRealValueType &)
const
167 itkExceptionMacro(
"Evaluate not implemented for spline order "