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: 2009-04-23 03:53:37 $
00007   Version:   $Revision: 1.30 $
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 typename TInputImage::IndexType    IndexType;
00084   typedef typename TInputImage::SizeType     SizeType;
00085   typedef typename TInputImage::RegionType   RegionType;
00086   typedef typename TInputImage::PixelType    PixelType;
00087 
00088   typedef TOutputImage                       OutputImageType;
00089   typedef typename TOutputImage::PixelType   OutputPixelType;
00090 
00091   typedef VoronoiDiagram2D<double>                     VoronoiDiagram;
00092   typedef VoronoiDiagram2DGenerator<double>            VoronoiDiagramGenerator;
00093   typedef typename VoronoiDiagram::PointType           PointType;
00094   typedef typename VoronoiDiagram::CellType            CellType;
00095   typedef typename VoronoiDiagram::CellAutoPointer     CellAutoPointer;
00096   typedef typename VoronoiDiagram::Pointer             VoronoiPointer;
00097   typedef typename CellType::PointIdIterator           PointIdIterator;
00098   typedef typename VoronoiDiagram::SeedsType           SeedsType;
00099   typedef typename VoronoiDiagram::SeedsIterator       SeedsIterator;
00100   typedef typename VoronoiDiagram::NeighborIdIterator  NeighborIdIterator;
00101   typedef typename VoronoiDiagram::VoronoiEdgeIterator EdgeIterator;
00102   typedef typename VoronoiDiagram::VoronoiEdge         EdgeInfo;
00103   typedef std::vector<PointType>                       PointTypeVector;
00104   typedef std::deque<PointType>                        PointTypeDeque;
00105   typedef TBinaryPriorImage                            BinaryObjectImage;
00106   typedef typename BinaryObjectImage::Pointer          BinaryObjectImagePointer;
00107   typedef std::vector<IndexType>                       IndexList;
00108 
00110   typedef Image<unsigned char,2>     VDImage; 
00111   typedef typename VDImage::Pointer  VDImagePointer; 
00112 
00114   itkSetMacro(NumberOfSeeds, int);
00115   itkGetConstMacro(NumberOfSeeds, int);
00117 
00119   itkSetMacro(MinRegion, int);
00120   itkGetConstMacro(MinRegion, int);
00122 
00125   itkSetMacro(Steps, int);
00126   itkGetConstMacro(Steps, int);
00128 
00130   itkGetConstMacro(LastStepSeeds, int);
00131 
00133   itkGetConstMacro(NumberOfSeedsToAdded, int); 
00134 
00136   itkSetMacro(UseBackgroundInAPrior, bool);
00137   itkGetConstMacro(UseBackgroundInAPrior, bool);
00139 
00141   itkSetMacro(OutputBoundary, bool);
00142   itkGetConstMacro(OutputBoundary, bool);
00144 
00147   itkSetMacro(InteractiveSegmentation, bool);
00148   itkGetConstMacro(InteractiveSegmentation, bool);
00149   itkBooleanMacro(InteractiveSegmentation);
00151 
00153   itkSetMacro(MeanDeviation, double);
00154   itkGetConstMacro(MeanDeviation, double);
00156 
00158   itkSetMacro(Size,SizeType);
00159   itkGetConstMacro(Size,SizeType);
00161 
00164   virtual void TakeAPrior(const BinaryObjectImage*){}
00165 
00167   void RunSegment(void);
00168 
00170   void RunSegmentOneStep(void);
00171 
00173   virtual void MakeSegmentBoundary(void);
00174   virtual void MakeSegmentObject(void);
00176 
00178   VoronoiPointer GetVoronoiDiagram(void)
00179     { return m_WorkingVD; }
00180 
00184   void SetSeeds(int num, SeedsIterator begin)
00185     { 
00186     m_NumberOfSeeds = num; 
00187     m_WorkingVD->SetSeeds(num,begin); 
00188     } 
00190 
00192   PointType GetSeed(int SeedID)
00193     { return m_WorkingVD->GetSeed(SeedID); } 
00194 
00196   void DrawDiagram(VDImagePointer result,unsigned char incolor, 
00197                    unsigned char outcolor,unsigned char boundcolor); 
00198 
00199   void BeforeNextStep(void); 
00200 
00203   virtual void GenerateInputRequestedRegion();
00204 
00207   virtual void EnlargeOutputRequestedRegion(DataObject *output);  
00208 
00209 protected:
00210   VoronoiSegmentationImageFilterBase();
00211   ~VoronoiSegmentationImageFilterBase();
00212   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00213 
00214   void GenerateData(void); //general pipeline function.
00215 
00216   SizeType m_Size;
00217   int      m_NumberOfSeeds;
00218   int      m_MinRegion;
00219   int      m_Steps;
00220   int      m_LastStepSeeds;
00221   int      m_NumberOfSeedsToAdded;
00222   int      m_NumberOfBoundary;
00223 
00224   std::vector<int>           m_NumberOfPixels;
00225   std::vector<unsigned char> m_Label;
00226 
00227   double m_MeanDeviation;
00228   bool   m_UseBackgroundInAPrior;
00229   bool   m_OutputBoundary; //if =1 then output the boundaries, if = 0 then output the object.
00230   bool   m_InteractiveSegmentation;
00231   
00232   typename VoronoiDiagram::Pointer          m_WorkingVD;
00233   typename VoronoiDiagramGenerator::Pointer m_VDGenerator;
00234 
00235   std::vector<PointType> m_SeedsToAdded;
00236 
00237   // private methods:
00238   // Classify all the voronoi cells as interior , exterior or boundary.
00239   virtual void ClassifyDiagram(void);
00240   
00241   // Generate the seeds to be added by dividing the boundary cells.
00242   virtual void GenerateAddingSeeds(void);
00243   
00244   // Compute the statistics of the pixels inside the cell.
00245   void GetPixelIndexFromPolygon(PointTypeDeque VertList, IndexList *PixelPool);
00246   virtual bool TestHomogeneity(IndexList&)
00247     {return 1;}
00248   
00249   void FillPolygon(PointTypeDeque vertlist, OutputPixelType color=1);
00250   
00251   // Draw a straight line to the output image.
00252   void drawLine(PointType p1,PointType p2);
00253   
00254   // Draw the intermedia Voronoi Diagram structure. 
00255   void drawVDline(VDImagePointer result,PointType p1,PointType p2, unsigned char color);
00256   
00257 private:
00258   VoronoiSegmentationImageFilterBase(const Self&); //purposely not implemented
00259   void operator=(const Self&); //purposely not implemented
00260   
00261 };
00262 
00263 }//end namespace
00264 
00265 
00266 #ifndef ITK_MANUAL_INSTANTIATION
00267 #include "itkVoronoiSegmentationImageFilterBase.txx"
00268 #endif
00269 
00270 #endif
00271 

Generated at Thu May 28 12:03:16 2009 for ITK by doxygen 1.5.5 written by Dimitri van Heesch, © 1997-2000