Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkBSplineInterpolateImageFunction.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkBSplineInterpolateImageFunction.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/03/30 15:13:39 $
00007   Version:   $Revision: 1.15 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012   Portions of this code are covered under the VTK copyright.
00013   See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details.
00014 
00015      This software is distributed WITHOUT ANY WARRANTY; without even 
00016      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00017      PURPOSE.  See the above copyright notices for more information.
00018 
00019 =========================================================================*/
00020 
00021 #ifndef __itkBSplineInterpolateImageFunction_h
00022 #define __itkBSplineInterpolateImageFunction_h
00023 
00024 #include <vector>
00025 
00026 #include "itkImageLinearIteratorWithIndex.h"
00027 #include "itkInterpolateImageFunction.h"
00028 #include "vnl/vnl_matrix.h"
00029 
00030 #include "itkBSplineDecompositionImageFilter.h"
00031 #include "itkConceptChecking.h"
00032 #include "itkCovariantVector.h"
00033 
00034 namespace itk
00035 {
00069 template <
00070   class TImageType, 
00071   class TCoordRep = double,
00072   class TCoefficientType = double >
00073 class ITK_EXPORT BSplineInterpolateImageFunction : 
00074     public InterpolateImageFunction<TImageType,TCoordRep> 
00075 {
00076 public:
00078   typedef BSplineInterpolateImageFunction       Self;
00079   typedef InterpolateImageFunction<TImageType,TCoordRep>  Superclass;
00080   typedef SmartPointer<Self>                    Pointer;
00081   typedef SmartPointer<const Self>              ConstPointer;
00082 
00084   itkTypeMacro(BSplineInterpolateImageFunction, InterpolateImageFunction);
00085 
00086  
00088   itkNewMacro( Self );
00089 
00091   typedef typename Superclass::OutputType OutputType;
00092 
00094   typedef typename Superclass::InputImageType InputImageType;
00095 
00097   itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00098 
00100   typedef typename Superclass::IndexType IndexType;
00101 
00103   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00104 
00106   typedef typename Superclass::PointType PointType;
00107 
00109   typedef itk::ImageLinearIteratorWithIndex<TImageType> Iterator;
00110 
00112   typedef TCoefficientType CoefficientDataType;
00113   typedef itk::Image<CoefficientDataType, 
00114                      itkGetStaticConstMacro(ImageDimension)
00115     > CoefficientImageType;
00116 
00118   typedef itk::BSplineDecompositionImageFilter<TImageType, CoefficientImageType> 
00119   CoefficientFilter;
00120   typedef typename CoefficientFilter::Pointer CoefficientFilterPointer;
00121 
00130   virtual OutputType EvaluateAtContinuousIndex( 
00131     const ContinuousIndexType & index ) const; 
00132 
00134   typedef CovariantVector<OutputType,
00135                           itkGetStaticConstMacro(ImageDimension)
00136     > CovariantVectorType;
00137 
00138   CovariantVectorType EvaluateDerivative( const PointType & point ) const
00139   {    
00140     ContinuousIndexType index;
00141     this->GetInputImage()->TransformPhysicalPointToContinuousIndex( point, index );
00142     return ( this->EvaluateDerivativeAtContinuousIndex( index ) );
00143   } 
00144 
00145   CovariantVectorType EvaluateDerivativeAtContinuousIndex( 
00146     const ContinuousIndexType & x ) const;
00147 
00148 
00151   void SetSplineOrder(unsigned int SplineOrder);
00152   itkGetMacro(SplineOrder, int);
00154 
00155 
00157   virtual void SetInputImage(const TImageType * inputData);
00158 
00159 protected:
00160   BSplineInterpolateImageFunction();
00161   virtual ~BSplineInterpolateImageFunction() {};
00162   void operator=( const Self& ); //purposely not implemented
00163   void PrintSelf(std::ostream& os, Indent indent) const;
00164 
00165   // These are needed by the smoothing spline routine.
00166   std::vector<CoefficientDataType>    m_Scratch;        // temp storage for processing of Coefficients
00167   typename TImageType::SizeType       m_DataLength;  // Image size
00168   unsigned int                        m_SplineOrder; // User specified spline order (3rd or cubic is the default)
00169 
00170   typename CoefficientImageType::ConstPointer       m_Coefficients; // Spline coefficients  
00171 
00172 private:
00173   BSplineInterpolateImageFunction( const Self& ); //purposely not implemented
00175   void SetInterpolationWeights( const ContinuousIndexType & x, 
00176                                 const vnl_matrix<long> & EvaluateIndex, 
00177                                 vnl_matrix<double> & weights, 
00178                                 unsigned int splineOrder ) const;
00179 
00181   void SetDerivativeWeights( const ContinuousIndexType & x, 
00182                              const vnl_matrix<long> & EvaluateIndex, 
00183                              vnl_matrix<double> & weights, 
00184                              unsigned int splineOrder ) const;
00185 
00188   void GeneratePointsToIndex(  );
00189 
00191   void DetermineRegionOfSupport( vnl_matrix<long> & evaluateIndex, 
00192                                  const ContinuousIndexType & x, 
00193                                  unsigned int splineOrder ) const;
00194 
00197   void ApplyMirrorBoundaryConditions(vnl_matrix<long> & evaluateIndex, 
00198                                      unsigned int splineOrder) const;
00199 
00200 
00201   Iterator                  m_CIterator;    // Iterator for traversing spline coefficients.
00202   unsigned long             m_MaxNumberInterpolationPoints; // number of neighborhood points used for interpolation
00203   std::vector<IndexType>    m_PointsToIndex;  // Preallocation of interpolation neighborhood indicies
00204 
00205   CoefficientFilterPointer     m_CoefficientFilter;
00206   
00207 };
00208 
00209 } // namespace itk
00210 
00211 #ifndef ITK_MANUAL_INSTANTIATION
00212 #include "itkBSplineInterpolateImageFunction.txx"
00213 #endif
00214 
00215 #endif
00216 
00217 

Generated at Sun Sep 23 12:05:20 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000