Multivariate gaussian probability errors
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I am using multivariate Gaussian model to identify a yellow ball. I am given some training images with yellow balls. I have used these pixels to get the parameters of the model.
But when I am observing the probability values of the image with this model, I get the values of very low order (10^-8) and strangely I am finding the probability of foreground is lower than the background.
The code to get parameters are
mu = sum(Samples(:,:))/N;
Samples = double(Samples);
mu1 = repmat(mu, N, 1);
Sigma = ((Samples-mu1)'*(Samples-mu1))/N;
where Samples is N*3 matrix with RGB values. Using the following code, I am trying to get probability values
clc
clear al
close all
imagepath = './train';
D = 3;
load('parameters.mat', 'mu');
load('parameters.mat', 'Sigma');
dSigma = det(Sigma);
const = 1/(((2*pi)^(D/2))*((dSigma)^(1/2)));
thre = 1e-8;
for k=1:1
samples = [];
% Load image
I = imread(sprintf('%s/%03d.png',imagepath,k));
% You may consider other color space than RGB
R = I(:,:,1);
G = I(:,:,2);
B = I(:,:,3);
R = R(:);
B = B(:);
G = G(:);
samples = [samples; [R G B]];
samples = double(samples);
m = length(R);
p = zeros(m, 1);
for i = 1:m
p(i) = const*exp(-0.5*(samples(i)-mu)*pinv(Sigma)*(samples(i)-mu)');
end
end
I have attached parameters.mat and an image file. Could someone let me know, where I am going wrong
0 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Mathematics and Optimization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!