1

I have been scratching my head try to understand how to use the GMM model returned by the opencv grabcut function(python API), the GMM models returned are 2* 64 elements tuple which I assume contains both the mean and variance information but I don't know how to apply it to a pixel that contains 3 color channel to predict how likely it belongs to the foreground or the background. I didn't manage to find any example code that does anything with the GMM models returned by the grabcut function.

Alternatively, I understand that I can use EM.predict to obtain the possibilities if I build the graph and train background/foreground using EM. But I want to be able to use grabcut the way it's written.

Any help will be greatly appreciated!

Susie
  • 287
  • 1
  • 13

1 Answers1

2

Turned out this is a quite complicated issue, the correct order to calculate this is to first assign one of the GMMs component to this pixel and then calculate the probability based on the weight, mean and covariance of the Gaussian assigned.

Susie
  • 287
  • 1
  • 13
  • I don't think one typically uses the returned model for anything but repeated calls to grabcut, however, it could make sense to force the grabcut to use my GMM instead of letting it estimate it based on initial bg/fg labels. – mainactual Mar 31 '18 at 07:08