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: 2007/01/16 15:44:15 $
00007   Version:   $Revision: 1.32 $
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:
00148 
00151   typedef SegmentationLevelSetImageFilter Self;
00152 
00155   itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
00156 
00158   typedef Image<TOutputPixelType, itkGetStaticConstMacro(InputImageDimension)> OutputImageType;
00159 
00161   typedef SparseFieldLevelSetImageFilter<TInputImage, OutputImageType> Superclass;
00162   typedef SmartPointer<Self>  Pointer;
00163   typedef SmartPointer<const Self>  ConstPointer;
00164 
00166   typedef typename Superclass::ValueType ValueType;
00167   typedef typename Superclass::IndexType IndexType;
00168   typedef typename Superclass::TimeStepType TimeStepType;
00169   typedef typename Superclass::InputImageType  InputImageType;
00170 
00172   typedef TFeatureImage FeatureImageType;
00173 
00175   typedef SegmentationLevelSetFunction<OutputImageType, FeatureImageType>
00176   SegmentationFunctionType;
00177 
00179   typedef typename SegmentationFunctionType::VectorImageType VectorImageType;
00180   typedef typename SegmentationFunctionType::ImageType       SpeedImageType;
00181 
00183   itkTypeMacro(SegmentationLevelSetImageFilter, SparseFieldLevelSetImageFilter);
00184 
00187   void SetMaximumIterations (unsigned int i)
00188   {
00189     itkWarningMacro("SetMaximumIterations is deprecated.  Please use SetNumberOfIterations instead.");
00190     this->SetNumberOfIterations(i);
00191   }
00192   unsigned int GetMaximumIterations()
00193   {
00194     itkWarningMacro("GetMaximumIterations is deprecated. Please use GetNumberOfIterations instead.");
00195     return this->GetNumberOfIterations();
00196   }
00198 
00201   virtual void SetFeatureImage(const FeatureImageType *f)
00202   {
00203     this->ProcessObject::SetNthInput( 1, const_cast< FeatureImageType * >(f) );
00204     m_SegmentationFunction->SetFeatureImage(f);
00205   }
00206   virtual FeatureImageType * GetFeatureImage()
00207   { return ( static_cast< FeatureImageType *>(this->ProcessObject::GetInput(1)) ); }
00209 
00212   virtual void SetInitialImage(InputImageType *f)
00213   {
00214     this->SetInput(f);
00215   }
00216 
00218   void SetInput2(const FeatureImageType *input)
00219      {
00220      this->SetFeatureImage( input );
00221      }
00222 
00226   void SetSpeedImage( SpeedImageType *s )
00227   {  m_SegmentationFunction->SetSpeedImage( s ); }
00228 
00232   void SetAdvectionImage( VectorImageType *v)
00233   { m_SegmentationFunction->SetAdvectionImage( v ); }
00234 
00237   virtual const SpeedImageType *GetSpeedImage() const
00238   { return m_SegmentationFunction->GetSpeedImage(); }
00239 
00242   virtual const VectorImageType *GetAdvectionImage() const
00243   { return m_SegmentationFunction->GetAdvectionImage(); }
00244 
00248   void SetUseNegativeFeaturesOn()
00249   {
00250     itkWarningMacro( << "SetUseNegativeFeaturesOn has been deprecated.  Please use ReverseExpansionDirectionOn() instead" );
00251     this->ReverseExpansionDirectionOn();
00252   }
00253   void SetUseNegativeFeaturesOff()
00254   {
00255     itkWarningMacro( << "SetUseNegativeFeaturesOff has been deprecated.  Please use ReverseExpansionDirectionOff() instead" );
00256     this->ReverseExpansionDirectionOff();
00257   }
00259 
00262   void SetUseNegativeFeatures( bool u )
00263   {
00264     itkWarningMacro( << "SetUseNegativeFeatures has been deprecated.  Please use SetReverseExpansionDirection instead" );
00265     if (u == true)
00266       {
00267       this->SetReverseExpansionDirection(false);
00268       }
00269     else
00270       {
00271       this->SetReverseExpansionDirection(true);
00272       }
00273   }
00274   bool GetUseNegativeFeatures() const
00275   {
00276     itkWarningMacro( << "GetUseNegativeFeatures has been deprecated.  Please use GetReverseExpansionDirection() instead" );
00277     if ( m_ReverseExpansionDirection == false)
00278       {
00279       return true;
00280       }
00281     else
00282       {
00283       return false;
00284       }
00285   }
00287 
00296   itkSetMacro(ReverseExpansionDirection, bool);
00297   itkGetMacro(ReverseExpansionDirection, bool);
00298   itkBooleanMacro(ReverseExpansionDirection);
00300 
00306   itkSetMacro(AutoGenerateSpeedAdvection, bool);
00307   itkGetMacro(AutoGenerateSpeedAdvection, bool);
00308   itkBooleanMacro(AutoGenerateSpeedAdvection);
00310 
00315   void SetFeatureScaling(ValueType v)
00316   {
00317     if (v != m_SegmentationFunction->GetPropagationWeight())
00318       {        
00319       this->SetPropagationScaling(v);
00320       }
00321     if (v != m_SegmentationFunction->GetAdvectionWeight())
00322       {
00323       this->SetAdvectionScaling(v);
00324       }
00325   }
00327 
00330   void SetPropagationScaling(ValueType v)
00331   {
00332     if (v != m_SegmentationFunction->GetPropagationWeight())
00333       {        
00334       m_SegmentationFunction->SetPropagationWeight(v);
00335       this->Modified();
00336       }
00337   }
00338   ValueType GetPropagationScaling() const
00339   {
00340     return m_SegmentationFunction->GetPropagationWeight();
00341   }
00343 
00346   void SetAdvectionScaling(ValueType v)
00347   {
00348     if (v != m_SegmentationFunction->GetAdvectionWeight())
00349       {        
00350       m_SegmentationFunction->SetAdvectionWeight(v);
00351       this->Modified();
00352       }
00353   }
00354   ValueType GetAdvectionScaling() const
00355   {
00356     return m_SegmentationFunction->GetAdvectionWeight();
00357   }
00359 
00363   void SetCurvatureScaling(ValueType v)
00364   {
00365     if (v != m_SegmentationFunction->GetCurvatureWeight())
00366       {        
00367       m_SegmentationFunction->SetCurvatureWeight(v);
00368       this->Modified();
00369       }
00370   }
00371   ValueType GetCurvatureScaling() const
00372   {
00373     return m_SegmentationFunction->GetCurvatureWeight();
00374   }
00376 
00377 
00379   void SetUseMinimalCurvature( bool b )
00380   {
00381     if ( m_SegmentationFunction->GetUseMinimalCurvature() != b)
00382       {
00383       m_SegmentationFunction->SetUseMinimalCurvature( b );
00384       this->Modified();
00385       }
00386   }
00387   bool GetUseMinimalCurvature() const
00388   {
00389     return m_SegmentationFunction->GetUseMinimalCurvature();
00390   }
00391   void UseMinimalCurvatureOn()
00392   {
00393     this->SetUseMinimalCurvature(true);
00394   }
00395   void UseMinimalCurvatureOff()
00396   {
00397     this->SetUseMinimalCurvature(false);
00398   }
00400 
00401   
00407   virtual void SetSegmentationFunction(SegmentationFunctionType *s)
00408   {
00409     m_SegmentationFunction = s; 
00410 
00411     typename SegmentationFunctionType::RadiusType r;
00412     r.Fill( 1 );
00413   
00414     m_SegmentationFunction->Initialize(r);
00415     this->SetDifferenceFunction(m_SegmentationFunction);
00416     this->Modified();
00417   }
00418 
00419   virtual SegmentationFunctionType *GetSegmentationFunction()
00420   { return m_SegmentationFunction; }
00421 
00422   
00427   void SetMaximumCurvatureTimeStep(double n)
00428   {
00429     if ( n != m_SegmentationFunction->GetMaximumCurvatureTimeStep() )
00430       {
00431       m_SegmentationFunction->SetMaximumCurvatureTimeStep(n);
00432       this->Modified();
00433       }
00434   }
00435   double GetMaximumCurvatureTimeStep() const
00436   {
00437     return m_SegmentationFunction->GetMaximumCurvatureTimeStep();
00438   }
00440 
00445   void SetMaximumPropagationTimeStep(double n)
00446   {
00447     if (n != m_SegmentationFunction->GetMaximumPropagationTimeStep() )
00448       {
00449       m_SegmentationFunction->SetMaximumPropagationTimeStep(n);
00450       this->Modified();
00451       }
00452   }
00453   double GetMaximumPropagationTimeStep() const
00454   {
00455     return m_SegmentationFunction->GetMaximumPropagationTimeStep();
00456   }
00458 
00462   void GenerateSpeedImage();
00463 
00467   void GenerateAdvectionImage();
00468 
00469 #ifdef ITK_USE_CONCEPT_CHECKING
00470 
00471   itkConceptMacro(OutputHasNumericTraitsCheck,
00472                   (Concept::HasNumericTraits<TOutputPixelType>));
00473 
00475 #endif
00476 
00477 protected:
00478   virtual ~SegmentationLevelSetImageFilter() {}
00479   SegmentationLevelSetImageFilter();
00480 
00481   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00482 
00484   virtual void InitializeIteration()
00485   {
00486     Superclass::InitializeIteration();
00487     // Estimate the progress of the filter
00488     this->SetProgress( (float) ((float)this->GetElapsedIterations()
00489                                 / (float)this->GetNumberOfIterations()) );
00490   }
00492 
00495   void GenerateData();
00496 
00499   bool m_ReverseExpansionDirection;
00500 
00505   bool m_AutoGenerateSpeedAdvection;
00506 
00507 private:
00508   SegmentationLevelSetImageFilter(const Self&); //purposely not implemented
00509   void operator=(const Self&); //purposely not implemented
00510 
00511   SegmentationFunctionType *m_SegmentationFunction;
00512 };
00513 
00514 } // end namespace itk
00515 
00516 #ifndef ITK_MANUAL_INSTANTIATION
00517 #include "itkSegmentationLevelSetImageFilter.txx"
00518 #endif
00519 
00520 #endif
00521 
00522 

Generated at Mon Mar 12 02:54:57 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000