00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
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,
00038 GMM=1,
00039 }valueMethod;
00040
00041 typedef struct
00042 {
00043 double weight;
00044 double mu;
00045 double sigma;
00046 }GMM_Para;
00047
00048 typedef struct
00049 {
00050 int x;
00051 int y;
00052 double grayValue;
00053 }PointIndex;
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
00071 bool KMeansCluster(PointQueue seedQueue, int numCluster, GrayArr& meanCluster);
00072
00073
00074 bool GaussianMixtureModel(PointQueue seedQueue, int numModel, paraArr& GMMPara, float delt, int ITER_MAX );
00075
00076
00077 double G_Probability(double grayValue, GMM_Para para);
00078
00079
00080 bool CopyPara( paraArr& dstPara, paraArr srcPara);
00081
00082
00083 void InitGMMPara (int order);
00084
00085
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;
00101 int m_Order;
00102 double m_Beta;
00103 valueMethod m_Method;
00104
00105 PointQueue seedQueueF, seedQueueB;
00106
00107
00108
00109
00110
00111 mitkICVolume *m_Label;
00112
00113
00114 Graph *m_Graph;
00115 Graph_node_id **m_nodes;
00116
00117 GrayArr m_meanCluster_f;
00118 GrayArr m_meanCluster_b;
00119
00120 paraArr m_GMMPara_f;
00121 paraArr m_GMMPara_b;
00122
00123 };
00124
00125
00126 #endif
00127