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

itkWatershedImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkWatershedImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2005/01/12 23:09:39 $
00007   Version:   $Revision: 1.42 $
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 __itkWatershedImageFilter_h
00018 #define __itkWatershedImageFilter_h
00019 
00020 #if defined(_MSC_VER)
00021 #pragma warning ( disable : 4786 )
00022 #endif
00023 
00024 #include "itkImageToImageFilter.h"
00025 #include "itkImage.h"
00026 #include "itkWatershedSegmenter.h"
00027 #include "itkWatershedSegmentTreeGenerator.h"
00028 #include "itkWatershedRelabeler.h"
00029 #include "itkWatershedMiniPipelineProgressCommand.h"
00030 
00031 namespace itk
00032 {
00151 template <class TInputImage>
00152 class ITK_EXPORT WatershedImageFilter :
00153     public ImageToImageFilter< TInputImage, Image<unsigned long,
00154                                                   ::itk::GetImageDimension<TInputImage>::ImageDimension> >
00155 {
00156 public:
00158   typedef WatershedImageFilter Self;
00159 
00161   typedef TInputImage InputImageType;
00162 
00164   itkStaticConstMacro (ImageDimension, unsigned int,
00165                        TInputImage::ImageDimension);
00166   
00168   typedef Image<unsigned long, itkGetStaticConstMacro(ImageDimension)> OutputImageType;
00169 
00171   typedef typename InputImageType::RegionType RegionType;
00172   typedef typename InputImageType::SizeType   SizeType;
00173   typedef typename InputImageType::IndexType  IndexType;
00174   
00176   typedef ImageToImageFilter< InputImageType, OutputImageType > Superclass;
00177 
00179   typedef typename InputImageType::PixelType ScalarType;
00180 
00182   typedef SmartPointer<Self> Pointer;
00183 
00185   itkTypeMacro(WatershedImageFilter, ImageToImageFilter);
00186   
00188   itkNewMacro(Self);
00189 
00191   void GenerateData();
00192 
00195   void SetInput(const InputImageType *input)
00196     {
00197     // if the input is changed, we'll need to clear the cached tree
00198     // when we execute
00199     if (input != this->GetInput(0))
00200       {
00201       m_InputChanged = true;
00202       }
00203       
00204     // processObject is not const-correct so a const_cast is needed here
00205     this->ProcessObject::SetNthInput(0, const_cast<InputImageType *>(input));
00206     m_Segmenter->SetInputImage( const_cast<InputImageType *>( input ) );
00207     }
00208 
00209   virtual void SetInput( unsigned int i, const TInputImage * image)
00210   {
00211     if (i != 0)
00212       { itkExceptionMacro(<< "Filter has only one input."); }
00213     else
00214       { this->SetInput(image); }
00215   }
00218   void SetThreshold(double);
00219   itkGetMacro(Threshold, double);
00220   
00223   void SetLevel(double);
00224   itkGetMacro(Level, double);
00225 
00227   typename watershed::Segmenter<InputImageType>::OutputImageType *
00228   GetBasicSegmentation()
00229   {
00230     m_Segmenter->Update();
00231     return m_Segmenter->GetOutputImage();
00232   }
00233 
00235   typename watershed::SegmentTreeGenerator<ScalarType>::SegmentTreeType *
00236   GetSegmentTree()
00237   {
00238     return m_TreeGenerator->GetOutputSegmentTree();
00239   }
00240    
00241   // Override since the filter produces all of its output
00242   void EnlargeOutputRequestedRegion(DataObject *data);
00243 
00244 protected:
00245   WatershedImageFilter();
00246   virtual ~WatershedImageFilter() {}
00247   WatershedImageFilter(const Self&) {}
00248   void operator=(const Self&) {}
00249   void PrintSelf(std::ostream& os, Indent indent) const;
00250 
00253   virtual void PrepareOutputs();
00254   
00255 private:
00259   double m_Threshold;
00260 
00264   double m_Level;
00265 
00270   typename watershed::Segmenter<InputImageType>::Pointer m_Segmenter;
00271   typename watershed::SegmentTreeGenerator<ScalarType>::Pointer m_TreeGenerator;
00272   typename watershed::Relabeler<ScalarType, itkGetStaticConstMacro(ImageDimension)>::Pointer m_Relabeler;
00273 
00274   unsigned long m_ObserverTag;
00275 
00276   bool m_LevelChanged;
00277   bool m_ThresholdChanged;
00278   bool m_InputChanged;
00279   TimeStamp m_GenerateDataMTime;
00280 };
00281 
00282 } // end namespace itk
00283 
00284 #ifndef ITK_MANUAL_INSTANTIATION
00285 #include "itkWatershedImageFilter.txx"
00286 #endif
00287 
00288 #endif

Generated at Thu May 25 00:17:21 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000