Upload
pi194043
View
561
Download
0
Embed Size (px)
DESCRIPTION
A basic implementation of Gaussian Mixture Model Implementation for OpenVision Library .Code can be found at https://github.com/pi19404/OpenVision/
Citation preview
OpenVision LibraryGaussian MixtureImplementation
Pi19404
March 2, 2014
Contents
Contents
OpenVision Library Gaussian Mixture Implementation 3
0.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30.1.1 Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 | 5
OpenVision Library Gaussian Mixture Implementation
OpenVision Library Gaussian
Mixture Implementation
0.1 Introduction
� In this article we will look at gaussian mixture model.
� Mixture Models are a type of density model which comprise a
number of component functions, usually Gaussian.
� These component functions are combined to provide a multi-
modal density.
� GMM is a weighted average of gaussians where gaussian by its
own mean can covariance matrix matrix
� The mixture density is given by
P (Xj�;�; w) =P
kwkN (X;�k;�k)
� To compute the likelyhood that a random variable is sampled from
the mixture model we just need to compute the probability of
individual gaussian component and then find the weighted aver-
age.
� Instead of probability we can compute the log likelyhood of
gaussian components which would simply be the log of sum of
weighted exponentials.
L(Xj�;�; w) = logP
kexp(logwk + logN (X;�k;�k))
� A gaussian mixture model is characterized by
� Number of mixture components
� Weights of mixtures
� Mean and covariances of individual mixture components
� Thus given the model parameters computation of probability
that a vector is sampled from the gaussian mixture model is
fairly simple
3 | 5
OpenVision Library Gaussian Mixture Implementation
vector<Gaussian> components;
/**
* @brief ProbMix:method returns the probability that
* vector X belongs to each of mixture gaussian
* @param X : input vector X
* @return :output vector of probabilities
*/
vector<float> ProbMix(Mat X)
{
vector<float> res;
res.resize(_nmix);
for(int i=0;i<_nmix;i++)
{
// cerr << _weights[i] << endl;
res[i]=(_components[i].Prob(X));
}
return res;
}
/**
* @brief Prob : method computes the probability that vector X
* is drawn from the gaussian mixture model
* @param X : input vector X
* @return
*/
float Prob(Mat X)
{
float res=0;
for(int i=0;i<_nmix;i++)
{
// cerr << _weights[i] << endl;
res=res+_weights[i]*(_components[i].Prob(X));
}
return res;
}
� For example if we consider the following mixture models
MU1 = [1 2];
SIGMA1 = [2 0; 0 .5];
MU2 = [-3 -5];
SIGMA2 = [1 0; 0 1];
4 | 5
OpenVision Library Gaussian Mixture Implementation
priors=[0.4 0.6];
X=[1.1 2.3];
� The probability that vector X belongs to GMM is computed as
0:0580374 using the method Prob
� The probability that vector X belongs to individual mixture com-
ponents is computed as 0:145093 : 9:5455e� 17
� Both the above results can be verified by manual calculation or
other packages etc.
0.1.1 Code
� The code for the same can be found in OpenVision git repos-
itory https://github.com/pi19404/OpenVision in files ImgMl/gaus-
sianmixture.cpp and ImgMl/gaussianmixture.hpp files.
� OpenVision is attempt at a opensource C/C++ Library developed
in C/C++ using OpenCV,Eigen etc providing modular interface
for image processing,computer vision,machine learning applica-
tions.
5 | 5