KWStyle - itkSegmentationLevelSetFunction.h
 
Matrix View
Description

1 /*=========================================================================
2
3   Program:   Insight Segmentation & Registration Toolkit
4   Module:    $RCSfile: itkSegmentationLevelSetFunction.h.html,v $
5   Language:  C++
6   Date:      $Date: 2006/01/17 19:15:47 $
7   Version:   $Revision: 1.4 $
8
9   Copyright (c) Insight Software Consortium. All rights reserved.
10   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11
12      This software is distributed WITHOUT ANY WARRANTY; without even 
13      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
14      PURPOSE.  See the above copyright notices for more information.
15
16 =========================================================================*/
17 DEF #ifndef __itkSegmentationLevelSetFunction_h_
18 DEF #define __itkSegmentationLevelSetFunction_h_
19
20 #include "itkLevelSetFunction.h"
21 #include "itkLinearInterpolateImageFunction.h"
22 #include "itkVectorLinearInterpolateImageFunction.h"
23 #include "itkVectorCastImageFilter.h"
24
25 namespace itk {
26
27 /** \class SegmentationLevelSetFunction
28
29 IND **\par
30 IND **This object defines the API for a class of function objects which perform
31 IND **level set based segmentations.  The SegmentationLevelSetImageFilter objects
32 IND **use these SegmentationLevelSetFunction objects to perform the numerical
33 IND **calculations which move a level set front to lock onto image features.
34
35 IND **\par
36 IND **In order to create a working function object, you must subclass the
37 IND **CalculateSpeedImage method to produce a "feature image" that is used by the
38 IND **parent LevelSetFunction class as the PropagationSpeed for its calculations.
39
40 IND **\sa SegmentationLevelSetImageFilter
41 IND **\sa LevelSetFunction
42 IND */
43   
44 template <class TImageType, class TFeatureImageType = TImageType>
45 class ITK_EXPORT SegmentationLevelSetFunction
46 IND **: public LevelSetFunction<TImageType>
47 {
48 public:
49   /** Standard class typedefs. */
50   typedef SegmentationLevelSetFunction Self;
51   typedef LevelSetFunction<TImageType> Superclass;
52 TDA   typedef SmartPointer<Self> Pointer;
53 TDA   typedef SmartPointer<const Self> ConstPointer;
54
55   /** Run-time type information (and related methods) */
56   itkTypeMacro( SegmentationLevelSetFunction, LevelSetFunction );
57
58   /** Extract some parameters from the superclass. */
59   typedef typename Superclass::ImageType ImageType;
60 TDA   typedef typename Superclass::RadiusType RadiusType;
61 TDA   typedef TFeatureImageType FeatureImageType;
62 TDA   typedef typename Superclass::FloatOffsetType FloatOffsetType;
63 TDA   typedef typename Superclass::ScalarValueType ScalarValueType;
64 TDA   typedef typename Superclass::NeighborhoodType NeighborhoodType;
65 TDA   typedef typename FeatureImageType::PixelType FeatureScalarType;
66 TDA   typedef typename ImageType::IndexType IndexType;
67 TDA   typedef typename Superclass::VectorType VectorType;
68 TDA   typedef typename Superclass::GlobalDataStruct GlobalDataStruct;
69
70   /** Extract some parameters from the superclass. */
71   itkStaticConstMacro(ImageDimension, unsigned int,Superclass::ImageDimension);
72
73   /** Define an image type for the advection field. */
74 LEN   typedef Image<VectorType, itkGetStaticConstMacro(ImageDimension)> VectorImageType;
75
76
77   /** Define a scalar interpolator */
78   typedef LinearInterpolateImageFunction<ImageType>  InterpolatorType;
79
80   /** Define a vector interpolator */
81 LEN   typedef VectorLinearInterpolateImageFunction<VectorImageType> VectorInterpolatorType;
82   
83   /** Continuous index type recognized by the interpolator */
84   typedef typename InterpolatorType::ContinuousIndexType ContinuousIndexType;
85   
86   /** Set/Get the image which will be used to calculate the speed function. */
87   virtual const FeatureImageType *GetFeatureImage() const
88 IND **{ return m_FeatureImage.GetPointer(); }
89   virtual void SetFeatureImage(const FeatureImageType *f)
90 IND **{    m_FeatureImage = f;  }
91   
92   /** Get/Set the image used as the speed function in the level set equation */
93   virtual ImageType *GetSpeedImage() 
94 IND **{ return m_SpeedImage.GetPointer(); }
95   void SetSpeedImage( ImageType *s );
96   
97   /** Get/Set the image used as the advection field in the level set equation */
98   virtual VectorImageType *GetAdvectionImage() const
99 IND **{ return m_AdvectionImage.GetPointer(); } 
100   void SetAdvectionImage( VectorImageType *s );
101   
102   
103   /** This method creates the appropriate member variable operators for the
104    * level-set calculations.  The argument to this function is a the radius
105    * necessary for performing the level-set calculations. */
106   virtual void Initialize(const RadiusType &r);
107
108   /** This method must be defined in a subclass to implement a working function
109    * object.  This method is called before the solver begins its work to
110    * produce the speed image used as the level set function's Propagation speed
111    * term.  See LevelSetFunction for more information. */
112   virtual void CalculateSpeedImage() {}
113
114   /** This method must be defined in a subclass to implement a working function
115    * object.  This method is called before the solver begins its work to
116    * produce the speed image used as the level set function's Advection field
117    * term.  See LevelSetFunction for more information. */
118   virtual void CalculateAdvectionImage() {}
119
120   /** Allocates the image that will be used for the level set function's
121    * Propagation Speed term.  See LevelSetFunction for more information. */
122   virtual void AllocateSpeedImage();
123
124   /** Allocates the image that will be used for the level set function's
125    * Advection field term.  See LevelSetFunction for more information. */
126   virtual void AllocateAdvectionImage();
127
128   /** Determines whether Positive or Negative speed terms will cause surface
129    * expansion.  This method flips the sign of all of the speed, advection, etc
130    * terms.  By convention, filters should be written so that POSITIVE speed
131    * terms cause surface expansion.  Calling this method will
132    * toggle between the standard POSITIVE EXPANSION convention and the
133    * nonstandard NEGATIVE EXPANSION convention.
134    *
135    * IMPORTANT:  When adding terms to the level-set equation through
136    * subclassing you may need to override this function so that your new terms
137    * will be properly adjusted. */
138   virtual void ReverseExpansionDirection();
139   
140 protected:
141   /** The image whose features will be used to create a speed image */
142   typename FeatureImageType::ConstPointer m_FeatureImage;
143
144   /** The image holding the speed values for front propagation */
145   typename ImageType::Pointer        m_SpeedImage;
146
147   /** The image holding the advection field for front propation */
148   typename VectorImageType::Pointer  m_AdvectionImage;
149
150   /** A casting functor to convert between vector types.  */
151   Functor::VectorCast< ITK_TYPENAME VectorInterpolatorType::OutputType,
152                        VectorType > m_VectorCast;
153
154   /** Returns the propagation speed from the precalculated speed image.*/
155   virtual ScalarValueType PropagationSpeed(const NeighborhoodType &,
156 LEN                                            const FloatOffsetType &, GlobalDataStruct *gd) const;
157
158   /** Advection field.  Returns a vector from the computed advectionfield.*/
159   virtual VectorType AdvectionField(const NeighborhoodType &,
160 LEN                                     const FloatOffsetType &, GlobalDataStruct *gd) const;
161   
162   
163   virtual ~SegmentationLevelSetFunction() {}
164   SegmentationLevelSetFunction()
165 IND **{
166     m_SpeedImage = ImageType::New();
167     m_AdvectionImage = VectorImageType::New();
168     m_Interpolator = InterpolatorType::New();
169     m_VectorInterpolator = VectorInterpolatorType::New();
170 IND **}
171
172   typename InterpolatorType::Pointer m_Interpolator;
173   typename VectorInterpolatorType::Pointer m_VectorInterpolator;
174   
175 };
176
177 // end namespace
178
179 #ifndef ITK_MANUAL_INSTANTIATION
180 #include "itkSegmentationLevelSetFunction.txx"
181 #endif
182
183 #endif
184

Generated by KWStyle 1.0b on Tuesday January,17 at 02:14:45PM
© Kitware Inc.