這裏就是我用我的程序代碼:熵變的值在每次執行
calcHist(&pre_img, 1, channels, Mat(), // do not use mask
hist, 1, histSize, ranges,
true, // the histogram is uniform
false);
Mat histNorm = hist/(pre_img.rows * pre_img.cols);
double entropy = 0.0;
for (int i=0; i<histNorm.rows; i++)
{
float binEntry = histNorm.at<float>(i,0);
if (binEntry != 0.0)
{
entropy -= binEntry * log(binEntry);
}
}
cout<<entropy<<endl;
的第一件事就是當過我進入它像entropy -= binEntry * log2(binEntry);
它給我的錯誤上log2
,我增加了庫的數學和數字在VS 2010中,但仍然得到的錯誤,並在代碼中的第二點是每當我運行它在同一個視頻它給我不同的值在每次執行,如果它給我10.0 , 2.0 , 0.05
比同一幀上下次運行程序給我看8.0 , 1.5 , 0.01
these are sample values not exact
你看到了什麼錯誤? –
@AlanStokes標識符log2未定義# – Pieter
你有'#include'嗎? –