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);
00153 
00154 
00156   virtual void SetInputImage(const TImageType * inputData);
00157 
00158 protected:
00159   BSplineInterpolateImageFunction();
00160   virtual ~BSplineInterpolateImageFunction() {};
00161   void operator=( const Self& ); //purposely not implemented
00162   void PrintSelf(std::ostream& os, Indent indent) const;
00163 
00164   // These are needed by the smoothing spline routine.
00165   std::vector<CoefficientDataType>    m_Scratch;        // temp storage for processing of Coefficients
00166   typename TImageType::SizeType       m_DataLength;  // Image size
00167   unsigned int                        m_SplineOrder; // User specified spline order (3rd or cubic is the default)
00168 
00169   typename CoefficientImageType::ConstPointer       m_Coefficients; // Spline coefficients  
00170 
00171 private:
00172   BSplineInterpolateImageFunction( const Self& ); //purposely not implemented
00174   void SetInterpolationWeights( const ContinuousIndexType & x, 
00175                                 const vnl_matrix<long> & EvaluateIndex, 
00176                                 vnl_matrix<double> & weights, 
00177                                 unsigned int splineOrder ) const;
00178 
00180   void SetDerivativeWeights( const ContinuousIndexType & x, 
00181                              const vnl_matrix<long> & EvaluateIndex, 
00182                              vnl_matrix<double> & weights, 
00183                              unsigned int splineOrder ) const;
00184 
00187   void GeneratePointsToIndex(  );
00188 
00190   void DetermineRegionOfSupport( vnl_matrix<long> & evaluateIndex, 
00191                                  const ContinuousIndexType & x, 
00192                                  unsigned int splineOrder ) const;
00193 
00196   void ApplyMirrorBoundaryConditions(vnl_matrix<long> & evaluateIndex, 
00197                                      unsigned int splineOrder) const;
00198 
00199 
00200   Iterator                  m_CIterator;    // Iterator for traversing spline coefficients.
00201   unsigned long             m_MaxNumberInterpolationPoints; // number of neighborhood points used for interpolation
00202   std::vector<IndexType>    m_PointsToIndex;  // Preallocation of interpolation neighborhood indicies
00203 
00204   CoefficientFilterPointer     m_CoefficientFilter;
00205   
00206 };
00207 
00208 } // namespace itk
00209 
00210 #ifndef ITK_MANUAL_INSTANTIATION
00211 #include "itkBSplineInterpolateImageFunction.txx"
00212 #endif
00213 
00214 #endif
00215 

Generated at Wed May 24 22:53:36 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000