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

itkSegmentationLevelSetImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkSegmentationLevelSetImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2004/06/01 19:14:08 $
00007   Version:   $Revision: 1.28 $
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 __itkSegmentationLevelSetImageFilter_h_
00018 #define __itkSegmentationLevelSetImageFilter_h_
00019 
00020 #include "itkSparseFieldLevelSetImageFilter.h"
00021 #include "itkSegmentationLevelSetFunction.h"
00022 
00023 namespace itk {
00024 
00140 template <class TInputImage,
00141           class TFeatureImage,
00142           class TOutputPixelType = float >
00143 class ITK_EXPORT SegmentationLevelSetImageFilter
00144   : public SparseFieldLevelSetImageFilter<TInputImage, Image<TOutputPixelType,
00145                                      ::itk::GetImageDimension<TInputImage>::ImageDimension> >
00146 {
00147 public:
00150   typedef SegmentationLevelSetImageFilter Self;
00151 
00154   itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
00155 
00157   typedef Image<TOutputPixelType, itkGetStaticConstMacro(InputImageDimension)> OutputImageType;
00158   
00160   typedef SparseFieldLevelSetImageFilter<TInputImage, OutputImageType> Superclass;
00161   typedef SmartPointer<Self>  Pointer;
00162   typedef SmartPointer<const Self>  ConstPointer;
00163 
00165   typedef typename Superclass::ValueType ValueType;
00166   typedef typename Superclass::IndexType IndexType;
00167   typedef typename Superclass::TimeStepType TimeStepType;
00168   typedef typename Superclass::InputImageType  InputImageType;
00169 
00171   typedef TFeatureImage FeatureImageType;
00172 
00174   typedef SegmentationLevelSetFunction<OutputImageType, FeatureImageType>
00175   SegmentationFunctionType;
00176 
00178   typedef typename SegmentationFunctionType::VectorImageType VectorImageType;
00179   
00181   itkTypeMacro(SegmentationLevelSetImageFilter, SparseFieldLevelSetImageFilter);
00182 
00185   void SetMaximumIterations (unsigned int i)
00186   {
00187     itkWarningMacro("SetMaximumIterations is deprecated.  Please use SetNumberOfIterations instead.");
00188     this->SetNumberOfIterations(i);
00189   }
00190   unsigned int GetMaximumIterations()
00191   {
00192     itkWarningMacro("GetMaximumIterations is deprecated. Please use GetNumberOfIterations instead.");
00193     return this->GetNumberOfIterations();
00194   }
00195 
00198   virtual void SetFeatureImage(const FeatureImageType *f)
00199   {
00200     this->ProcessObject::SetNthInput( 1, const_cast< FeatureImageType * >(f) );
00201     m_SegmentationFunction->SetFeatureImage(f);
00202   }
00203   virtual FeatureImageType * GetFeatureImage()
00204   { return ( static_cast< FeatureImageType *>(this->ProcessObject::GetInput(1)) ); }
00205 
00208   virtual void SetInitialImage(InputImageType *f)
00209   {
00210     this->SetInput(f);
00211   }
00212 
00216   void SetSpeedImage( typename SegmentationFunctionType::ImageType *s)
00217   {  m_SegmentationFunction->SetSpeedImage( s ); }
00218 
00222   void SetAdvectionImage( typename SegmentationFunctionType::VectorImageType *v)
00223   { m_SegmentationFunction->SetAdvectionImage( v ); }
00224 
00227   virtual const typename SegmentationFunctionType::ImageType *GetSpeedImage() const
00228   { return m_SegmentationFunction->GetSpeedImage(); }
00229 
00232   virtual const typename SegmentationFunctionType::VectorImageType *GetAdvectionImage() const
00233   { return m_SegmentationFunction->GetAdvectionImage(); }
00234 
00238   void SetUseNegativeFeaturesOn()
00239   {
00240     itkWarningMacro( << "SetUseNegativeFeaturesOn has been deprecated.  Please use ReverseExpansionDirectionOn() instead" );
00241     this->ReverseExpansionDirectionOn();
00242   }
00243   void SetUseNegativeFeaturesOff()
00244   {
00245     itkWarningMacro( << "SetUseNegativeFeaturesOff has been deprecated.  Please use ReverseExpansionDirectionOff() instead" );
00246     this->ReverseExpansionDirectionOff();
00247   }
00248 
00251   void SetUseNegativeFeatures( bool u )
00252   {
00253     itkWarningMacro( << "SetUseNegativeFeatures has been deprecated.  Please use SetReverseExpansionDirection instead" );
00254     if (u == true)
00255       {
00256       this->SetReverseExpansionDirection(false);
00257       }
00258     else
00259       {
00260       this->SetReverseExpansionDirection(true);
00261       }
00262   }
00263   bool GetUseNegativeFeatures() const
00264   {
00265     itkWarningMacro( << "GetUseNegativeFeatures has been deprecated.  Please use GetReverseExpansionDirection() instead" );
00266     if ( m_ReverseExpansionDirection == false)
00267       {
00268       return true;
00269       }
00270     else
00271       {
00272       return false;
00273       }
00274   }
00275 
00284   itkSetMacro(ReverseExpansionDirection, bool);
00285   itkGetMacro(ReverseExpansionDirection, bool);
00286   itkBooleanMacro(ReverseExpansionDirection);
00287 
00293   itkSetMacro(AutoGenerateSpeedAdvection, bool);
00294   itkGetMacro(AutoGenerateSpeedAdvection, bool);
00295   itkBooleanMacro(AutoGenerateSpeedAdvection);
00296   
00301   void SetFeatureScaling(ValueType v)
00302   {
00303     if (v != m_SegmentationFunction->GetPropagationWeight())
00304       {        
00305       this->SetPropagationScaling(v);
00306       }
00307     if (v != m_SegmentationFunction->GetAdvectionWeight())
00308       {
00309       this->SetAdvectionScaling(v);
00310       }
00311   }
00312 
00315   void SetPropagationScaling(ValueType v)
00316   {
00317     if (v != m_SegmentationFunction->GetPropagationWeight())
00318       {        
00319       m_SegmentationFunction->SetPropagationWeight(v);
00320       this->Modified();
00321       }
00322   }
00323   ValueType GetPropagationScaling() const
00324   {
00325     return m_SegmentationFunction->GetPropagationWeight();
00326   }
00327 
00330   void SetAdvectionScaling(ValueType v)
00331   {
00332     if (v != m_SegmentationFunction->GetAdvectionWeight())
00333       {        
00334       m_SegmentationFunction->SetAdvectionWeight(v);
00335       this->Modified();
00336       }
00337   }
00338   ValueType GetAdvectionScaling() const
00339   {
00340     return m_SegmentationFunction->GetAdvectionWeight();
00341   }
00342 
00346   void SetCurvatureScaling(ValueType v)
00347   {
00348     if (v != m_SegmentationFunction->GetCurvatureWeight())
00349       {        
00350       m_SegmentationFunction->SetCurvatureWeight(v);
00351       this->Modified();
00352       }
00353   }
00354   ValueType GetCurvatureScaling() const
00355   {
00356     return m_SegmentationFunction->GetCurvatureWeight();
00357   }
00358 
00359 
00361   void SetUseMinimalCurvature( bool b )
00362   {
00363     if ( m_SegmentationFunction->GetUseMinimalCurvature() != b)
00364       {
00365       m_SegmentationFunction->SetUseMinimalCurvature( b );
00366       this->Modified();
00367       }
00368   }
00369   bool GetUseMinimalCurvature() const
00370   {
00371     return m_SegmentationFunction->GetUseMinimalCurvature();
00372   }
00373   void UseMinimalCurvatureOn()
00374   {
00375     this->SetUseMinimalCurvature(true);
00376   }
00377   void UseMinimalCurvatureOff()
00378   {
00379     this->SetUseMinimalCurvature(false);
00380   }
00381   
00382   
00388   virtual void SetSegmentationFunction(SegmentationFunctionType *s)
00389   {
00390     m_SegmentationFunction = s; 
00391   
00392     typename SegmentationFunctionType::RadiusType r;
00393     r.Fill( 1 );
00394   
00395     m_SegmentationFunction->Initialize(r);
00396     this->SetDifferenceFunction(m_SegmentationFunction);
00397     this->Modified();
00398   }
00399 
00400   virtual SegmentationFunctionType *GetSegmentationFunction()
00401   { return m_SegmentationFunction; }
00402 
00403   
00408   void SetMaximumCurvatureTimeStep(double n)
00409   {
00410     if ( n != m_SegmentationFunction->GetMaximumCurvatureTimeStep() )
00411       {
00412       m_SegmentationFunction->SetMaximumCurvatureTimeStep(n);
00413       this->Modified();
00414       }
00415   }
00416   double GetMaximumCurvatureTimeStep() const
00417   {
00418     return m_SegmentationFunction->GetMaximumCurvatureTimeStep();
00419   }
00420 
00425   void SetMaximumPropagationTimeStep(double n)
00426   {
00427     if (n != m_SegmentationFunction->GetMaximumPropagationTimeStep() )
00428       {
00429       m_SegmentationFunction->SetMaximumPropagationTimeStep(n);
00430       this->Modified();
00431       }
00432   }
00433   double GetMaximumPropagationTimeStep() const
00434   {
00435     return m_SegmentationFunction->GetMaximumPropagationTimeStep();
00436   }
00437 
00441   void GenerateSpeedImage();
00442 
00446   void GenerateAdvectionImage();
00447   
00448 protected:
00449   virtual ~SegmentationLevelSetImageFilter() {}
00450   SegmentationLevelSetImageFilter(const Self&);
00451   SegmentationLevelSetImageFilter();
00452 
00453   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00454 
00456   virtual void InitializeIteration()
00457   {
00458     Superclass::InitializeIteration();
00459     // Estimate the progress of the filter
00460     this->SetProgress( (float) ((float)this->GetElapsedIterations()
00461                                 / (float)this->GetNumberOfIterations()) );
00462   }
00463   
00466   void GenerateData();
00467 
00470   bool m_ReverseExpansionDirection;
00471 
00476   bool m_AutoGenerateSpeedAdvection;
00477   
00478 private:
00479   SegmentationFunctionType *m_SegmentationFunction;
00480 };
00481 
00482 } // end namespace itk
00483 
00484 #ifndef ITK_MANUAL_INSTANTIATION
00485 #include "itkSegmentationLevelSetImageFilter.txx"
00486 #endif
00487 
00488 #endif
00489 

Generated at Wed Mar 30 00:10:15 2005 for ITK by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2000