Ask Your Question
1

Calculate weight of a cluster in Opencv

asked 2015-02-20 08:06:03 -0600

RiSaMa gravatar image

updated 2015-02-23 04:22:08 -0600

Dear forum followers I have a issue which I don't know how deal with it.

I'm developing a tracker (track people in videos) from a particle filter. I have particles along the image and I cluster them using EM (http://docs.opencv.org/modules/ml/doc...) in Opencv.

After clustering, I can check the next values about the output clusters:

  • Mean of the cluster (position)
  • Weight of the cluster
  • Covariance of the clusters

At this point everything is fine.

After I modify some of this clusters and particles and the final step would be recalculate mean, weight and covariance. I calculcate these variables:

  • Mean: calculating the average position of the particles.
  • Covariance: calculateing the covariance of the particles.
  • Weight: here is my doubt... HOW can I calculate the weight of each cluster??

Extend information: I'm currently doing: - I call trainE - I modify things using these results like the labels... -And I want calculate the weight of the clusters; with the labels modified...

I hope you can help me!!! Thank in advanced!!!

edit retag flag offensive close merge delete

Comments

Have a look in the example here. It seems that it could help you.

theodore gravatar imagetheodore ( 2015-02-20 08:36:39 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-02-22 12:29:26 -0600

Guanta gravatar image

Imho, you just need to call trainE() with your means, use empty matrices for covariance and weights and they should be filled accordingly (or just use your old mean, cov and weight parameters and they should be updated)!

edit flag offensive delete link more

Comments

Thank you for your answer! I think this one isn't the correct solution because... I currently do:

  • I call trainE
  • I modify things using these results like the labels...
  • If I recall trainE I will get the same clustering that the previous call.... and I want the weight of the clusters with the new labels which I'm modified...

I hope someone could hit the mark!

THANKS!!

RiSaMa gravatar imageRiSaMa ( 2015-02-23 03:29:00 -0600 )edit
1

If your labels are changed, then it is impossible to get the same clustering as from the previous call. Restarting the trainE step is exactly what you need to do.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-02-23 06:01:17 -0600 )edit

But the labels aren't a input of the clustering... I use positions (x,y) how input of the clustering I have "particles" like these:

  • X | Y | .... | LABEL | .....

I use like input: (x,y) I use like OUTPUT label for asign labels at each particle.

Do you think I need restart trainE? With labels like input? because if I use the (x,y) (which have not been modified) I will get the same result....

I don't understand what is the meaning of the weight... is related with the distance between input and means of the clusters?

THANKS for your HELP!!!

RiSaMa gravatar imageRiSaMa ( 2015-02-23 06:14:49 -0600 )edit

You can get the labels as optional output parameters. Your changes to the labels won't be used since EM is an unsupervised algorithm!

Guanta gravatar imageGuanta ( 2015-02-23 07:04:06 -0600 )edit

I think we aren't understanding properly.

I have some particles with this values: position (x,y) and label(empty before execute the EM).

At this moment I execute the trainE using like INPUT only the position (x,y). And I get (output):

  • Labels from EM and I assign these to the particles.
  • Weights, covs and means.

At this moment we have the particles with its new labels.

Now I CHANGE some labels based in others things.... And I want get the weights of these modified clusters!

How could I achieve these new weights??

THANKS in advance and thanks for your patience!!

RiSaMa gravatar imageRiSaMa ( 2015-02-23 07:14:57 -0600 )edit
1

Somehow you really speak from something else since the weights of a GMM which you train via EM are not related to the labels at all, only throught the sum of posteriors! Thus, you must be talking of another weight parameter ^^

Guanta gravatar imageGuanta ( 2015-02-23 07:26:40 -0600 )edit

OK, thank you for your explanations.

But I have a doubt...

If I use how input a cloud of points (particles x, y) ... What determines the weight of the clusters??

  • Dense cluster -> high weight?
  • No dense cluster -> low weight?

THANKS!!!

RiSaMa gravatar imageRiSaMa ( 2015-02-25 03:24:33 -0600 )edit
1

Afaik the weights of GMM models are an indication of the influence of each gaussian model inside the mixture and how important it is.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-02-25 03:31:31 -0600 )edit

OK Thank you everyone helped me! I finally implemented recalling the train function using the LABELS modified how input. THANKS

RiSaMa gravatar imageRiSaMa ( 2015-02-25 04:34:10 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-02-20 08:06:03 -0600

Seen: 526 times

Last updated: Feb 23 '15