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

itkGibbsPriorFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkGibbsPriorFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2002/09/11 19:39:01 $
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 
00018 #ifndef __itkGibbsPriorFilter_h
00019 #define __itkGibbsPriorFilter_h
00020 
00021 //#include "itkObject.h"
00022 #include "vnl/vnl_vector.h"
00023 #include "vnl/vnl_matrix.h"
00024 
00025 #include "itkImageToImageFilter.h"
00026 //#include "itkSupervisedClassifier.h"
00027 #include "itkMRFImageFilter.h"
00028 #include "itkImageRegionIteratorWithIndex.h"
00029 
00030 
00031 namespace itk
00032 {
00033 
00047 template <class TInputImage, class TClassifiedImage>
00048 class ITK_EXPORT GibbsPriorFilter : public MRFImageFilter<TInputImage, 
00049   TClassifiedImage>
00050 {
00051 public:
00053   typedef GibbsPriorFilter  Self;
00054   typedef MRFImageFilter<TInputImage, TClassifiedImage> Superclass;
00055   typedef SmartPointer<Self>  Pointer;
00056   typedef SmartPointer<const Self>  ConstPointer;
00057 
00059   itkNewMacro(Self);
00060   
00062   itkTypeMacro(GibbsPriorFilter,MRFImageFilter);
00063 
00065   typedef typename TInputImage::Pointer              InputImageType;  
00066 
00068   typedef typename TInputImage::PixelType            InputPixelType;
00069 
00071   typedef typename TClassifiedImage::Pointer         TrainingImageType;
00072 
00074   typedef typename TClassifiedImage::PixelType       TrainingPixelType;
00075 
00078   typedef typename TClassifiedImage::Pointer         LabelledImageType;
00079       
00082   typedef typename TClassifiedImage::PixelType       LabelledPixelType;
00083 
00085   typedef typename TClassifiedImage::IndexType       LabelledImageIndexType;
00086 
00088   typedef typename Superclass::ClassifierType ClassifierType;
00089 //  typedef Classifier<TInputImage,TClassifiedImage> ClassifierType;
00090 
00092   typename ClassifierType::Pointer m_ClassifierPtr;
00093   typedef typename TInputImage::PixelType      InputImagePixelType;
00094   typedef typename TClassifiedImage::PixelType TrainingImagePixelType;
00095   typedef typename TClassifiedImage::PixelType LabelledImagePixelType;
00096 
00098   typedef ImageRegionIteratorWithIndex< TInputImage > InputImageIterator;
00099   typedef ImageRegionIteratorWithIndex<TClassifiedImage> LabelledImageIterator;
00100   typedef typename TInputImage::PixelType    InputImageVectorType;
00101 
00103   void SetTrainingImage(TrainingImageType image);
00104 
00106   void SetLabelledImage(LabelledImageType LabelledImage);
00107 
00109   LabelledImageType GetLabelledImage()
00110     { return m_LabelledImage; }
00111 
00113   void SetClassifier( typename ClassifierType::Pointer ptrToClassifier );
00114 
00116   itkSetMacro(NumberOfClasses, unsigned int);
00117   itkGetMacro(NumberOfClasses, unsigned int);
00118 
00121   itkSetMacro(MaximumNumberOfIterations, unsigned int);
00122   itkGetMacro(MaximumNumberOfIterations, unsigned int);
00123 
00126   itkSetMacro(ErrorTolerance, double);
00127   itkGetMacro(ErrorTolerance, double);
00128 
00130   itkSetMacro(ClusterSize, unsigned int);
00131 
00133   itkSetMacro(ObjectLabel, unsigned int);
00134 
00136   itkStaticConstMacro(ImageDimension, unsigned int,
00137                       TInputImage::ImageDimension);
00138 
00140   void SetStartPoint (int x, int y, int z); 
00141   void SetBoundaryGradient(int a);
00142   void Advance();
00143 
00144 protected:
00145   GibbsPriorFilter();
00146   ~GibbsPriorFilter() {};
00147   void PrintSelf(std::ostream& os, Indent indent) const;
00148 
00149   virtual void MinimizeFunctional();
00150   virtual void GenerateData();
00151   void ApplyGibbsLabeller();
00152   virtual void ApplyMRFImageFilter();
00153   void Allocate();
00154 
00155   InputImageType         m_InputImage;
00156   TrainingImageType      m_TrainingImage;
00157   LabelledImageType      m_LabelledImage;
00158 
00159   float m_BoundaryWeight; 
00160   float m_GibbsPriorWeight; 
00161   int m_StartRadius;
00162 
00163   int m_StartPoint[3]; 
00164   int m_StartModelSize; 
00165   int m_GibbsNeighborsThreshold; 
00166   int m_BoundaryGradient;
00167   int m_RecursiveNum;
00168 
00169   unsigned int          m_NumberOfClasses;
00170   unsigned int          m_MaximumNumberOfIterations;
00171   unsigned int          *m_LabelStatus;
00172   
00173   double                m_ErrorTolerance;
00174   double                *m_ClassProbability; //Class liklihood
00175 
00176   int                   m_ErrorCounter;
00177   int                   m_ImageWidth;
00178   int                   m_ImageHeight;
00179   int                   m_ImageDepth;
00180   int                   m_ClusterSize;
00181   int                   m_ObjectLabel;
00182 
00183   unsigned short    *m_Region;
00184   unsigned short    *m_RegionCount;
00185 
00187   void  GenerateInputRequestedRegion();
00188   void  EnlargeOutputRequestedRegion( DataObject * );
00189   void  GenerateOutputInformation();
00190 
00191   void  GibbsTotalEnergy(int i);
00192   int   GreyScalarBoundary(LabelledImageIndexType Index3D); 
00193   float GibbsEnergy(int i, int k, int k1);
00194   int Sim(int a, int b);
00195   int LabelRegion(int i, int l, int change);
00196   void  RegionEraser();
00197 
00198 private:
00199   GibbsPriorFilter(const Self&); //purposely not implemented
00200   void operator=(const Self&); //purposely not implemented
00201   
00202   typedef typename TInputImage::SizeType InputImageSizeType;
00203 };
00204 
00205 } // end namespace itk
00206 #ifndef ITK_MANUAL_INSTANTIATION
00207 #include "itkGibbsPriorFilter.txx"
00208 #endif
00209 #endif

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