gpt4 book ai didi

c++ - 在 C++ 中实现多变量正态 pdf 以进行图像分类

转载 作者:太空宇宙 更新时间:2023-11-04 14:05:18 25 4
gpt4 key购买 nike

我希望实现多变量正态 PDF [ 1 ] 在 C++ 中分配一个类的图像成员中的每个像素,即

    for each pixel
for each class
compute multivariate normal PDF using the pixel's feature vector and the class' mean vector and covariance matrix
end
end

是否有一个库可以高效地执行此操作(即类似于 Matlab 的 mvnpdf 函数[ 2 ])?如果没有什么想法最好的库或方法(我正在考虑使用 Eigen)。

最佳答案

我不知道现成的一步解决方案。对于两步混合匹配方法,您可以熟悉 Boost.Math它有一个 extended example对于统计分布部分的单变量正态分布:

// [...] many headers and namespaces inclusions

int main()
{
// Construct a standard normal distribution s
normal s; // (default mean = zero, and standard deviation = unity)
cout << "Standard normal distribution, mean = "<< s.mean()
<< ", standard deviation = " << s.standard_deviation() << endl;

/*` First the probability distribution function (pdf).
*/
cout << "Probability distribution function values" << endl;
cout << " z " " pdf " << endl;
cout.precision(5);
for (double z = -range; z < range + step; z += step)
{
cout << left << setprecision(3) << setw(6) << z << " "
<< setprecision(precision) << setw(12) << pdf(s, z) << endl;
}
cout.precision(6); // default

// [...] much more
}

然后您可以使用 Eigen 进行必要的 vector 和矩阵操作以将标量传递给它。这blog posting有更多详细信息(尽管它使用 Boost.Random 生成示例值)。

关于c++ - 在 C++ 中实现多变量正态 pdf 以进行图像分类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17282956/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com