ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkLevelSetEquationAdvectionTerm.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 
00019 #ifndef __itkLevelSetEquationAdvectionTerm_h
00020 #define __itkLevelSetEquationAdvectionTerm_h
00021 
00022 #include "itkLevelSetEquationTermBase.h"
00023 #include "itkZeroFluxNeumannBoundaryCondition.h"
00024 #include "itkConstNeighborhoodIterator.h"
00025 #include "itkVector.h"
00026 #include "vnl/vnl_matrix_fixed.h"
00027 
00028 namespace itk
00029 {
00050 template< class TInput, // Input image or mesh
00051           class TLevelSetContainer >
00052 class LevelSetEquationAdvectionTerm :
00053     public LevelSetEquationTermBase< TInput, TLevelSetContainer >
00054 {
00055 public:
00056   typedef LevelSetEquationAdvectionTerm                           Self;
00057   typedef SmartPointer< Self >                                    Pointer;
00058   typedef SmartPointer< const Self >                              ConstPointer;
00059   typedef LevelSetEquationTermBase< TInput, TLevelSetContainer >  Superclass;
00061 
00063   itkNewMacro( Self );
00064 
00066   itkTypeMacro( LevelSetEquationAdvectionTerm,
00067                 LevelSetEquationTermBase );
00068 
00069   typedef typename Superclass::InputImageType     InputImageType;
00070   typedef typename Superclass::InputImagePointer  InputImagePointer;
00071   typedef typename Superclass::InputPixelType     InputPixelType;
00072   typedef typename Superclass::InputPixelRealType InputPixelRealType;
00073 
00074   typedef typename Superclass::LevelSetContainerType      LevelSetContainerType;
00075   typedef typename Superclass::LevelSetContainerPointer   LevelSetContainerPointer;
00076   typedef typename Superclass::LevelSetType               LevelSetType;
00077   typedef typename Superclass::LevelSetPointer            LevelSetPointer;
00078   typedef typename Superclass::LevelSetOutputPixelType    LevelSetOutputPixelType;
00079   typedef typename Superclass::LevelSetOutputRealType     LevelSetOutputRealType;
00080   typedef typename Superclass::LevelSetInputIndexType     LevelSetInputIndexType;
00081   typedef typename Superclass::LevelSetGradientType       LevelSetGradientType;
00082   typedef typename Superclass::LevelSetHessianType        LevelSetHessianType;
00083   typedef typename Superclass::LevelSetIdentifierType     LevelSetIdentifierType;
00084   typedef typename Superclass::LevelSetDataType           LevelSetDataType;
00085 
00086   typedef typename Superclass::HeavisideType         HeavisideType;
00087   typedef typename Superclass::HeavisideConstPointer HeavisideConstPointer;
00088 
00089   itkStaticConstMacro(ImageDimension, unsigned int, InputImageType::ImageDimension);
00090 
00091   typedef LevelSetGradientType  VectorType;
00092 
00093   typedef Image< VectorType, itkGetStaticConstMacro(ImageDimension) > AdvectionImageType;
00094   typedef typename AdvectionImageType::Pointer                        AdvectionImagePointer;
00095 
00096 
00097   void SetAdvectionImage( AdvectionImageType* iImage );
00098   itkGetObjectMacro( AdvectionImage, AdvectionImageType );
00099 
00100   itkSetMacro( DerivativeSigma, LevelSetOutputRealType );
00101   itkGetMacro( DerivativeSigma, LevelSetOutputRealType );
00102 
00104   typedef ZeroFluxNeumannBoundaryCondition< InputImageType > DefaultBoundaryConditionType;
00105   typedef typename ConstNeighborhoodIterator< InputImageType >::RadiusType RadiusType;
00106   typedef ConstNeighborhoodIterator< InputImageType, DefaultBoundaryConditionType > NeighborhoodType;
00107 
00108   typedef Vector< LevelSetOutputRealType, itkGetStaticConstMacro(ImageDimension) > NeighborhoodScalesType;
00109 
00111   virtual void Update();
00112 
00114   virtual void InitializeParameters();
00115 
00117   virtual void Initialize( const LevelSetInputIndexType& );
00118 
00120   virtual void UpdatePixel( const LevelSetInputIndexType& iP,
00121                             const LevelSetOutputRealType& oldValue,
00122                             const LevelSetOutputRealType& newValue );
00123 
00124 protected:
00125   LevelSetEquationAdvectionTerm();
00126 
00127   virtual ~LevelSetEquationAdvectionTerm();
00128 
00129   AdvectionImagePointer m_AdvectionImage;
00130 
00133   VectorType AdvectionSpeed( const LevelSetInputIndexType& iP ) const;
00134 
00137   virtual LevelSetOutputRealType Value( const LevelSetInputIndexType& iP );
00138   virtual LevelSetOutputRealType Value( const LevelSetInputIndexType& iP,
00139                                         const LevelSetDataType& iData );
00141 
00142   LevelSetOutputRealType m_NeighborhoodScales[ImageDimension];
00143 
00144 private:
00145   LevelSetEquationAdvectionTerm( const Self& ); // purposely not implemented
00146   void operator = ( const Self& ); // purposely not implemented
00147 
00148   LevelSetOutputRealType m_DerivativeSigma;
00149 
00150   bool m_AutoGenerateAdvectionImage;
00151 
00152   void GenerateAdvectionImage();
00153 };
00154 
00155 }
00156 
00157 #ifndef ITK_MANUAL_INSTANTIATION
00158 #include "itkLevelSetEquationAdvectionTerm.hxx"
00159 #endif
00160 
00161 #endif
00162