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

itkVoronoiSegmentationImageFilterBase.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkVoronoiSegmentationImageFilterBase.h,v $
00005   Language:  C++
00006   Date:      $Date: 2003/02/26 23:20:31 $
00007   Version:   $Revision: 1.22 $
00008 
00009   Copyright (c) 2002 Insight 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 _itkVoronoiSegmentationImageFilterBase_h
00018 #define _itkVoronoiSegmentationImageFilterBase_h
00019 
00020 #include "itkImageToImageFilter.h"
00021 #include "itkVoronoiDiagram2D.h"
00022 #include "itkVoronoiDiagram2DGenerator.h"
00023 #include "itkImage.h"
00024 
00025 namespace itk
00026 {
00027 
00058 template <class TInputImage, class TOutputImage>
00059 class VoronoiSegmentationImageFilterBase:
00060 public ImageToImageFilter<TInputImage,TOutputImage>
00061 {
00062 public:
00064   typedef VoronoiSegmentationImageFilterBase       Self;
00065   typedef ImageToImageFilter<TInputImage,TOutputImage>   Superclass;
00066   typedef SmartPointer <Self>  Pointer;
00067   typedef SmartPointer<const Self>  ConstPointer;
00068 
00070   itkNewMacro(Self);
00071 
00073   itkTypeMacro(VoronoiSegmentationImageFilterBase,ImageToImageFilter);
00074 
00076   itkStaticConstMacro(ImageDimension, unsigned int,
00077                       TInputImage::ImageDimension);
00078   
00080   typedef TInputImage InputImageType;
00081   typedef typename TInputImage::Pointer InputImagePointer;
00082   typedef typename TInputImage::ConstPointer InputImageConstPointer;
00083   typedef TOutputImage OutputImageType;
00084   typedef typename TInputImage::IndexType IndexType;
00085   typedef typename TInputImage::SizeType SizeType;
00086   typedef typename TInputImage::RegionType RegionType;
00087   typedef typename TInputImage::PixelType PixelType;
00088   typedef VoronoiDiagram2D<double> VoronoiDiagram;
00089   typedef VoronoiDiagram2DGenerator<double> VoronoiDiagramGenerator;
00090   typedef typename VoronoiDiagram::PointType PointType;
00091   typedef typename VoronoiDiagram::CellType CellType;
00092   typedef typename VoronoiDiagram::CellAutoPointer CellAutoPointer;
00093   typedef typename VoronoiDiagram::Pointer VoronoiPointer;
00094   typedef typename CellType::PointIdIterator PointIdIterator;
00095   typedef typename VoronoiDiagram::SeedsType SeedsType;
00096   typedef typename VoronoiDiagram::SeedsIterator SeedsIterator;
00097   typedef typename VoronoiDiagram::NeighborIdIterator NeighborIdIterator;
00098   typedef typename VoronoiDiagram::VoronoiEdgeIterator EdgeIterator;
00099   typedef typename VoronoiDiagram::VoronoiEdge EdgeInfo;
00100   typedef std::vector<PointType> PointTypeVector;
00101   typedef std::deque<PointType> PointTypeDeque;
00102   typedef Image<bool,2>  BinaryObjectImage;
00103   typedef typename BinaryObjectImage::Pointer  BinaryObjectImagePointer;
00104   typedef std::vector<IndexType> IndexList;
00105 
00107   typedef Image<unsigned char,2>  VDImage; 
00108   typedef typename VDImage::Pointer  VDImagePointer; 
00109     
00111   itkSetMacro(NumberOfSeeds, int);
00112   itkGetMacro(NumberOfSeeds, int);
00113 
00115   itkSetMacro(MinRegion, int);
00116   itkGetMacro(MinRegion, int);
00117 
00120   itkSetMacro(Steps, int);
00121   itkGetMacro(Steps, int);
00122 
00124   itkGetMacro(LastStepSeeds, int);
00125 
00127   itkGetMacro(NumberOfSeedsToAdded, int); 
00128 
00130   itkSetMacro(UseBackgroundInAPrior, bool);
00131   itkGetMacro(UseBackgroundInAPrior, bool);
00132 
00134   itkSetMacro(OutputBoundary, bool);
00135   itkGetMacro(OutputBoundary, bool);
00136 
00139   itkSetMacro(InteractiveSegmentation, bool);
00140   itkGetMacro(InteractiveSegmentation, bool);
00141   itkBooleanMacro(InteractiveSegmentation);
00142   
00144   itkSetMacro(MeanDeviation, double);
00145   itkGetMacro(MeanDeviation, double);
00146 
00149   virtual void TakeAPrior(BinaryObjectImage*){};
00150   
00152   void RunSegment(void);
00153 
00155   void RunSegmentOneStep(void);
00156 
00158   virtual void MakeSegmentBoundary(void);
00159   virtual void MakeSegmentObject(void);
00160 
00162   VoronoiPointer GetVoronoiDiagram(void)
00163     { return m_WorkingVD; }
00164     
00168   void SetSeeds(int num, SeedsIterator begin)
00169     { 
00170     m_NumberOfSeeds = num; 
00171     m_WorkingVD->SetSeeds(num,begin); 
00172     }; 
00173     
00175   PointType GetSeed(int SeedID)
00176     { return m_WorkingVD->GetSeed(SeedID); } 
00177       
00179   void DrawDiagram(VDImagePointer result,unsigned char incolor, 
00180                    unsigned char outcolor,unsigned char boundcolor); 
00181 
00182   void BeforeNextStep(void); 
00183 
00186   virtual void GenerateInputRequestedRegion();
00187   
00190   virtual void EnlargeOutputRequestedRegion(DataObject *output);  
00191 
00192 protected:
00193   VoronoiSegmentationImageFilterBase();
00194   ~VoronoiSegmentationImageFilterBase();
00195   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00196 
00197   void GenerateData(void); //general pipeline function.
00198 
00199   SizeType m_Size;
00200   int m_NumberOfSeeds;
00201   int m_MinRegion;
00202   int m_Steps;
00203   int m_LastStepSeeds;
00204   int m_NumberOfSeedsToAdded;
00205   int m_NumberOfBoundary;
00206   std::vector<int> m_NumberOfPixels;
00207   std::vector<unsigned char> m_Label;
00208   double m_MeanDeviation;
00209   bool m_UseBackgroundInAPrior;
00210   bool m_OutputBoundary; //if =1 then output the boundaries, if = 0 then output the object.
00211   bool m_InteractiveSegmentation;
00212   
00213   typename VoronoiDiagram::Pointer m_WorkingVD;
00214   typename VoronoiDiagramGenerator::Pointer m_VDGenerator;
00215 
00216   std::vector<PointType> m_SeedsToAdded;
00217 
00218   // private methods:
00219   // Classify all the voronoi cells as interior , exterior or boundary.
00220   virtual void ClassifyDiagram(void);
00221   
00222   // Generate the seeds to be added by dividing the boundary cells.
00223   virtual void GenerateAddingSeeds(void);
00224   
00225   // Compute the statistics of the pixels inside the cell.
00226   void GetPixelIndexFromPolygon(PointTypeDeque VertList, IndexList *PixelPool);
00227   virtual bool TestHomogeneity(IndexList&){return 1;}
00228   
00229   void FillPolygon(PointTypeDeque vertlist);
00230   
00231   // Draw a straight line to the output image.
00232   void drawLine(PointType p1,PointType p2);
00233   
00234   // Draw the intermedia Voronoi Diagram structure. 
00235   void drawVDline(VDImagePointer result,PointType p1,PointType p2, unsigned char color);
00236   
00237 private:
00238   VoronoiSegmentationImageFilterBase(const Self&); //purposely not implemented
00239   void operator=(const Self&); //purposely not implemented
00240   
00241 };
00242 
00243 }//end namespace
00244 
00245 
00246 #ifndef ITK_MANUAL_INSTANTIATION
00247 #include "itkVoronoiSegmentationImageFilterBase.txx"
00248 #endif
00249 
00250 #endif
00251 
00252 
00253 
00254 

Generated at Fri May 21 01:15:35 2004 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000