Here is code which i am using in my program :
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;
The first thing is when ever i enter it like entropy -= binEntry * log2(binEntry);
it give me error on log2
, i added the libraries of math and numeric in VS 2010 , but still getting the error and the second point in the code is whenever i run it on the same video it give me different values on every execution , like if it give me 10.0 , 2.0 , 0.05
than the same frame on the next time running the program show me 8.0 , 1.5 , 0.01
these are sample values not exact