Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Issue with meanStdDev() result and Mat channels

meanStdDev() is not giving the correct calculation of mean and standard. I want it to give mean/stdev for each corresponding column. The code follows,

Mat_<int> C = (Mat_<int>(2,6) << 1, 0, 3, 1, 0, 5, 6, 2, 0, 4, 0, 9), E=Mat::zeros(9, 9, CV_8UC1); 
Mat mn, stdev; 
meanStdDev(C.reshape(C.cols),mn,stdev); 
std::cout << C.reshape(C.cols) << endl<< mn << std::endl;

It gives the following results,

[1, 0, 3, 1, 0, 5; 
 6, 2, 0, 4, 0, 9]

[2.5;
 1;
 0;
 0;
 0;
 0]

You can see that the calculated mean value is corrent only for the first 2 positions