Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

mitkGraphCutImageFilter.h

00001 /*=========================================================================
00002 
00003   Program:   3DMed
00004   Date:      $Date: 2014-02-25 18:30:00 +0800 $
00005   Version:   $Version: 4.6.0 $
00006   Copyright: MIPG, Institute of Automation, Chinese Academy of Sciences
00007 
00008 =========================================================================*/
00009 
00010 
00011 /* mitkGraphCutImageFilter - A class that implement graph cut segmentation method integrated with 
00012   three modeling methods: K-Means, Gaussian Mixture Model and Support Vector Machines.
00013 */
00014 //=========================================================================
00015 #ifndef __mitkGraphCutImageFilter_h
00016 #define __mitkGraphCutImageFilter_h
00017 
00018 #include "mitkSegmentationIncludes.h"
00019 #include "mitkVolumeToVolumeFilter.h"
00020 #include "mitkICVolume.h"
00021 
00022 class Graph;
00023 typedef void *  Graph_node_id;
00024 
00025 class MITK_SEGMENTATION_API mitkGraphCutImageFilter :public mitkVolumeToVolumeFilter
00026 {
00027 public:
00028     
00029      MITK_TYPE(mitkGraphCutImageFilter,mitkVolumeToVolumeFilter)
00030 
00031     mitkGraphCutImageFilter();
00032     virtual ~mitkGraphCutImageFilter();
00033 
00034     virtual void PrintSelf(ostream& os){};
00035 
00036      typedef enum{
00037          KMC=0,              // K-Means method
00038          GMM=1,             // Gaussian Mixture Model method
00039     }valueMethod;
00040      
00041      typedef struct
00042      {
00043          double  weight;    // weight of model of GMM
00044          double  mu;         // mean of model of GMM
00045          double  sigma;     // variance of model of GMM
00046      }GMM_Para;
00047          
00048      typedef struct 
00049      {
00050          int x;                   
00051          int y;
00052          double grayValue;
00053      }PointIndex;           //coordinate and intensity of a point
00054      
00055      typedef vector<double> GrayArr;
00056      typedef vector<PointIndex> PointQueue;
00057      typedef vector<GMM_Para> paraArr;
00058      
00059      void  Initialize();
00060 
00061      void SetLabel(mitkICVolume* label)           {this->m_Label =label;}
00062      void SetOrder(int order)                         {this->m_Order=order;}
00063      void SetBeta(int beta)                             {this->m_Beta=beta;}
00064      void SetCurrentSlice(int cur)                    {this->m_CurrentSlice=cur;}
00065      void SetMethod(valueMethod method)   {m_Method = method;}   
00066      mitkICVolume* GetLabel()   {return this->m_Label;}
00067 
00068 protected:
00069 
00070     // calculate the KMC parameters
00071      bool   KMeansCluster(PointQueue seedQueue, int numCluster, GrayArr& meanCluster); 
00072 
00073     // calculate the GMM parameters by EM algorithm
00074      bool   GaussianMixtureModel(PointQueue seedQueue, int numModel, paraArr& GMMPara, float delt, int ITER_MAX );
00075 
00076    // calculate the probability for a component of  GMM
00077     double G_Probability(double grayValue, GMM_Para para);
00078 
00079     // copy GMM model parameters
00080      bool   CopyPara( paraArr& dstPara, paraArr srcPara);     
00081 
00082      // initialize GMM model parameters
00083      void   InitGMMPara (int  order);
00084     
00085      // calculate the probability of a given sample using  GMM
00086      double Likelihood( paraArr GMMPara, PointQueue pointArr);
00087   
00088      template <typename T>    bool SetSeedPoint(mitkVolume * label, T *pInData);
00089      template <typename T>      bool  GraphCut(T* pInData, valueMethod method, double beta);
00090      template <typename T>      bool _tExecute(T* pInData, unsigned char* pOutData);
00091    
00092      virtual bool Execute();
00093 
00094 private:
00095     mitkGraphCutImageFilter(const mitkGraphCutImageFilter&){};
00096     void operator=(const mitkGraphCutImageFilter&){};
00097 
00098 private:
00099 
00100     int  m_Width, m_Height, m_CurrentSlice;    // width, height and currentSlice of the volume
00101     int m_Order;                                            // number of the model
00102     double m_Beta;                                        // tolerance
00103     valueMethod m_Method;                          // modeling method
00104     
00105     PointQueue seedQueueF, seedQueueB;    // seed points for foreground and background
00106 
00107    /*label for foreground or background    
00108       1 ----foreground  
00109       0 ----background   
00110      -1----unknown*/
00111     mitkICVolume *m_Label;
00112    // mitkICVolume *m_LabelUpdate;
00113 
00114     Graph *m_Graph;
00115     Graph_node_id **m_nodes;
00116     
00117     GrayArr m_meanCluster_f;  // KMC parameters for foreground
00118     GrayArr m_meanCluster_b;  // KMC parameters for background
00119     
00120     paraArr m_GMMPara_f;      // GMM parameters for foreground
00121     paraArr m_GMMPara_b;      // GMM parameters for background
00122 
00123 };
00124 
00125 
00126 #endif
00127 

Generated on Tue Feb 25 15:00:37 2014 for MITK (Medical Imaging ToolKit) by  doxygen 1.4.3