# 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

your usage of Mat::reshape() looks broken. why is it even there ? please explain.

@berak Don't know where my initial comment went to.. I'll repeat it. I used reshape to convert the matrix to a 6-channel 2x6, which makes the function calculate the mean/standard deviation for each column individually. If I leave it out then it seems that the matrix is taken as a 1-channel 2x6 matrix and that gives me one value for the mean and standard deviation values calculated across all matrix columns and rows.

may i ask: which beast requires a 6 channel mat ?

@berak Maybe let me put it this way, how I can get the mean value per column for a given square matrix using meanStdDev() or a similar function?