Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkBSplineSecondOrderDerivativeKernelFunction2_h
00018 #define __itkBSplineSecondOrderDerivativeKernelFunction2_h
00019
00020 #include "itkKernelFunction.h"
00021 #include "vnl/vnl_math.h"
00022
00023
00024 namespace itk
00025 {
00026
00042 template <unsigned int VSplineOrder = 3>
00043 class ITK_EXPORT BSplineSecondOrderDerivativeKernelFunction2 : public KernelFunction
00044 {
00045 public:
00047 typedef BSplineSecondOrderDerivativeKernelFunction2 Self;
00048 typedef KernelFunction Superclass;
00049 typedef SmartPointer<Self> Pointer;
00050
00052 itkNewMacro(Self);
00053
00055 itkTypeMacro(BSplineSecondOrderDerivativeKernelFunction2, KernelFunction);
00056
00058 itkStaticConstMacro(SplineOrder, unsigned int, VSplineOrder);
00059
00060
00061
00062
00063
00064
00065
00067 inline double Evaluate( const double & u ) const
00068 {
00069 return this->Evaluate( Dispatch<VSplineOrder>(), u );
00070 }
00071
00072 protected:
00073 BSplineSecondOrderDerivativeKernelFunction2(){};
00074 ~BSplineSecondOrderDerivativeKernelFunction2(){};
00075
00076 void PrintSelf(std::ostream& os, Indent indent) const
00077 {
00078 Superclass::PrintSelf( os, indent );
00079 os << indent << "Spline Order: " << SplineOrder << std::endl;
00080 }
00081
00082 private:
00083 BSplineSecondOrderDerivativeKernelFunction2(const Self&);
00084 void operator=(const Self&);
00085
00087 struct DispatchBase {};
00088 template<unsigned int>
00089 struct Dispatch : DispatchBase {};
00090
00134 inline double Evaluate ( const Dispatch<2>&, const double& u) const
00135 {
00136 double absValue = vnl_math_abs( u );
00137
00138 if ( absValue < 0.5 )
00139 {
00140 return -2.0;
00141 }
00142 else if ( absValue == 0.5 )
00143 {
00144 return -0.5;
00145 }
00146 else if ( absValue < 1.5 )
00147 {
00148 return 1.0;
00149 }
00150 else if ( absValue == 1.5 )
00151 {
00152 return 0.5;
00153 }
00154 else
00155 {
00156 return 0.0;
00157 }
00158
00159 }
00160
00162 inline double Evaluate ( const Dispatch<3>&, const double& u) const
00163 {
00164 const double absValue = vnl_math_abs( u );
00165
00166 if ( absValue < 1.0 )
00167 {
00168 return vnl_math_sgn0( u ) * ( 3.0 * u ) - 2.0;
00169 }
00170 else if ( absValue < 2.0 )
00171 {
00172 return -vnl_math_sgn( u ) * u + 2.0;
00173 }
00174 else
00175 {
00176 return 0.0;
00177 }
00178
00179 }
00180
00182 inline double Evaluate ( const DispatchBase&, const double&) const
00183 {
00184 itkExceptionMacro("Evaluate not implemented for spline\
00185 order " << SplineOrder);
00186 return 0.0;
00187
00188 }
00189
00190 };
00191
00192
00193 }
00194
00195 #endif