1 | initial version |
I have asked this question on stack overflow and has been answered : http://stackoverflow.com/questions/14230377/opencv-output-of-the-predict-function-of-expectation-maximization
2 | No.2 Revision |
I have asked this question on stack overflow and has been answered : http://stackoverflow.com/questions/14230377/opencv-output-of-the-predict-function-of-expectation-maximization
Here is the copy of the answer given in stackoverflow:
As I understand you have two separate GMMs for the foreground and background part of the image.The total probability of a sample pixel 'x' in the test image when evaluated in the foreground GMM is
P_fg(x) = sum_over_j_1_to_k ( Wj_fg * Pj_fg( x )) where k = number of clusters in foreground GMM x = test sample Pj_fg(x) = probability that sample x is in j-th cluster according to the foreground GMM Wj_fg = weight of the j-th cluster in foreground GMM also, sum of all weights should be 1 for each GMM.`We can do a similar calculation for the background GMM.
From looking at the EM code in opencv, it looks like the first part of the 2 values that EM returns is the log likelihood. For the foreground GMM this is
log(P_fg(x_i))I implemented your algorithm and for each pixel in the test image, I compared the log-likelihoods returned for each of the two GMM-s and classified the pixel with the GMM with higher value. I got decent results.
In that respect, yes this value is an indication of the pixel to be belonging to the entire GMM.
2) In my implementation of your problem, I always got the log likelihoods of all GMMS of all test-sample pixels under 0.