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/09/21 20:05:09 $
00007   Version:   $Revision: 1.33 $
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 
00144 template <class TInputImage,
00145           class TFeatureImage,
00146           class TOutputPixelType = float >
00147 class ITK_EXPORT SegmentationLevelSetImageFilter
00148   : public SparseFieldLevelSetImageFilter<TInputImage, Image<TOutputPixelType,
00149                                      ::itk::GetImageDimension<TInputImage>::ImageDimension> >
00150 {
00151 public:
00152 
00155   typedef SegmentationLevelSetImageFilter Self;
00156 
00159   itkStaticConstMacro(InputImageDimension, unsigned int, TInputImage::ImageDimension);
00160 
00162   typedef Image<TOutputPixelType, itkGetStaticConstMacro(InputImageDimension)> OutputImageType;
00163 
00165   typedef SparseFieldLevelSetImageFilter<TInputImage, OutputImageType> Superclass;
00166   typedef SmartPointer<Self>  Pointer;
00167   typedef SmartPointer<const Self>  ConstPointer;
00168 
00170   typedef typename Superclass::ValueType ValueType;
00171   typedef typename Superclass::IndexType IndexType;
00172   typedef typename Superclass::TimeStepType TimeStepType;
00173   typedef typename Superclass::InputImageType  InputImageType;
00174 
00176   typedef TFeatureImage FeatureImageType;
00177 
00179   typedef SegmentationLevelSetFunction<OutputImageType, FeatureImageType>
00180   SegmentationFunctionType;
00181 
00183   typedef typename SegmentationFunctionType::VectorImageType VectorImageType;
00184   typedef typename SegmentationFunctionType::ImageType       SpeedImageType;
00185 
00187   itkTypeMacro(SegmentationLevelSetImageFilter, SparseFieldLevelSetImageFilter);
00188 
00191   void SetMaximumIterations (unsigned int i)
00192   {
00193     itkWarningMacro("SetMaximumIterations is deprecated.  Please use SetNumberOfIterations instead.");
00194     this->SetNumberOfIterations(i);
00195   }
00196   unsigned int GetMaximumIterations()
00197   {
00198     itkWarningMacro("GetMaximumIterations is deprecated. Please use GetNumberOfIterations instead.");
00199     return this->GetNumberOfIterations();
00200   }
00202 
00205   virtual void SetFeatureImage(const FeatureImageType *f)
00206   {
00207     this->ProcessObject::SetNthInput( 1, const_cast< FeatureImageType * >(f) );
00208     m_SegmentationFunction->SetFeatureImage(f);
00209   }
00210   virtual FeatureImageType * GetFeatureImage()
00211   { return ( static_cast< FeatureImageType *>(this->ProcessObject::GetInput(1)) ); }
00213 
00216   virtual void SetInitialImage(InputImageType *f)
00217   {
00218     this->SetInput(f);
00219   }
00220 
00222   void SetInput2(const FeatureImageType *input)
00223      {
00224      this->SetFeatureImage( input );
00225      }
00226 
00230   void SetSpeedImage( SpeedImageType *s )
00231   {  m_SegmentationFunction->SetSpeedImage( s ); }
00232 
00236   void SetAdvectionImage( VectorImageType *v)
00237   { m_SegmentationFunction->SetAdvectionImage( v ); }
00238 
00241   virtual const SpeedImageType *GetSpeedImage() const
00242   { return m_SegmentationFunction->GetSpeedImage(); }
00243 
00246   virtual const VectorImageType *GetAdvectionImage() const
00247   { return m_SegmentationFunction->GetAdvectionImage(); }
00248 
00252   void SetUseNegativeFeaturesOn()
00253   {
00254     itkWarningMacro( << "SetUseNegativeFeaturesOn has been deprecated.  Please use ReverseExpansionDirectionOn() instead" );
00255     this->ReverseExpansionDirectionOn();
00256   }
00257   void SetUseNegativeFeaturesOff()
00258   {
00259     itkWarningMacro( << "SetUseNegativeFeaturesOff has been deprecated.  Please use ReverseExpansionDirectionOff() instead" );
00260     this->ReverseExpansionDirectionOff();
00261   }
00263 
00266   void SetUseNegativeFeatures( bool u )
00267   {
00268     itkWarningMacro( << "SetUseNegativeFeatures has been deprecated.  Please use SetReverseExpansionDirection instead" );
00269     if (u == true)
00270       {
00271       this->SetReverseExpansionDirection(false);
00272       }
00273     else
00274       {
00275       this->SetReverseExpansionDirection(true);
00276       }
00277   }
00278   bool GetUseNegativeFeatures() const
00279   {
00280     itkWarningMacro( << "GetUseNegativeFeatures has been deprecated.  Please use GetReverseExpansionDirection() instead" );
00281     if ( m_ReverseExpansionDirection == false)
00282       {
00283       return true;
00284       }
00285     else
00286       {
00287       return false;
00288       }
00289   }
00291 
00300   itkSetMacro(ReverseExpansionDirection, bool);
00301   itkGetMacro(ReverseExpansionDirection, bool);
00302   itkBooleanMacro(ReverseExpansionDirection);
00304 
00310   itkSetMacro(AutoGenerateSpeedAdvection, bool);
00311   itkGetMacro(AutoGenerateSpeedAdvection, bool);
00312   itkBooleanMacro(AutoGenerateSpeedAdvection);
00314 
00319   void SetFeatureScaling(ValueType v)
00320   {
00321     if (v != m_SegmentationFunction->GetPropagationWeight())
00322       {        
00323       this->SetPropagationScaling(v);
00324       }
00325     if (v != m_SegmentationFunction->GetAdvectionWeight())
00326       {
00327       this->SetAdvectionScaling(v);
00328       }
00329   }
00331 
00334   void SetPropagationScaling(ValueType v)
00335   {
00336     if (v != m_SegmentationFunction->GetPropagationWeight())
00337       {        
00338       m_SegmentationFunction->SetPropagationWeight(v);
00339       this->Modified();
00340       }
00341   }
00342   ValueType GetPropagationScaling() const
00343   {
00344     return m_SegmentationFunction->GetPropagationWeight();
00345   }
00347 
00350   void SetAdvectionScaling(ValueType v)
00351   {
00352     if (v != m_SegmentationFunction->GetAdvectionWeight())
00353       {        
00354       m_SegmentationFunction->SetAdvectionWeight(v);
00355       this->Modified();
00356       }
00357   }
00358   ValueType GetAdvectionScaling() const
00359   {
00360     return m_SegmentationFunction->GetAdvectionWeight();
00361   }
00363 
00367   void SetCurvatureScaling(ValueType v)
00368   {
00369     if (v != m_SegmentationFunction->GetCurvatureWeight())
00370       {        
00371       m_SegmentationFunction->SetCurvatureWeight(v);
00372       this->Modified();
00373       }
00374   }
00375   ValueType GetCurvatureScaling() const
00376   {
00377     return m_SegmentationFunction->GetCurvatureWeight();
00378   }
00380 
00381 
00383   void SetUseMinimalCurvature( bool b )
00384   {
00385     if ( m_SegmentationFunction->GetUseMinimalCurvature() != b)
00386       {
00387       m_SegmentationFunction->SetUseMinimalCurvature( b );
00388       this->Modified();
00389       }
00390   }
00391   bool GetUseMinimalCurvature() const
00392   {
00393     return m_SegmentationFunction->GetUseMinimalCurvature();
00394   }
00395   void UseMinimalCurvatureOn()
00396   {
00397     this->SetUseMinimalCurvature(true);
00398   }
00399   void UseMinimalCurvatureOff()
00400   {
00401     this->SetUseMinimalCurvature(false);
00402   }
00404 
00405   
00411   virtual void SetSegmentationFunction(SegmentationFunctionType *s)
00412   {
00413     m_SegmentationFunction = s; 
00414 
00415     typename SegmentationFunctionType::RadiusType r;
00416     r.Fill( 1 );
00417   
00418     m_SegmentationFunction->Initialize(r);
00419     this->SetDifferenceFunction(m_SegmentationFunction);
00420     this->Modified();
00421   }
00422 
00423   virtual SegmentationFunctionType *GetSegmentationFunction()
00424   { return m_SegmentationFunction; }
00425 
00426   
00431   void SetMaximumCurvatureTimeStep(double n)
00432   {
00433     if ( n != m_SegmentationFunction->GetMaximumCurvatureTimeStep() )
00434       {
00435       m_SegmentationFunction->SetMaximumCurvatureTimeStep(n);
00436       this->Modified();
00437       }
00438   }
00439   double GetMaximumCurvatureTimeStep() const
00440   {
00441     return m_SegmentationFunction->GetMaximumCurvatureTimeStep();
00442   }
00444 
00449   void SetMaximumPropagationTimeStep(double n)
00450   {
00451     if (n != m_SegmentationFunction->GetMaximumPropagationTimeStep() )
00452       {
00453       m_SegmentationFunction->SetMaximumPropagationTimeStep(n);
00454       this->Modified();
00455       }
00456   }
00457   double GetMaximumPropagationTimeStep() const
00458   {
00459     return m_SegmentationFunction->GetMaximumPropagationTimeStep();
00460   }
00462 
00466   void GenerateSpeedImage();
00467 
00471   void GenerateAdvectionImage();
00472 
00473 #ifdef ITK_USE_CONCEPT_CHECKING
00474 
00475   itkConceptMacro(OutputHasNumericTraitsCheck,
00476                   (Concept::HasNumericTraits<TOutputPixelType>));
00477 
00479 #endif
00480 
00481 protected:
00482   virtual ~SegmentationLevelSetImageFilter() {}
00483   SegmentationLevelSetImageFilter();
00484 
00485   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00486 
00488   virtual void InitializeIteration()
00489   {
00490     Superclass::InitializeIteration();
00491     // Estimate the progress of the filter
00492     this->SetProgress( (float) ((float)this->GetElapsedIterations()
00493                                 / (float)this->GetNumberOfIterations()) );
00494   }
00496 
00499   void GenerateData();
00500 
00503   bool m_ReverseExpansionDirection;
00504 
00509   bool m_AutoGenerateSpeedAdvection;
00510 
00511 private:
00512   SegmentationLevelSetImageFilter(const Self&); //purposely not implemented
00513   void operator=(const Self&); //purposely not implemented
00514 
00515   SegmentationFunctionType *m_SegmentationFunction;
00516 };
00517 
00518 } // end namespace itk
00519 
00520 #ifndef ITK_MANUAL_INSTANTIATION
00521 #include "itkSegmentationLevelSetImageFilter.txx"
00522 #endif
00523 
00524 #endif
00525 
00526 

Generated at Sun Sep 23 14:12:47 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000