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: 2002/09/17 23:27:16 $
00007   Version:   $Revision: 1.1 $
00008 
00009   Copyright (c) 2002 Insight 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 
00032 namespace itk
00033 {
00067 template <class TImageType, class TCoordRep = float>
00068 class ITK_EXPORT BSplineInterpolateImageFunction : 
00069   public InterpolateImageFunction<TImageType,TCoordRep> 
00070 {
00071 public:
00073   typedef BSplineInterpolateImageFunction       Self;
00074   typedef InterpolateImageFunction<TImageType,TCoordRep>  Superclass;
00075   typedef SmartPointer<Self>                    Pointer;
00076   typedef SmartPointer<const Self>              ConstPointer;
00077 
00079   itkTypeMacro(BSplineInterpolateImageFunction, InterpolateImageFunction);
00080 
00081  
00083   itkNewMacro( Self );
00084 
00086   typedef typename Superclass::OutputType OutputType;
00087 
00089   typedef typename Superclass::InputImageType InputImageType;
00090 
00092   itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00093 
00095   typedef typename Superclass::IndexType IndexType;
00096 
00098   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00099 
00101   typedef typename Superclass::PointType PointType;
00102 
00104   typedef itk::ImageLinearIteratorWithIndex<TImageType> Iterator;
00105 
00107   /*** TODO:  Need to permit templating over a different output type. */
00108   typedef itk::BSplineDecompositionImageFilter<TImageType, TImageType> 
00109     CoefficientFilter;
00110   typedef typename CoefficientFilter::Pointer CoefficientFilterPointer;
00111 
00120   virtual OutputType EvaluateAtContinuousIndex( 
00121       const ContinuousIndexType & index ) const; 
00122 
00124   typedef CovariantVector<OutputType,itkGetStaticConstMacro(ImageDimension)>
00125       CovariantVectorType;
00126 
00127   CovariantVectorType EvaluateDerivative( const PointType & point )
00128     {    
00129     ContinuousIndexType index;
00130     this->ConvertPointToContinuousIndex( point, index );
00131     return ( this->EvaluateDerivativeAtContinuousIndex( index ) );
00132     }
00133 
00134   CovariantVectorType EvaluateDerivativeAtContinuousIndex( 
00135     const ContinuousIndexType & x ) const;
00136 
00137 
00140   void SetSplineOrder(unsigned int SplineOrder);
00141   itkGetMacro(SplineOrder, int);
00142 
00143 
00145   virtual void SetInputImage(const TImageType * inputData);
00146 
00147 protected:
00148   BSplineInterpolateImageFunction();
00149   virtual ~BSplineInterpolateImageFunction() {};
00150   void PrintSelf(std::ostream& os, Indent indent) const;
00151 
00152     // These are needed by the smoothing spline routine.
00153   std::vector<double>    m_Scratch;        // temp storage for processing of Coefficients
00154   typename TImageType::SizeType      m_DataLength;  // Image size
00155   unsigned int                       m_SplineOrder; // User specified spline order (3rd or cubic is the default)
00156   //TODO  Should these be double?
00157   typename TImageType::Pointer       m_Coefficients; // Spline coefficients  
00158 
00159 private:
00161   void SetInterpolationWeights( const ContinuousIndexType & x, 
00162     const vnl_matrix<long> & EvaluateIndex, 
00163     vnl_matrix<double> & weights, 
00164     unsigned int splineOrder ) const;
00165 
00167   void SetDerivativeWeights( const ContinuousIndexType & x, 
00168     const vnl_matrix<long> & EvaluateIndex, 
00169     vnl_matrix<double> & weights, 
00170     unsigned int splineOrder ) const;
00171 
00174   void GeneratePointsToIndex(  );
00175 
00177   void DetermineRegionOfSupport( vnl_matrix<long> & evaluateIndex, 
00178     const ContinuousIndexType & x, 
00179     unsigned int splineOrder ) const;
00180 
00183   void ApplyMirrorBoundaryConditions(vnl_matrix<long> & evaluateIndex, 
00184     unsigned int splineOrder) const;
00185 
00186 
00187   Iterator                  m_CIterator;    // Iterator for traversing spline coefficients.
00188   unsigned long             m_MaxNumberInterpolationPoints; // number of neighborhood points used for interpolation
00189   std::vector<IndexType>    m_PointsToIndex;  // Preallocation of interpolation neighborhood indicies
00190 
00191   BSplineInterpolateImageFunction( const Self& ); //purposely not implemented
00192   void operator=( const Self& ); //purposely not implemented
00193   CoefficientFilterPointer     m_CoefficientFilter;
00194   
00195 };
00196 
00197 } // namespace itk
00198 
00199 #ifndef ITK_MANUAL_INSTANTIATION
00200 #include "itkBSplineInterpolateImageFunction.txx"
00201 #endif
00202 
00203 #endif
00204 

Generated at Wed Mar 12 01:12:49 2003 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000