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: 2010-03-02 19:26:09 $
00007   Version:   $Revision: 1.12 $
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 "itkBSplineKernelFunction.h"
00022 #include "itkCoxDeBoorBSplineKernelFunction.h"
00023 #include "itkFixedArray.h"
00024 #include "itkVariableSizeMatrix.h"
00025 #include "itkVector.h"
00026 #include "itkVectorContainer.h"
00027 
00028 #include "vnl/vnl_matrix.h"
00029 
00030 namespace itk
00031 {
00032 
00071 template <class TInputPointSet, class TOutputImage>
00072 class BSplineScatteredDataPointSetToImageFilter
00073 : public PointSetToImageFilter<TInputPointSet, TOutputImage>
00074 {
00075 public:
00076   typedef BSplineScatteredDataPointSetToImageFilter  Self;
00077   typedef PointSetToImageFilter
00078     <TInputPointSet, TOutputImage>                   Superclass;
00079   typedef SmartPointer<Self>                         Pointer;
00080   typedef SmartPointer<const Self>                   ConstPointer;
00081 
00083   itkNewMacro(Self);
00084 
00086   itkStaticConstMacro( ImageDimension, unsigned int,
00087     TOutputImage::ImageDimension );
00088 
00089   typedef TOutputImage                               ImageType;
00090   typedef TInputPointSet                             PointSetType;
00091 
00093   typedef typename ImageType::PixelType              PixelType;
00094   typedef typename ImageType::RegionType             RegionType;
00095   typedef typename ImageType::SizeType               SizeType;
00096   typedef typename ImageType::IndexType              IndexType;
00097   typedef typename ImageType::PointType              ContinuousIndexType;
00098 
00100   typedef typename PointSetType::PointType           PointType;
00101   typedef typename PointSetType::PixelType           PointDataType;
00102   typedef typename PointSetType::PointDataContainer  PointDataContainerType;
00103 
00105   typedef float                                      RealType;
00106   typedef VectorContainer<unsigned, RealType>        WeightsContainerType;
00107   typedef Image<PointDataType,
00108     itkGetStaticConstMacro( ImageDimension )>        PointDataImageType;
00109   typedef typename PointDataImageType::Pointer       PointDataImagePointer;
00110   typedef Image<RealType,
00111     itkGetStaticConstMacro( ImageDimension )>        RealImageType;
00112   typedef typename RealImageType::Pointer            RealImagePointer;
00113   typedef FixedArray<unsigned,
00114     itkGetStaticConstMacro( ImageDimension )>        ArrayType;
00115   typedef VariableSizeMatrix<RealType>               GradientType;
00117 
00121   typedef CoxDeBoorBSplineKernelFunction<3>          KernelType;
00122   typedef BSplineKernelFunction<0>                   KernelOrder0Type;
00123   typedef BSplineKernelFunction<1>                   KernelOrder1Type;
00124   typedef BSplineKernelFunction<2>                   KernelOrder2Type;
00125   typedef BSplineKernelFunction<3>                   KernelOrder3Type;
00126 
00129   void SetNumberOfLevels( unsigned int );
00130   void SetNumberOfLevels( ArrayType );
00131   itkGetConstReferenceMacro( NumberOfLevels, ArrayType );
00132 
00133   void SetSplineOrder( unsigned int );
00134   void SetSplineOrder( ArrayType );
00135   itkGetConstReferenceMacro( SplineOrder, ArrayType );
00136 
00137   itkSetMacro( NumberOfControlPoints, ArrayType );
00138   itkGetConstReferenceMacro( NumberOfControlPoints, ArrayType );
00139   itkGetConstReferenceMacro( CurrentNumberOfControlPoints, ArrayType );
00140 
00155   itkSetMacro( CloseDimension, ArrayType );
00156   itkGetConstReferenceMacro( CloseDimension, ArrayType );
00158 
00159   itkSetMacro( GenerateOutputImage, bool );
00160   itkGetConstReferenceMacro( GenerateOutputImage, bool );
00161   itkBooleanMacro( GenerateOutputImage );
00162 
00163   void SetPointWeights( WeightsContainerType * weights );
00164 
00168   itkSetMacro( PhiLattice, PointDataImagePointer );
00169   itkGetConstMacro( PhiLattice, PointDataImagePointer );
00171 
00176   void EvaluateAtPoint( PointType, PointDataType & );
00177   void EvaluateAtIndex( IndexType, PointDataType & );
00178   void EvaluateAtContinuousIndex( ContinuousIndexType, PointDataType & );
00180 
00186   void Evaluate( PointType, PointDataType & );
00187 
00192   void EvaluateGradientAtPoint( PointType, GradientType & );
00193   void EvaluateGradientAtIndex( IndexType, GradientType & );
00194   void EvaluateGradientAtContinuousIndex( ContinuousIndexType, GradientType & );
00196 
00203   void EvaluateGradient( PointType, GradientType & );
00204 
00205 protected:
00206   BSplineScatteredDataPointSetToImageFilter();
00207   virtual ~BSplineScatteredDataPointSetToImageFilter();
00208   void PrintSelf( std::ostream& os, Indent indent ) const;
00209 
00211   void ThreadedGenerateData( const RegionType&, int );
00212   void BeforeThreadedGenerateData();
00213   void AfterThreadedGenerateData();
00215 
00218   int SplitRequestedRegion(int, int, RegionType&)
00219     {
00220     return this->GetNumberOfThreads();
00221     }
00222 
00223   void GenerateData();
00224 
00225 private:
00226 
00227   //purposely not implemented
00228   BSplineScatteredDataPointSetToImageFilter(const Self&);
00229   void operator=(const Self&);
00230 
00231   void RefineControlPointLattice();
00232   void UpdatePointSet();
00233   void GenerateOutputImage();
00234   void GenerateOutputImageFast();
00235   void CollapsePhiLattice( PointDataImageType *, PointDataImageType *,
00236     RealType, unsigned int );
00237 
00238   bool                                           m_DoMultilevel;
00239   bool                                           m_GenerateOutputImage;
00240   bool                                           m_UsePointWeights;
00241   unsigned int                                   m_MaximumNumberOfLevels;
00242   unsigned int                                   m_CurrentLevel;
00243   ArrayType                                      m_NumberOfControlPoints;
00244   ArrayType                                      m_CurrentNumberOfControlPoints;
00245   ArrayType                                      m_CloseDimension;
00246   ArrayType                                      m_SplineOrder;
00247   ArrayType                                      m_NumberOfLevels;
00248   typename WeightsContainerType::Pointer         m_PointWeights;
00249   typename PointDataImageType::Pointer           m_PhiLattice;
00250   typename PointDataImageType::Pointer           m_PsiLattice;
00251   typename PointDataContainerType::Pointer       m_InputPointData;
00252   typename PointDataContainerType::Pointer       m_OutputPointData;
00253 
00254   typename KernelType::Pointer                   m_Kernel[ImageDimension];
00255   typename KernelOrder0Type::Pointer             m_KernelOrder0;
00256   typename KernelOrder1Type::Pointer             m_KernelOrder1;
00257   typename KernelOrder2Type::Pointer             m_KernelOrder2;
00258   typename KernelOrder3Type::Pointer             m_KernelOrder3;
00259 
00260   std::vector<RealImagePointer>                  m_OmegaLatticePerThread;
00261   std::vector<PointDataImagePointer>             m_DeltaLatticePerThread;
00262 
00263   RealType                                       m_BSplineEpsilon;
00264 
00265   vnl_matrix<RealType>
00266     m_RefinedLatticeCoefficients[ImageDimension];
00267 
00268   inline typename RealImageType::IndexType
00269   NumberToIndex( unsigned int number, typename RealImageType::SizeType size )
00270     {
00271     typename RealImageType::IndexType k;
00272     k[0] = 1;
00273 
00274     for ( unsigned int i = 1; i < ImageDimension; i++ )
00275       {
00276       k[i] = size[ImageDimension-i-1]*k[i-1];
00277       }
00278     typename RealImageType::IndexType index;
00279     for ( unsigned int i = 0; i < ImageDimension; i++ )
00280       {
00281       index[ImageDimension-i-1]
00282         = static_cast<unsigned int>( number/k[ImageDimension-i-1] );
00283       number %= k[ImageDimension-i-1];
00284       }
00285     return index;
00286     }
00287 };
00288 
00289 } // end namespace itk
00290 
00291 #ifndef ITK_MANUAL_INSTANTIATION
00292 #include "itkBSplineScatteredDataPointSetToImageFilter.txx"
00293 #endif
00294 
00295 #endif
00296 

Generated at Mon Jul 12 2010 17:59:34 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000