go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkBSplineInterpolationWeightFunctionBase.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 __itkBSplineInterpolationWeightFunctionBase_h
19 #define __itkBSplineInterpolationWeightFunctionBase_h
20 
21 #include "itkFunctionBase.h"
22 #include "itkContinuousIndex.h"
23 #include "itkArray.h"
24 #include "itkArray2D.h"
25 #include "itkMatrix.h"
27 #include "itkBSplineDerivativeKernelFunction.h"
29 
30 namespace itk
31 {
32 
34 template< unsigned int SplineOrder, unsigned int Dimension >
35 class GetConstNumberOfWeightsHack
36 {
37 public:
38 
39  typedef GetConstNumberOfWeightsHack< SplineOrder, Dimension - 1 > OneDimensionLess;
40  itkStaticConstMacro( Value, unsigned long, ( SplineOrder + 1 ) * OneDimensionLess::Value );
41 };
42 
44 template< unsigned int SplineOrder >
45 class GetConstNumberOfWeightsHack< SplineOrder, 0 >
46 {
47 public:
48 
49  itkStaticConstMacro( Value, unsigned long, 1 );
50 };
51 
68 template< class TCoordRep = float,
69 unsigned int VSpaceDimension = 2,
70 unsigned int VSplineOrder = 3 >
72  public FunctionBase< ContinuousIndex< TCoordRep, VSpaceDimension >, Array< double > >
73 {
74 public:
75 
78  typedef FunctionBase<
79  ContinuousIndex< TCoordRep, VSpaceDimension >,
80  Array< double > > Superclass;
82  typedef SmartPointer< const Self > ConstPointer;
83 
86 
88  itkStaticConstMacro( SpaceDimension, unsigned int, VSpaceDimension );
89 
91  itkStaticConstMacro( SplineOrder, unsigned int, VSplineOrder );
92 
94  typedef GetConstNumberOfWeightsHack<
95  itkGetStaticConstMacro( SplineOrder ),
96  itkGetStaticConstMacro( SpaceDimension ) > GetConstNumberOfWeightsHackType;
97  itkStaticConstMacro( NumberOfWeights, unsigned long, GetConstNumberOfWeightsHackType::Value );
98 
100  typedef Array< double > WeightsType;
101 
103  typedef Index< VSpaceDimension > IndexType;
104  typedef Size< VSpaceDimension > SizeType;
105 
107  typedef ContinuousIndex< TCoordRep, VSpaceDimension > ContinuousIndexType;
108 
110  virtual WeightsType Evaluate( const ContinuousIndexType & index ) const;
111 
119  virtual void Evaluate( const ContinuousIndexType & cindex,
120  const IndexType & startIndex, WeightsType & weights ) const;
121 
123  void ComputeStartIndex( const ContinuousIndexType & index,
124  IndexType & startIndex ) const;
125 
127  itkGetConstReferenceMacro( SupportSize, SizeType );
128 
130  itkGetConstMacro( NumberOfWeights, unsigned long );
131 
132 protected:
133 
136 
140  typedef BSplineDerivativeKernelFunction< Self::SplineOrder > DerivativeKernelType;
141  typedef typename DerivativeKernelType::Pointer DerivativeKernelPointer;
145 
147  typedef Array2D< unsigned long > TableType;
148 
153  typedef Matrix< double,
154  itkGetStaticConstMacro( SpaceDimension ),
155  itkGetStaticConstMacro( SplineOrder ) + 1 > OneDWeightsType;
156 
158  virtual void Compute1DWeights(
159  const ContinuousIndexType & index,
160  const IndexType & startIndex,
161  OneDWeightsType & weights1D ) const = 0;
162 
164  virtual void PrintSelf( std::ostream & os, Indent indent ) const;
165 
167  unsigned long m_NumberOfWeights;
168  SizeType m_SupportSize;
170 
173  typename DerivativeKernelType::Pointer m_DerivativeKernel;
175 
176 private:
177 
178  BSplineInterpolationWeightFunctionBase( const Self & ); // purposely not implemented
179  void operator=( const Self & ); // purposely not implemented
180 
182  void InitializeSupport( void );
183 
188  void InitializeOffsetToIndexTable( void );
189 
190 };
191 
192 } // end namespace itk
193 
194 #ifndef ITK_MANUAL_INSTANTIATION
195 #include "itkBSplineInterpolationWeightFunctionBase.hxx"
196 #endif
197 
198 #endif
Matrix< double, itkGetStaticConstMacro(SpaceDimension), itkGetStaticConstMacro(SplineOrder)+1 > OneDWeightsType
SecondOrderDerivativeKernelType::Pointer SecondOrderDerivativeKernelPointer
ContinuousIndex< TCoordRep, VSpaceDimension > ContinuousIndexType
virtual WeightsType Evaluate(const ContinuousIndexType &index) const
BSplineSecondOrderDerivativeKernelFunction2< Self::SplineOrder > SecondOrderDerivativeKernelType
BSplineDerivativeKernelFunction< Self::SplineOrder > DerivativeKernelType
SecondOrderDerivativeKernelType::Pointer m_SecondOrderDerivativeKernel
void ComputeStartIndex(const ContinuousIndexType &index, IndexType &startIndex) const
itkStaticConstMacro(SpaceDimension, unsigned int, VSpaceDimension)
virtual void PrintSelf(std::ostream &os, Indent indent) const
FunctionBase< ContinuousIndex< TCoordRep, VSpaceDimension >, Array< double > > Superclass
FixedArray< double, itkGetStaticConstMacro(SplineOrder)+1 > WeightArrayType
B-spline kernel used for density estimation and nonparameteric regression.
virtual void Compute1DWeights(const ContinuousIndexType &index, const IndexType &startIndex, OneDWeightsType &weights1D) const =0
Returns the weights over the support region used for B-spline interpolation/reconstruction.
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