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: 2006/01/19 12:19:20 $
00007   Version:   $Revision: 1.28 $
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 _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,class TBinaryPriorImage=Image<unsigned char,2> >
00059 class ITK_EXPORT 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 typename TOutputImage::PixelType OutputPixelType;
00089   typedef VoronoiDiagram2D<double> VoronoiDiagram;
00090   typedef VoronoiDiagram2DGenerator<double> VoronoiDiagramGenerator;
00091   typedef typename VoronoiDiagram::PointType PointType;
00092   typedef typename VoronoiDiagram::CellType CellType;
00093   typedef typename VoronoiDiagram::CellAutoPointer CellAutoPointer;
00094   typedef typename VoronoiDiagram::Pointer VoronoiPointer;
00095   typedef typename CellType::PointIdIterator PointIdIterator;
00096   typedef typename VoronoiDiagram::SeedsType SeedsType;
00097   typedef typename VoronoiDiagram::SeedsIterator SeedsIterator;
00098   typedef typename VoronoiDiagram::NeighborIdIterator NeighborIdIterator;
00099   typedef typename VoronoiDiagram::VoronoiEdgeIterator EdgeIterator;
00100   typedef typename VoronoiDiagram::VoronoiEdge EdgeInfo;
00101   typedef std::vector<PointType> PointTypeVector;
00102   typedef std::deque<PointType> PointTypeDeque;
00103   typedef TBinaryPriorImage     BinaryObjectImage;
00104   typedef typename BinaryObjectImage::Pointer  BinaryObjectImagePointer;
00105   typedef std::vector<IndexType> IndexList;
00106 
00108   typedef Image<unsigned char,2>  VDImage; 
00109   typedef typename VDImage::Pointer  VDImagePointer; 
00110 
00112   itkSetMacro(NumberOfSeeds, int);
00113   itkGetMacro(NumberOfSeeds, int);
00115 
00117   itkSetMacro(MinRegion, int);
00118   itkGetMacro(MinRegion, int);
00120 
00123   itkSetMacro(Steps, int);
00124   itkGetMacro(Steps, int);
00126 
00128   itkGetMacro(LastStepSeeds, int);
00129 
00131   itkGetMacro(NumberOfSeedsToAdded, int); 
00132 
00134   itkSetMacro(UseBackgroundInAPrior, bool);
00135   itkGetMacro(UseBackgroundInAPrior, bool);
00137 
00139   itkSetMacro(OutputBoundary, bool);
00140   itkGetMacro(OutputBoundary, bool);
00142 
00145   itkSetMacro(InteractiveSegmentation, bool);
00146   itkGetMacro(InteractiveSegmentation, bool);
00147   itkBooleanMacro(InteractiveSegmentation);
00149 
00151   itkSetMacro(MeanDeviation, double);
00152   itkGetMacro(MeanDeviation, double);
00154 
00156   itkSetMacro(Size,SizeType);
00157   itkGetMacro(Size,SizeType);
00159 
00162   virtual void TakeAPrior(const BinaryObjectImage*){};
00163 
00165   void RunSegment(void);
00166 
00168   void RunSegmentOneStep(void);
00169 
00171   virtual void MakeSegmentBoundary(void);
00172   virtual void MakeSegmentObject(void);
00174 
00176   VoronoiPointer GetVoronoiDiagram(void)
00177   { return m_WorkingVD; }
00178 
00182   void SetSeeds(int num, SeedsIterator begin)
00183   { 
00184     m_NumberOfSeeds = num; 
00185     m_WorkingVD->SetSeeds(num,begin); 
00186   }; 
00188 
00190   PointType GetSeed(int SeedID)
00191   { return m_WorkingVD->GetSeed(SeedID); } 
00192 
00194   void DrawDiagram(VDImagePointer result,unsigned char incolor, 
00195                    unsigned char outcolor,unsigned char boundcolor); 
00196 
00197   void BeforeNextStep(void); 
00198 
00201   virtual void GenerateInputRequestedRegion();
00202 
00205   virtual void EnlargeOutputRequestedRegion(DataObject *output);  
00206 
00207 protected:
00208   VoronoiSegmentationImageFilterBase();
00209   ~VoronoiSegmentationImageFilterBase();
00210   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00211 
00212   void GenerateData(void); //general pipeline function.
00213 
00214   SizeType m_Size;
00215   int m_NumberOfSeeds;
00216   int m_MinRegion;
00217   int m_Steps;
00218   int m_LastStepSeeds;
00219   int m_NumberOfSeedsToAdded;
00220   int m_NumberOfBoundary;
00221   std::vector<int> m_NumberOfPixels;
00222   std::vector<unsigned char> m_Label;
00223   double m_MeanDeviation;
00224   bool m_UseBackgroundInAPrior;
00225   bool m_OutputBoundary; //if =1 then output the boundaries, if = 0 then output the object.
00226   bool m_InteractiveSegmentation;
00227   
00228   typename VoronoiDiagram::Pointer m_WorkingVD;
00229   typename VoronoiDiagramGenerator::Pointer m_VDGenerator;
00230 
00231   std::vector<PointType> m_SeedsToAdded;
00232 
00233   // private methods:
00234   // Classify all the voronoi cells as interior , exterior or boundary.
00235   virtual void ClassifyDiagram(void);
00236   
00237   // Generate the seeds to be added by dividing the boundary cells.
00238   virtual void GenerateAddingSeeds(void);
00239   
00240   // Compute the statistics of the pixels inside the cell.
00241   void GetPixelIndexFromPolygon(PointTypeDeque VertList, IndexList *PixelPool);
00242   virtual bool TestHomogeneity(IndexList&){return 1;}
00243   
00244   void FillPolygon(PointTypeDeque vertlist, OutputPixelType color=1);
00245   
00246   // Draw a straight line to the output image.
00247   void drawLine(PointType p1,PointType p2);
00248   
00249   // Draw the intermedia Voronoi Diagram structure. 
00250   void drawVDline(VDImagePointer result,PointType p1,PointType p2, unsigned char color);
00251   
00252 private:
00253   VoronoiSegmentationImageFilterBase(const Self&); //purposely not implemented
00254   void operator=(const Self&); //purposely not implemented
00255   
00256 };
00257 
00258 }//end namespace
00259 
00260 
00261 #ifndef ITK_MANUAL_INSTANTIATION
00262 #include "itkVoronoiSegmentationImageFilterBase.txx"
00263 #endif
00264 
00265 #endif
00266 
00267 
00268 
00269 
00270 

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