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: 2002/09/11 19:39:01 $
00007   Version:   $Revision: 1.20 $
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 
00138   itkSetMacro(MeanDeviation, double);
00139   itkGetMacro(MeanDeviation, double);
00140 
00143   virtual void TakeAPrior(BinaryObjectImage* aprior){};
00144   
00146   void RunSegment(void);
00147 
00149   void RunSegmentOneStep(void);
00150 
00152   void MakeSegmentBoundary(void);
00153   void MakeSegmentObject(void);
00154 
00156   VoronoiPointer GetVoronoiDiagram(void)
00157     { return m_WorkingVD; }
00158     
00162   void SetSeeds(int num, SeedsIterator begin)
00163     { 
00164     m_NumberOfSeeds = num; 
00165     m_WorkingVD->SetSeeds(num,begin); 
00166     }; 
00167     
00169   PointType GetSeed(int SeedID)
00170     { return m_WorkingVD->GetSeed(SeedID); } 
00171       
00173   void DrawDiagram(VDImagePointer result,unsigned char incolor, 
00174                    unsigned char outcolor,unsigned char boundcolor); 
00175 
00176   void BeforeNextStep(void); 
00177 
00180   virtual void GenerateInputRequestedRegion();
00181   
00184   virtual void EnlargeOutputRequestedRegion(DataObject *output);  
00185 
00186 protected:
00187   VoronoiSegmentationImageFilterBase();
00188   ~VoronoiSegmentationImageFilterBase();
00189   virtual void PrintSelf(std::ostream& os, Indent indent) const;
00190 
00191   void GenerateData(void); //general pipeline function.
00192 
00193   SizeType m_Size;
00194   int m_NumberOfSeeds;
00195   int m_MinRegion;
00196   int m_Steps;
00197   int m_LastStepSeeds;
00198   int m_NumberOfSeedsToAdded;
00199   int m_NumberOfBoundary;
00200   std::vector<int> m_NumberOfPixels;
00201   std::vector<unsigned char> m_Label;
00202   double m_MeanDeviation;
00203   bool m_UseBackgroundInAPrior;
00204   bool m_OutputBoundary; //if =1 then output the boundaries, if = 0 then output the object.
00205 
00206   typename VoronoiDiagram::Pointer m_WorkingVD;
00207   typename VoronoiDiagramGenerator::Pointer m_VDGenerator;
00208 
00209   std::vector<PointType> m_SeedsToAdded;
00210 
00211   // private methods:
00212   // Classify all the voronoi cells as interior , exterior or boundary.
00213   void ClassifyDiagram(void);
00214   
00215   // Generate the seeds to be added by dividing the boundary cells.
00216   void GenerateAddingSeeds(void);
00217   
00218   // Compute the statistics of the pixels inside the cell.
00219   void GetPixelIndexFromPolygon(PointTypeDeque VertList, IndexList *PixelPool);
00220   virtual bool TestHomogeneity(IndexList Plist){return 1;};
00221   
00222   void FillPolygon(PointTypeDeque vertlist);
00223   
00224   // Draw a straight line to the output image.
00225   void drawLine(PointType p1,PointType p2);
00226   
00227   // Draw the intermedia Voronoi Diagram structure. 
00228   void drawVDline(VDImagePointer result,PointType p1,PointType p2, unsigned char color);
00229   
00230 private:
00231   VoronoiSegmentationImageFilterBase(const Self&); //purposely not implemented
00232   void operator=(const Self&); //purposely not implemented
00233   
00234 };
00235 
00236 }//end namespace
00237 
00238 
00239 #ifndef ITK_MANUAL_INSTANTIATION
00240 #include "itkVoronoiSegmentationImageFilterBase.txx"
00241 #endif
00242 
00243 #endif
00244 
00245 
00246 
00247 

Generated at Wed Mar 12 01:13:13 2003 for ITK by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2000