00001 #define __cplusplus__ 00002 #ifndef __DHMRF__ 00003 #define __DHMRF__ 00004 00005 #include<iostream> 00006 #include<istream> 00007 #include<fstream> 00008 #include<string> 00009 #include<vector> 00010 #include<sstream> 00011 #include <cmath> 00012 00013 00014 #include <Seg_Model.hpp> 00015 #include <Spatial_Data.hpp> 00016 #include <Neighborhood_System.hpp> 00017 #include <MRF.hpp> 00018 #include <Conditional_MRF.hpp> 00019 00020 using namespace std; 00021 00022 00032 class DHMRF : public Seg_Model{ 00033 00034 protected : 00035 00037 MRF *Y; 00039 Conditional_MRF *Z; 00040 00041 00042 public : 00043 00045 virtual ~DHMRF(); 00046 00048 uint Get_K(); 00050 uint Get_N(); 00052 uint Get_L(); 00053 00055 bool Check(); 00056 00058 uint upper_class(uint k); 00059 00061 virtual double Density(vector<double> const & X, uint k); 00063 virtual double Density(uint i, vector<double> const & xi, uint l); 00065 virtual double Density(uint i, vector<double> const & xi, vector<uint> const & z, uint l); 00066 00068 double Likelihood(Spatial_Data *spatd); 00070 double BIC(Spatial_Data *spatd ); 00072 double ICL(Spatial_Data *spatd ); 00073 00075 void Compute_PY_ICM(vector<uint> const & y , vector<uint> const & z , uint i, Spatial_Data *spatd, vector<double> & PG ); 00077 void Compute_PZ_ICM(vector<uint> const & y , vector<uint> const & z , uint i, Spatial_Data *spatd, vector<double> & PG ); 00079 void Compute_P_Y_X(uint i, Spatial_Data *spatd, vector<double> & PG_Y ); 00081 void Compute_P_Z_X(uint i, Spatial_Data *spatd, vector<double> const & PG_Y, vector<double> &PG_Z ); 00083 void Compute_PGmf(vector<double> & P_G); 00085 void Compute_tik(Spatial_Data *spatd, vector<double> & til); 00086 00088 void Set_Zmf( vector<double> const & z ); 00090 void Set_Ymf( vector<double> const & y ); 00092 void Set_Zmf( vector<double> const & z , uint i); 00094 void Set_Ymf( vector<double> const & y , uint i); 00096 void Get_Zmf( vector<double> & z ); 00098 void Get_Ymf( vector<double> & z ); 00099 00101 void SetGradient(double step, double tol, uint maxiter); 00102 00103 00105 void Estimate_MRF(Spatial_Data *spatd, vector<double> const & til); 00106 00108 virtual void NREM_E(Spatial_Data *spatd, vector<double> & til); 00110 virtual void NREM_M(Spatial_Data *spatd, vector<double> const & til); 00111 00112 00114 void ICM(Spatial_Data *spatd, vector<uint> & Y_ICM, vector<uint> & Z_ICM); 00115 00117 double Completed_Likelihood(Spatial_Data *spatd, vector<double> const & til); 00118 00120 double PLIC(Spatial_Data *spatd, vector<uint> const & Z_ICM); 00121 00122 }; 00123 00124 00125 #endif