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: 2008-03-03 13:58:42 $
00007   Version:   $Revision: 1.34 $
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 
00139 template <class TInputImage,
00140           class TFeatureImage,
00141           class TOutputPixelType = float >
00142 class ITK_EXPORT SegmentationLevelSetImageFilter
00143   : public SparseFieldLevelSetImageFilter<TInputImage, Image<TOutputPixelType,
00144                                      ::itk::GetImageDimension<TInputImage>::ImageDimension> >
00145 {
00146 public:
00147 
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   typedef typename SegmentationFunctionType::ImageType       SpeedImageType;
00180 
00182   itkTypeMacro(SegmentationLevelSetImageFilter, SparseFieldLevelSetImageFilter);
00183 
00186   void SetMaximumIterations (unsigned int i)
00187   {
00188     itkWarningMacro("SetMaximumIterations is deprecated.  Please use SetNumberOfIterations instead.");
00189     this->SetNumberOfIterations(i);
00190   }
00191   unsigned int GetMaximumIterations()
00192   {
00193     itkWarningMacro("GetMaximumIterations is deprecated. Please use GetNumberOfIterations instead.");
00194     return this->GetNumberOfIterations();
00195   }
00197 
00200   virtual void SetFeatureImage(const FeatureImageType *f)
00201   {
00202     this->ProcessObject::SetNthInput( 1, const_cast< FeatureImageType * >(f) );
00203     m_SegmentationFunction->SetFeatureImage(f);
00204   }
00205   virtual FeatureImageType * GetFeatureImage()
00206   { return ( static_cast< FeatureImageType *>(this->ProcessObject::GetInput(1)) ); }
00208 
00211   virtual void SetInitialImage(InputImageType *f)
00212   {
00213     this->SetInput(f);
00214   }
00215 
00217   void SetInput2(const FeatureImageType *input)
00218      {
00219      this->SetFeatureImage( input );
00220      }
00221 
00225   void SetSpeedImage( SpeedImageType *s )
00226   {  m_SegmentationFunction->SetSpeedImage( s ); }
00227 
00231   void SetAdvectionImage( VectorImageType *v)
00232   { m_SegmentationFunction->SetAdvectionImage( v ); }
00233 
00236   virtual const SpeedImageType *GetSpeedImage() const
00237   { return m_SegmentationFunction->GetSpeedImage(); }
00238 
00241   virtual const VectorImageType *GetAdvectionImage() const
00242   { return m_SegmentationFunction->GetAdvectionImage(); }
00243 
00247   void SetUseNegativeFeaturesOn()
00248   {
00249     itkWarningMacro( << "SetUseNegativeFeaturesOn has been deprecated.  Please use ReverseExpansionDirectionOn() instead" );
00250     this->ReverseExpansionDirectionOn();
00251   }
00252   void SetUseNegativeFeaturesOff()
00253   {
00254     itkWarningMacro( << "SetUseNegativeFeaturesOff has been deprecated.  Please use ReverseExpansionDirectionOff() instead" );
00255     this->ReverseExpansionDirectionOff();
00256   }
00258 
00261   void SetUseNegativeFeatures( bool u )
00262   {
00263     itkWarningMacro( << "SetUseNegativeFeatures has been deprecated.  Please use SetReverseExpansionDirection instead" );
00264     if (u == true)
00265       {
00266       this->SetReverseExpansionDirection(false);
00267       }
00268     else
00269       {
00270       this->SetReverseExpansionDirection(true);
00271       }
00272   }
00273   bool GetUseNegativeFeatures() const
00274   {
00275     itkWarningMacro( << "GetUseNegativeFeatures has been deprecated.  Please use GetReverseExpansionDirection() instead" );
00276     if ( m_ReverseExpansionDirection == false)
00277       {
00278       return true;
00279       }
00280     else
00281       {
00282       return false;
00283       }
00284   }
00286 
00295   itkSetMacro(ReverseExpansionDirection, bool);
00296   itkGetMacro(ReverseExpansionDirection, bool);
00297   itkBooleanMacro(ReverseExpansionDirection);
00299 
00305   itkSetMacro(AutoGenerateSpeedAdvection, bool);
00306   itkGetMacro(AutoGenerateSpeedAdvection, bool);
00307   itkBooleanMacro(AutoGenerateSpeedAdvection);
00309 
00314   void SetFeatureScaling(ValueType v)
00315   {
00316     if (v != m_SegmentationFunction->GetPropagationWeight())
00317       {        
00318       this->SetPropagationScaling(v);
00319       }
00320     if (v != m_SegmentationFunction->GetAdvectionWeight())
00321       {
00322       this->SetAdvectionScaling(v);
00323       }
00324   }
00326 
00329   void SetPropagationScaling(ValueType v)
00330   {
00331     if (v != m_SegmentationFunction->GetPropagationWeight())
00332       {        
00333       m_SegmentationFunction->SetPropagationWeight(v);
00334       this->Modified();
00335       }
00336   }
00337   ValueType GetPropagationScaling() const
00338   {
00339     return m_SegmentationFunction->GetPropagationWeight();
00340   }
00342 
00345   void SetAdvectionScaling(ValueType v)
00346   {
00347     if (v != m_SegmentationFunction->GetAdvectionWeight())
00348       {        
00349       m_SegmentationFunction->SetAdvectionWeight(v);
00350       this->Modified();
00351       }
00352   }
00353   ValueType GetAdvectionScaling() const
00354   {
00355     return m_SegmentationFunction->GetAdvectionWeight();
00356   }
00358 
00362   void SetCurvatureScaling(ValueType v)
00363   {
00364     if (v != m_SegmentationFunction->GetCurvatureWeight())
00365       {        
00366       m_SegmentationFunction->SetCurvatureWeight(v);
00367       this->Modified();
00368       }
00369   }
00370   ValueType GetCurvatureScaling() const
00371   {
00372     return m_SegmentationFunction->GetCurvatureWeight();
00373   }
00375 
00376 
00378   void SetUseMinimalCurvature( bool b )
00379   {
00380     if ( m_SegmentationFunction->GetUseMinimalCurvature() != b)
00381       {
00382       m_SegmentationFunction->SetUseMinimalCurvature( b );
00383       this->Modified();
00384       }
00385   }
00386   bool GetUseMinimalCurvature() const
00387   {
00388     return m_SegmentationFunction->GetUseMinimalCurvature();
00389   }
00390   void UseMinimalCurvatureOn()
00391   {
00392     this->SetUseMinimalCurvature(true);
00393   }
00394   void UseMinimalCurvatureOff()
00395   {
00396     this->SetUseMinimalCurvature(false);
00397   }
00399 
00400   
00406   virtual void SetSegmentationFunction(SegmentationFunctionType *s)
00407   {
00408     m_SegmentationFunction = s; 
00409 
00410     typename SegmentationFunctionType::RadiusType r;
00411     r.Fill( 1 );
00412   
00413     m_SegmentationFunction->Initialize(r);
00414     this->SetDifferenceFunction(m_SegmentationFunction);
00415     this->Modified();
00416   }
00417 
00418   virtual SegmentationFunctionType *GetSegmentationFunction()
00419   { return m_SegmentationFunction; }
00420 
00421   
00426   void SetMaximumCurvatureTimeStep(double n)
00427   {
00428     if ( n != m_SegmentationFunction->GetMaximumCurvatureTimeStep() )
00429       {
00430       m_SegmentationFunction->SetMaximumCurvatureTimeStep(n);
00431       this->Modified();
00432       }
00433   }
00434   double GetMaximumCurvatureTimeStep() const
00435   {
00436     return m_SegmentationFunction->GetMaximumCurvatureTimeStep();
00437   }
00439 
00444   void SetMaximumPropagationTimeStep(double n)
00445   {
00446     if (n != m_SegmentationFunction->GetMaximumPropagationTimeStep() )
00447       {
00448       m_SegmentationFunction->SetMaximumPropagationTimeStep(n);
00449       this->Modified();
00450       }
00451   }
00452   double GetMaximumPropagationTimeStep() const
00453   {
00454     return m_SegmentationFunction->GetMaximumPropagationTimeStep();
00455   }
00457 
00461   void GenerateSpeedImage();
00462 
00466   void GenerateAdvectionImage();
00467 
00468 #ifdef ITK_USE_CONCEPT_CHECKING
00469 
00470   itkConceptMacro(OutputHasNumericTraitsCheck,
00471                   (Concept::HasNumericTraits<TOutputPixelType>));
00472 
00474 #endif
00475 
00476 protected:
00477   virtual ~SegmentationLevelSetImageFilter() {}
00478   SegmentationLevelSetImageFilter();
00479 
00480   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00481 
00483   virtual void InitializeIteration()
00484   {
00485     Superclass::InitializeIteration();
00486     // Estimate the progress of the filter
00487     this->SetProgress( (float) ((float)this->GetElapsedIterations()
00488                                 / (float)this->GetNumberOfIterations()) );
00489   }
00491 
00494   void GenerateData();
00495 
00498   bool m_ReverseExpansionDirection;
00499 
00504   bool m_AutoGenerateSpeedAdvection;
00505 
00506 private:
00507   SegmentationLevelSetImageFilter(const Self&); //purposely not implemented
00508   void operator=(const Self&); //purposely not implemented
00509 
00510   SegmentationFunctionType *m_SegmentationFunction;
00511 };
00512 
00513 } // end namespace itk
00514 
00515 #ifndef ITK_MANUAL_INSTANTIATION
00516 #include "itkSegmentationLevelSetImageFilter.txx"
00517 #endif
00518 
00519 #endif
00520 
00521 

Generated at Thu Nov 6 00:06:21 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000