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.
00001 /*======================================================================
00002 
00003 This file is part of the elastix software.
00004 
00005 Copyright (c) University Medical Center Utrecht. All rights reserved.
00006 See src/CopyrightElastix.txt or http://elastix.isi.uu.nl/legal.php for
00007 details.
00008 
00009 This software is distributed WITHOUT ANY WARRANTY; without even
00010 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00011 PURPOSE. See the above copyright notices for more information.
00012 
00013 ======================================================================*/
00014 #ifndef __itkBSplineInterpolationWeightFunctionBase_h
00015 #define __itkBSplineInterpolationWeightFunctionBase_h
00016 
00017 #include "itkFunctionBase.h"
00018 #include "itkContinuousIndex.h"
00019 #include "itkArray.h"
00020 #include "itkArray2D.h"
00021 #include "itkMatrix.h"
00022 #include "itkBSplineKernelFunction2.h"
00023 #include "itkBSplineDerivativeKernelFunction2.h"
00024 #include "itkBSplineSecondOrderDerivativeKernelFunction2.h"
00025 
00026 
00027 namespace itk
00028 {
00029 
00031   template <unsigned int SplineOrder, unsigned int Dimension>
00032   class GetConstNumberOfWeightsHack
00033   {
00034   public:
00035     typedef GetConstNumberOfWeightsHack<SplineOrder, Dimension-1> OneDimensionLess;
00036     itkStaticConstMacro( Value, unsigned long, (SplineOrder+1) * OneDimensionLess::Value );
00037   };
00038 
00040   template <unsigned int SplineOrder>
00041   class GetConstNumberOfWeightsHack<SplineOrder, 0>
00042   {
00043   public:
00044     itkStaticConstMacro( Value, unsigned long, 1 );
00045   };
00046 
00063 template < class TCoordRep = float,
00064   unsigned int VSpaceDimension = 2,
00065   unsigned int VSplineOrder = 3 >
00066 class ITK_EXPORT BSplineInterpolationWeightFunctionBase :
00067 public FunctionBase< ContinuousIndex<TCoordRep,VSpaceDimension>, Array<double> >
00068 {
00069 public:
00071   typedef BSplineInterpolationWeightFunctionBase  Self;
00072   typedef FunctionBase<
00073     ContinuousIndex< TCoordRep, VSpaceDimension >,
00074     Array<double> >                               Superclass;
00075   typedef SmartPointer<Self>                      Pointer;
00076   typedef SmartPointer<const Self>                ConstPointer;
00077 
00079   itkTypeMacro( BSplineInterpolationWeightFunctionBase, FunctionBase );
00080 
00082   itkStaticConstMacro( SpaceDimension, unsigned int, VSpaceDimension );
00083 
00085   itkStaticConstMacro( SplineOrder, unsigned int, VSplineOrder );
00086 
00088   typedef GetConstNumberOfWeightsHack<
00089       itkGetStaticConstMacro(SplineOrder),
00090       itkGetStaticConstMacro(SpaceDimension) > GetConstNumberOfWeightsHackType;
00091   itkStaticConstMacro( NumberOfWeights, unsigned long, GetConstNumberOfWeightsHackType::Value );
00092 
00094   typedef Array< double > WeightsType;
00095 
00097   typedef Index<VSpaceDimension> IndexType;
00098   typedef Size<VSpaceDimension>  SizeType;
00099 
00101   typedef ContinuousIndex<TCoordRep,VSpaceDimension> ContinuousIndexType;
00102 
00104   virtual WeightsType Evaluate( const ContinuousIndexType & index ) const;
00105 
00113   virtual void Evaluate( const ContinuousIndexType & cindex,
00114     const IndexType & startIndex, WeightsType & weights ) const;
00115 
00117   void ComputeStartIndex( const ContinuousIndexType & index,
00118     IndexType & startIndex ) const;
00119 
00121   itkGetConstReferenceMacro( SupportSize, SizeType );
00122 
00124   itkGetConstMacro( NumberOfWeights, unsigned long );
00125 
00126 protected:
00127   BSplineInterpolationWeightFunctionBase();
00128   ~BSplineInterpolationWeightFunctionBase() {};
00129 
00131   typedef BSplineKernelFunction2<
00132     itkGetStaticConstMacro( SplineOrder ) >   KernelType;
00133   typedef BSplineDerivativeKernelFunction2<
00134     itkGetStaticConstMacro( SplineOrder ) >   DerivativeKernelType;
00135   typedef BSplineSecondOrderDerivativeKernelFunction2<
00136     itkGetStaticConstMacro( SplineOrder ) >   SecondOrderDerivativeKernelType;
00137   typedef typename KernelType::WeightArrayType WeightArrayType;
00138 
00140   typedef Array2D<unsigned long> TableType;
00141 
00146   typedef Matrix< double,
00147     itkGetStaticConstMacro( SpaceDimension ),
00148     itkGetStaticConstMacro( SplineOrder ) + 1 > OneDWeightsType;
00149 
00151   virtual void Compute1DWeights(
00152     const ContinuousIndexType & index,
00153     const IndexType & startIndex,
00154     OneDWeightsType & weights1D ) const = 0;
00155 
00157   virtual void PrintSelf( std::ostream & os, Indent indent ) const;
00158 
00160   unsigned long m_NumberOfWeights;
00161   SizeType      m_SupportSize;
00162   TableType     m_OffsetToIndexTable;
00163 
00165   typename KernelType::Pointer                      m_Kernel;
00166   typename DerivativeKernelType::Pointer            m_DerivativeKernel;
00167   typename SecondOrderDerivativeKernelType::Pointer m_SecondOrderDerivativeKernel;
00168 
00169 private:
00170 
00171   BSplineInterpolationWeightFunctionBase(const Self&); //purposely not implemented
00172   void operator=(const Self&); //purposely not implemented
00173 
00175   void InitializeSupport( void );
00176 
00181   void InitializeOffsetToIndexTable( void );
00182 
00183 };
00184 
00185 } // end namespace itk
00186 
00187 // Define instantiation macro for this template.
00188 #define ITK_TEMPLATE_BSplineInterpolationWeightFunctionBase(_, EXPORT, x, y) namespace itk { \
00189   _(3(class EXPORT BSplineInterpolationWeightFunctionBase< ITK_TEMPLATE_3 x >)) \
00190   namespace Templates { typedef BSplineInterpolationWeightFunctionBase< ITK_TEMPLATE_3 x > BSplineInterpolationWeightFunctionBase##y; } \
00191   }
00192 
00193 #if ITK_TEMPLATE_EXPLICIT
00194 # include "Templates/itkBSplineInterpolationWeightFunctionBase+-.h"
00195 #endif
00196 
00197 #if ITK_TEMPLATE_TXX
00198 # include "itkBSplineInterpolationWeightFunctionBase.txx"
00199 #endif
00200 
00201 
00202 #endif


Generated on 24-05-2012 for elastix by doxygen 1.7.6.1 elastix logo