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

itkBSplineScatteredDataPointSetToImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkBSplineScatteredDataPointSetToImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-10-10 12:16:55 $
00007   Version:   $Revision: 1.6 $
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      This software is distributed WITHOUT ANY WARRANTY; without even
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkBSplineScatteredDataPointSetToImageFilter_h
00018 #define __itkBSplineScatteredDataPointSetToImageFilter_h
00019 
00020 #include "itkPointSetToImageFilter.h"
00021 #include "itkCoxDeBoorBSplineKernelFunction.h"
00022 #include "itkFixedArray.h"
00023 #include "itkVariableSizeMatrix.h"
00024 #include "itkVector.h"
00025 #include "itkVectorContainer.h"
00026 
00027 #include "vnl/vnl_matrix.h"
00028 
00029 namespace itk
00030 {
00031 
00073 template <class TInputPointSet, class TOutputImage>
00074 class BSplineScatteredDataPointSetToImageFilter
00075 : public PointSetToImageFilter<TInputPointSet, TOutputImage>
00076 {
00077 public:
00078   typedef BSplineScatteredDataPointSetToImageFilter  Self;
00079   typedef PointSetToImageFilter
00080     <TInputPointSet, TOutputImage>                   Superclass;
00081   typedef SmartPointer<Self>                         Pointer;
00082   typedef SmartPointer<const Self>                   ConstPointer;
00083 
00085   itkNewMacro(Self);
00086 
00088   itkStaticConstMacro( ImageDimension, unsigned int,
00089                        TOutputImage::ImageDimension );
00090 
00091   typedef TOutputImage                               ImageType;
00092   typedef TInputPointSet                             PointSetType;
00093 
00095   typedef typename ImageType::PixelType              PixelType;
00096   typedef typename ImageType::RegionType             RegionType;
00097   typedef typename ImageType::SizeType               SizeType;
00098   typedef typename ImageType::IndexType              IndexType;
00099   typedef typename ImageType::PointType              ContinuousIndexType;
00100 
00102   typedef typename PointSetType::PointType           PointType;
00103   typedef typename PointSetType::PixelType           PointDataType;
00104   typedef typename PointSetType::PointDataContainer  PointDataContainerType;
00105 
00107   typedef float                                      RealType;
00108   typedef VectorContainer<unsigned, RealType>        WeightsContainerType;
00109   typedef Image<PointDataType,
00110     itkGetStaticConstMacro( ImageDimension )>        PointDataImageType;
00111   typedef Image<RealType,
00112     itkGetStaticConstMacro( ImageDimension )>        RealImageType;
00113   typedef FixedArray<unsigned,
00114     itkGetStaticConstMacro( ImageDimension )>        ArrayType;
00115   typedef VariableSizeMatrix<RealType>               GradientType;
00117 
00121   typedef CoxDeBoorBSplineKernelFunction<3>          KernelType;
00122 
00125   void SetNumberOfLevels( unsigned int );
00126   void SetNumberOfLevels( ArrayType );
00127   itkGetConstReferenceMacro( NumberOfLevels, ArrayType );
00128 
00129   void SetSplineOrder( unsigned int );
00130   void SetSplineOrder( ArrayType );
00131   itkGetConstReferenceMacro( SplineOrder, ArrayType );
00132 
00133   itkSetMacro( NumberOfControlPoints, ArrayType );
00134   itkGetConstReferenceMacro( NumberOfControlPoints, ArrayType );
00135   itkGetConstReferenceMacro( CurrentNumberOfControlPoints, ArrayType );
00136 
00137   itkSetMacro( CloseDimension, ArrayType );
00138   itkGetConstReferenceMacro( CloseDimension, ArrayType );
00139 
00140   itkSetMacro( GenerateOutputImage, bool );
00141   itkGetConstReferenceMacro( GenerateOutputImage, bool );
00142   itkBooleanMacro( GenerateOutputImage );
00143 
00144   void SetPointWeights( WeightsContainerType * weights );
00145 
00149   itkSetMacro( PhiLattice, typename PointDataImageType::Pointer );
00150   itkGetConstMacro( PhiLattice, typename PointDataImageType::Pointer );
00152 
00157   void EvaluateAtPoint( PointType, PointDataType & );
00158   void EvaluateAtIndex( IndexType, PointDataType & );
00159   void EvaluateAtContinuousIndex( ContinuousIndexType, PointDataType & );
00161 
00167   void Evaluate( PointType, PointDataType & );
00168 
00173   void EvaluateGradientAtPoint( PointType, GradientType & );
00174   void EvaluateGradientAtIndex( IndexType, GradientType & );
00175   void EvaluateGradientAtContinuousIndex( ContinuousIndexType, GradientType & );
00177 
00184   void EvaluateGradient( PointType, GradientType & );
00185 
00186 protected:
00187   BSplineScatteredDataPointSetToImageFilter();
00188   virtual ~BSplineScatteredDataPointSetToImageFilter();
00189   void PrintSelf( std::ostream& os, Indent indent ) const;
00190 
00191   void GenerateData();
00192 
00193 private:
00194 
00195   //purposely not implemented
00196   BSplineScatteredDataPointSetToImageFilter(const Self&);
00197   void operator=(const Self&);
00198 
00199   void GenerateControlLattice();
00200   void RefineControlLattice();
00201   void UpdatePointSet();
00202   void GenerateOutputImage();
00203   void GenerateOutputImageFast();
00204   void CollapsePhiLattice( PointDataImageType *,
00205                            PointDataImageType *,
00206                            RealType, unsigned int );
00207 
00208 
00209   bool                                           m_DoMultilevel;
00210   bool                                           m_GenerateOutputImage;
00211   bool                                           m_UsePointWeights;
00212   unsigned int                                   m_MaximumNumberOfLevels;
00213   unsigned int                                   m_CurrentLevel;
00214   ArrayType                                      m_NumberOfControlPoints;
00215   ArrayType                                      m_CurrentNumberOfControlPoints;
00216   ArrayType                                      m_CloseDimension;
00217   ArrayType                                      m_SplineOrder;
00218   ArrayType                                      m_NumberOfLevels;
00219   typename WeightsContainerType::Pointer         m_PointWeights;
00220   typename KernelType::Pointer                   m_Kernel[ImageDimension];
00221   typename PointDataImageType::Pointer           m_PhiLattice;
00222   typename PointDataImageType::Pointer           m_PsiLattice;
00223   typename PointDataContainerType::Pointer       m_InputPointData;
00224   typename PointDataContainerType::Pointer       m_OutputPointData;
00225 
00226   RealType                                       m_BSplineEpsilon;
00227 
00228   vnl_matrix<RealType>
00229     m_RefinedLatticeCoefficients[ImageDimension];
00230 
00231   inline typename RealImageType::IndexType
00232   NumberToIndex( unsigned int number, typename RealImageType::SizeType size )
00233     {
00234     typename RealImageType::IndexType k;
00235     k[0] = 1;
00236 
00237     for ( unsigned int i = 1; i < ImageDimension; i++ )
00238       {
00239       k[i] = size[ImageDimension-i-1]*k[i-1];
00240       }
00241     typename RealImageType::IndexType index;
00242     for ( unsigned int i = 0; i < ImageDimension; i++ )
00243       {
00244       index[ImageDimension-i-1]
00245         = static_cast<unsigned int>( number/k[ImageDimension-i-1] );
00246       number %= k[ImageDimension-i-1];
00247       }
00248     return index;
00249     }
00250 };
00251 
00252 } // end namespace itk
00253 
00254 #ifndef ITK_MANUAL_INSTANTIATION
00255 #include "itkBSplineScatteredDataPointSetToImageFilter.txx"
00256 #endif
00257 
00258 #endif
00259 

Generated at Wed Nov 5 20:42:11 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000