1

我期待實現C++多元正態分佈PDF [1]每個像素中的一類圖像會員分配,即裏用C實現多元正態分佈PDF ++用於圖像分類

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)。

回答

0

我不知道現成的一步式解決方案。對於兩步混合和匹配的方式,你可以熟悉Boost.Math這對於在統計分佈部分單變量正常distrubtion的:

// [...] 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 
    } 

然後,您可以使用本徵辦必要的向量和矩陣操作來傳遞標量。這blog posting有更多的細節(儘管它使用Boost.Random來生成樣本值)。