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 >
44 {
45 public:
46 
51 
53  itkNewMacro( Self );
54 
57 
59  itkStaticConstMacro( SplineOrder, unsigned int, VSplineOrder );
60 
61 // /** Evaluate the function. */
62 // inline double Evaluate( const double & u ) const
63 // {
64 // return ( m_KernelFunction->Evaluate( u + 0.5 ) -
65 // m_KernelFunction->Evaluate( u - 0.5 ) );
66 // }
68  inline double Evaluate( const double & u ) const
69  {
70  return this->Evaluate( Dispatch< VSplineOrder >(), u );
71  }
72 
73 
74 protected:
75 
78 
79  void PrintSelf( std::ostream & os, Indent indent ) const
80  {
81  Superclass::PrintSelf( os, indent );
82  os << indent << "Spline Order: " << SplineOrder << std::endl;
83  }
84 
85 
86 private:
87 
88  BSplineSecondOrderDerivativeKernelFunction2( const Self & ); // purposely not implemented
89  void operator=( const Self & ); // purposely not implemented
90 
92  struct DispatchBase {};
93  template< unsigned int >
94  struct Dispatch : DispatchBase {};
95 
139  inline double Evaluate( const Dispatch< 2 > &, const double & u ) const
140  {
141  double absValue = vnl_math_abs( u );
142 
143  if( absValue < 0.5 )
144  {
145  return -2.0;
146  }
147  else if( absValue == 0.5 )
148  {
149  return -0.5;
150  }
151  else if( absValue < 1.5 )
152  {
153  return 1.0;
154  }
155  else if( absValue == 1.5 )
156  {
157  return 0.5;
158  }
159  else
160  {
161  return 0.0;
162  }
163 
164  }
165 
166 
168  inline double Evaluate( const Dispatch< 3 > &, const double & u ) const
169  {
170  const double absValue = vnl_math_abs( u );
171 
172  if( absValue < 1.0 )
173  {
174  return vnl_math_sgn0( u ) * ( 3.0 * u ) - 2.0;
175  }
176  else if( absValue < 2.0 )
177  {
178  return -vnl_math_sgn( u ) * u + 2.0;
179  }
180  else
181  {
182  return 0.0;
183  }
184 
185  }
186 
187 
189  inline double Evaluate( const DispatchBase &, const double & ) const
190  {
191  itkExceptionMacro( "Evaluate not implemented for spline\
192  order " << SplineOrder );
193  return 0.0; // This is to avoid compiler warning about missing
194  // return statement. It should never be evaluated.
195  }
196 
197 
198 };
199 
200 } // end namespace itk
201 
202 #endif
double Evaluate(const Dispatch< 3 > &, const double &u) const
itkStaticConstMacro(SplineOrder, unsigned int, VSplineOrder)
double Evaluate(const Dispatch< 2 > &, const double &u) const
Derivative of a B-spline kernel used for density estimation and nonparametric regression.


Generated on 04-09-2015 for elastix by doxygen 1.8.9.1 elastix logo