go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkBSplineSecondOrderDerivativeKernelFunction2.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright UMC Utrecht and contributors
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef __itkBSplineSecondOrderDerivativeKernelFunction2_h
19 #define __itkBSplineSecondOrderDerivativeKernelFunction2_h
20 
21 #include "itkKernelFunctionBase.h"
22 #include "vnl/vnl_math.h"
23 
24 namespace itk
25 {
26 
42 template< unsigned int VSplineOrder = 3 >
43 class BSplineSecondOrderDerivativeKernelFunction2 : public KernelFunctionBase< double >
44 {
45 public:
46 
49  typedef KernelFunctionBase< double > Superclass;
51 
53  itkNewMacro( Self );
54 
56  itkTypeMacro( BSplineSecondOrderDerivativeKernelFunction2, KernelFunctionBase );
57 
59  itkStaticConstMacro( SplineOrder, unsigned int, VSplineOrder );
60 
62  inline double Evaluate( const double & u ) const
63  {
64  return this->Evaluate( Dispatch< VSplineOrder >(), u );
65  }
66 
67 
69  inline void Evaluate( const double & u, double * weights ) const
70  {
71  this->Evaluate( Dispatch< VSplineOrder >(), u, weights );
72  }
73 
74 
75 protected:
76 
79 
80  void PrintSelf( std::ostream & os, Indent indent ) const
81  {
82  Superclass::PrintSelf( os, indent );
83  os << indent << "Spline Order: " << SplineOrder << std::endl;
84  }
85 
86 
87 private:
88 
89  BSplineSecondOrderDerivativeKernelFunction2( const Self & ); // purposely not implemented
90  void operator=( const Self & ); // purposely not implemented
91 
93  struct DispatchBase {};
94  template< unsigned int >
95  struct Dispatch : DispatchBase {};
96 
98  // Second order derivative not defined.
99 
101  // Second order derivative not defined.
102 
104  inline double Evaluate( const Dispatch< 2 > &, const double & u ) const
105  {
106  double absValue = vnl_math_abs( u );
107 
108  if( absValue < 0.5 )
109  {
110  return -2.0;
111  }
112  else if( absValue == 0.5 )
113  {
114  return -0.5;
115  }
116  else if( absValue < 1.5 )
117  {
118  return 1.0;
119  }
120  else if( absValue == 1.5 )
121  {
122  return 0.5;
123  }
124  else
125  {
126  return 0.0;
127  }
128  }
129 
130 
131  inline void Evaluate( const Dispatch< 2 > &, const double & u, double * weights ) const
132  {
133  weights[ 0 ] = 1.0;
134  weights[ 1 ] = -2.0;
135  weights[ 2 ] = 1.0;
136  }
137 
138 
140  inline double Evaluate( const Dispatch< 3 > &, const double & u ) const
141  {
142  const double absValue = vnl_math_abs( u );
143 
144  if( absValue < 1.0 )
145  {
146  return vnl_math_sgn0( u ) * ( 3.0 * u ) - 2.0;
147  }
148  else if( absValue < 2.0 )
149  {
150  return -vnl_math_sgn( u ) * u + 2.0;
151  }
152  else
153  {
154  return 0.0;
155  }
156  }
157 
158 
159  inline void Evaluate( const Dispatch< 3 > &, const double & u, double * weights ) const
160  {
161  weights[ 0 ] = -u + 2.0;
162  weights[ 1 ] = 3.0 * u - 5.0;
163  weights[ 2 ] = -3.0 * u + 4.0;
164  weights[ 3 ] = u - 1.0;
165  }
166 
167 
169  inline double Evaluate( const DispatchBase &, const double & ) const
170  {
171  itkExceptionMacro( "Evaluate not implemented for spline order " << SplineOrder );
172  return 0.0; // This is to avoid compiler warning about missing
173  // return statement. It should never be evaluated.
174  }
175 
176 
177  inline void Evaluate( const DispatchBase &, const double &, double * ) const
178  {
179  itkExceptionMacro( "Evaluate not implemented for spline order " << SplineOrder );
180  }
181 
182 
183 };
184 
185 } // end namespace itk
186 
187 #endif
void Evaluate(const Dispatch< 3 > &, const double &u, double *weights) const
void Evaluate(const Dispatch< 2 > &, const double &u, double *weights) const
itkStaticConstMacro(SplineOrder, unsigned int, VSplineOrder)
void Evaluate(const DispatchBase &, const double &, double *) const
Derivative of a B-spline kernel used for density estimation and nonparametric regression.


Generated on OURCE_DATE_EPOCH for elastix by doxygen 1.8.13 elastix logo