go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkReducedDimensionBSplineInterpolateImageFunction.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 
00015 /*=========================================================================
00016 
00017   Program:   Insight Segmentation & Registration Toolkit
00018   Module:    $RCSfile: itkReducedDimBSplineInterpolateImageFunction.h,v $
00019   Language:  C++
00020   Date:      $Date: 2009-04-25 12:27:05 $
00021   Version:   $Revision: 1.24 $
00022 
00023   Copyright (c) Insight Software Consortium. All rights reserved.
00024   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00025 
00026   Portions of this code are covered under the VTK copyright.
00027   See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details.
00028 
00029      This software is distributed WITHOUT ANY WARRANTY; without even
00030      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00031      PURPOSE.  See the above copyright notices for more information.
00032 
00033 =========================================================================*/
00034 #ifndef __itkReducedDimensionBSplineInterpolateImageFunction_h
00035 #define __itkReducedDimensionBSplineInterpolateImageFunction_h
00036 
00037 #include <vector>
00038 
00039 #include "itkImageLinearIteratorWithIndex.h"
00040 #include "itkInterpolateImageFunction.h"
00041 #include "vnl/vnl_matrix.h"
00042 
00043 #include "itkBSplineDecompositionImageFilter.h"
00044 #include "itkConceptChecking.h"
00045 #include "itkCovariantVector.h"
00046 
00047 namespace itk
00048 {
00082 template <
00083   class TImageType,
00084   class TCoordRep = double,
00085   class TCoefficientType = double >
00086 class ITK_EXPORT ReducedDimensionBSplineInterpolateImageFunction :
00087     public InterpolateImageFunction<TImageType,TCoordRep>
00088 {
00089 public:
00091   typedef ReducedDimensionBSplineInterpolateImageFunction  Self;
00092   typedef InterpolateImageFunction<TImageType,TCoordRep>   Superclass;
00093   typedef SmartPointer<Self>                               Pointer;
00094   typedef SmartPointer<const Self>                         ConstPointer;
00095 
00097   itkTypeMacro(ReducedDimensionBSplineInterpolateImageFunction, InterpolateImageFunction);
00098 
00099 
00101   itkNewMacro( Self );
00102 
00104   typedef typename Superclass::OutputType OutputType;
00105 
00107   typedef typename Superclass::InputImageType InputImageType;
00108 
00110   itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00111 
00113   typedef typename Superclass::IndexType IndexType;
00114 
00116   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00117 
00119   typedef typename Superclass::PointType PointType;
00120 
00122   typedef ImageLinearIteratorWithIndex<TImageType> Iterator;
00123 
00125   typedef TCoefficientType CoefficientDataType;
00126   typedef Image<CoefficientDataType,
00127                      itkGetStaticConstMacro(ImageDimension)
00128     >                      CoefficientImageType;
00129 
00131   typedef BSplineDecompositionImageFilter<TImageType, CoefficientImageType>
00132   CoefficientFilter;
00133 
00134   typedef typename CoefficientFilter::Pointer CoefficientFilterPointer;
00135 
00144   virtual OutputType EvaluateAtContinuousIndex(
00145     const ContinuousIndexType & index ) const;
00146 
00148   typedef CovariantVector<OutputType,
00149                           itkGetStaticConstMacro(ImageDimension)
00150     > CovariantVectorType;
00151 
00152   CovariantVectorType EvaluateDerivative( const PointType & point ) const
00153     {
00154     ContinuousIndexType index;
00155     this->GetInputImage()->TransformPhysicalPointToContinuousIndex( point, index );
00156     return ( this->EvaluateDerivativeAtContinuousIndex( index ) );
00157     }
00158 
00159   CovariantVectorType EvaluateDerivativeAtContinuousIndex(
00160     const ContinuousIndexType & x ) const;
00161 
00162 
00165   void SetSplineOrder(unsigned int SplineOrder);
00166   itkGetConstMacro(SplineOrder, int);
00167 
00168 
00170   virtual void SetInputImage(const TImageType * inputData);
00171 
00172 
00185   itkSetMacro( UseImageDirection, bool );
00186   itkGetConstMacro( UseImageDirection, bool );
00187   itkBooleanMacro( UseImageDirection );
00188 
00189 
00190 protected:
00191   ReducedDimensionBSplineInterpolateImageFunction();
00192   virtual ~ReducedDimensionBSplineInterpolateImageFunction() {};
00193   void PrintSelf(std::ostream& os, Indent indent) const;
00194 
00195   // These are needed by the smoothing spline routine.
00196   std::vector<CoefficientDataType>    m_Scratch;        // temp storage for processing of Coefficients
00197   typename TImageType::SizeType       m_DataLength;  // Image size
00198   unsigned int                        m_SplineOrder; // User specified spline order (3rd or cubic is the default)
00199 
00200   typename CoefficientImageType::ConstPointer       m_Coefficients; // Spline coefficients
00201 
00202 private:
00203   ReducedDimensionBSplineInterpolateImageFunction( const Self& ); //purposely not implemented
00204   void operator=( const Self& ); //purposely not implemented
00205 
00207   void SetInterpolationWeights( const ContinuousIndexType & x,
00208                                 const vnl_matrix<long> & EvaluateIndex,
00209                                 vnl_matrix<double> & weights,
00210                                 unsigned int splineOrder ) const;
00211 
00213   void SetDerivativeWeights( const ContinuousIndexType & x,
00214                              const vnl_matrix<long> & EvaluateIndex,
00215                              vnl_matrix<double> & weights,
00216                              unsigned int splineOrder ) const;
00217 
00220   void GeneratePointsToIndex(  );
00221 
00223   void DetermineRegionOfSupport( vnl_matrix<long> & evaluateIndex,
00224                                  const ContinuousIndexType & x,
00225                                  unsigned int splineOrder ) const;
00226 
00229   void ApplyMirrorBoundaryConditions(vnl_matrix<long> & evaluateIndex,
00230                                      unsigned int splineOrder) const;
00231 
00232 
00233   Iterator                  m_CIterator;    // Iterator for traversing spline coefficients.
00234   unsigned long             m_MaxNumberInterpolationPoints; // number of neighborhood points used for interpolation
00235   std::vector<IndexType>    m_PointsToIndex;  // Preallocation of interpolation neighborhood indicies
00236 
00237   CoefficientFilterPointer     m_CoefficientFilter;
00238 
00239   // flag to take or not the image direction into account when computing the
00240   // derivatives.
00241   bool m_UseImageDirection;
00242 
00243 };
00244 
00245 } // namespace itk
00246 
00247 #ifndef ITK_MANUAL_INSTANTIATION
00248 #include "itkReducedDimensionBSplineInterpolateImageFunction.txx"
00249 #endif
00250 
00251 #endif


Generated on 11-05-2011 for elastix by doxygen 1.7.4 elastix logo