Hi everyone,
I'm using the EM module of opencv(tried 2.4.2 and 2.4.3). I wants to try my samples(676*64) which is generated by SIFT+PCA by EM. but I have tried to use the same samples to train the EM to get the Gaussian mixture model. But the results are different.
here is a test code.
CvEM m_emModel1;
CvEMParams params1;
cv::Mat labels1;
params1.covs = NULL;
params1.means = NULL;
params1.weights = NULL;
params1.probs = NULL;
params1.nclusters = 10;
params1.cov_mat_type = CvEM::COV_MAT_SPHERICAL;
params1.start_step = CvEM::START_AUTO_STEP;
params1.term_crit.max_iter = 300;
params1.term_crit.epsilon = 0.1;
params1.term_crit.type = CV_TERMCRIT_ITER|CV_TERMCRIT_EPS;
m_emModel1.train(samples, cv::Mat(), params1, &labels1);
std::cout<<"means1"<<std::endl;
for(int j=0; j<10; ++j)
std::cout<<m_emModel1.getMeans().at<double>(0, j)<<" ";
std::cout<<std::endl;
std::cout<<"weightes1"<<std::endl;
for(int j=0; j<10; ++j)
std::cout<<m_emModel1.getWeights().at<double>(j)<<" ";
std::cout<<std::endl;
CvEM m_emModel;
CvEMParams params;
cv::Mat labels;
params.covs = NULL;
params.means = NULL;
params.weights = NULL;
params.probs = NULL;
params.nclusters = 10;
params.cov_mat_type = CvEM::COV_MAT_SPHERICAL;
params.start_step = CvEM::START_M_STEP;//CvEM::START_AUTO_STEP;
params.term_crit.max_iter = 300;
params.term_crit.epsilon = 0.001;
params.term_crit.type = CV_TERMCRIT_ITER|CV_TERMCRIT_EPS;
m_emModel.train(samples, cv::Mat(), params, &labels);
std::cout<<"means"<<std::endl;
for(int j=0; j<10; ++j)
std::cout<<m_emModel.getMeans().at<double>(0, j)<<" ";
std::cout<<std::endl;
std::cout<<"weightes"<<std::endl;
for(int j=0; j<10; ++j)
std::cout<<m_emModel.getWeights().at<double>(j)<<" ";
std::cout<<std::endl;
here is a result:
I really hope your replys, thanks your reading.