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 "itkMultiOrderBSplineDecompositionImageFilter.h"
00044 #include "itkConceptChecking.h"
00045 #include "itkCovariantVector.h"
00046 
00047 namespace itk
00048 {
00083 template <
00084   class TImageType,
00085   class TCoordRep = double,
00086   class TCoefficientType = double >
00087 class ITK_EXPORT ReducedDimensionBSplineInterpolateImageFunction :
00088     public InterpolateImageFunction<TImageType,TCoordRep>
00089 {
00090 public:
00092   typedef ReducedDimensionBSplineInterpolateImageFunction  Self;
00093   typedef InterpolateImageFunction<TImageType,TCoordRep>   Superclass;
00094   typedef SmartPointer<Self>                               Pointer;
00095   typedef SmartPointer<const Self>                         ConstPointer;
00096 
00098   itkTypeMacro(ReducedDimensionBSplineInterpolateImageFunction, InterpolateImageFunction);
00099 
00100 
00102   itkNewMacro( Self );
00103 
00105   typedef typename Superclass::OutputType OutputType;
00106 
00108   typedef typename Superclass::InputImageType InputImageType;
00109 
00111   itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
00112 
00114   typedef typename Superclass::IndexType IndexType;
00115 
00117   typedef typename Superclass::ContinuousIndexType ContinuousIndexType;
00118 
00120   typedef typename Superclass::PointType PointType;
00121 
00123   typedef ImageLinearIteratorWithIndex<TImageType> Iterator;
00124 
00126   typedef TCoefficientType CoefficientDataType;
00127   typedef Image<CoefficientDataType,
00128                      itkGetStaticConstMacro(ImageDimension)
00129     >                      CoefficientImageType;
00130 
00132   typedef MultiOrderBSplineDecompositionImageFilter<TImageType, CoefficientImageType>
00133   CoefficientFilter;
00134 
00135   typedef typename CoefficientFilter::Pointer CoefficientFilterPointer;
00136 
00145   virtual OutputType EvaluateAtContinuousIndex(
00146     const ContinuousIndexType & index ) const;
00147 
00149   typedef CovariantVector<OutputType,
00150                           itkGetStaticConstMacro(ImageDimension)
00151     > CovariantVectorType;
00152 
00153   CovariantVectorType EvaluateDerivative( const PointType & point ) const
00154     {
00155     ContinuousIndexType index;
00156     this->GetInputImage()->TransformPhysicalPointToContinuousIndex( point, index );
00157     return ( this->EvaluateDerivativeAtContinuousIndex( index ) );
00158     }
00159 
00160   CovariantVectorType EvaluateDerivativeAtContinuousIndex(
00161     const ContinuousIndexType & x ) const;
00162 
00163 
00166   void SetSplineOrder(unsigned int SplineOrder);
00167   itkGetConstMacro(SplineOrder, int);
00168 
00169 
00171   virtual void SetInputImage(const TImageType * inputData);
00172 
00173 
00186   itkSetMacro( UseImageDirection, bool );
00187   itkGetConstMacro( UseImageDirection, bool );
00188   itkBooleanMacro( UseImageDirection );
00189 
00190 
00191 protected:
00192   ReducedDimensionBSplineInterpolateImageFunction();
00193   virtual ~ReducedDimensionBSplineInterpolateImageFunction() {};
00194   void PrintSelf(std::ostream& os, Indent indent) const;
00195 
00196   // These are needed by the smoothing spline routine.
00197   std::vector<CoefficientDataType>    m_Scratch;        // temp storage for processing of Coefficients
00198   typename TImageType::SizeType       m_DataLength;  // Image size
00199   unsigned int                        m_SplineOrder; // User specified spline order (3rd or cubic is the default)
00200 
00201   typename CoefficientImageType::ConstPointer       m_Coefficients; // Spline coefficients
00202 
00203 private:
00204   ReducedDimensionBSplineInterpolateImageFunction( const Self& ); //purposely not implemented
00205   void operator=( const Self& ); //purposely not implemented
00206 
00208   void SetInterpolationWeights( const ContinuousIndexType & x,
00209                                 const vnl_matrix<long> & EvaluateIndex,
00210                                 vnl_matrix<double> & weights,
00211                                 unsigned int splineOrder ) const;
00212 
00214   void SetDerivativeWeights( const ContinuousIndexType & x,
00215                              const vnl_matrix<long> & EvaluateIndex,
00216                              vnl_matrix<double> & weights,
00217                              unsigned int splineOrder ) const;
00218 
00221   void GeneratePointsToIndex(  );
00222 
00224   void DetermineRegionOfSupport( vnl_matrix<long> & evaluateIndex,
00225                                  const ContinuousIndexType & x,
00226                                  unsigned int splineOrder ) const;
00227 
00230   void ApplyMirrorBoundaryConditions(vnl_matrix<long> & evaluateIndex,
00231                                      unsigned int splineOrder) const;
00232 
00233 
00234   Iterator                  m_CIterator;    // Iterator for traversing spline coefficients.
00235   unsigned long             m_MaxNumberInterpolationPoints; // number of neighborhood points used for interpolation
00236   std::vector<IndexType>    m_PointsToIndex;  // Preallocation of interpolation neighborhood indicies
00237 
00238   CoefficientFilterPointer     m_CoefficientFilter;
00239 
00240   // flag to take or not the image direction into account when computing the
00241   // derivatives.
00242   bool m_UseImageDirection;
00243 
00244 };
00245 
00246 } // namespace itk
00247 
00248 #ifndef ITK_MANUAL_INSTANTIATION
00249 #include "itkReducedDimensionBSplineInterpolateImageFunction.txx"
00250 #endif
00251 
00252 #endif


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