OpenCV Gaussian Mixture Model of histogram -
given histogram want train gaussian mixture model:
int calcgmmthreshold(cv::mat & hist, cv::mat & labels){ cv::mat samples(hist.rows,2, cv_32fc1); // building 2 dim samples // output variables cv::mat probs, log_likelihoods; // building 2 dimensional mat -->[value][#value] for(int = 0; i<hist.rows; i++) { samples.at<float>(i,0) = (float)i; samples.at<float>(i,1) = hist.at<float>(i); } assert(samples.cols == 2); assert(samples.rows == 256); ///set gmm //gmm object 3 gmms cv::em gmm(3); /*train gmms*/ gmm.train(samples, log_likelihoods, labels, probs); }
when plot histogram labels me looks gmms separate absolute values , not 2 dimensional input.
i have expected 3 gaussians means @ each peak of histogram.
to compute gaussian mixture model use actual image data not histogram intended in code above.
Comments
Post a Comment