i'm try to get covariance matrix from an image stored in cv::Mat. i need it for calculate mahalanobis distance and attempt to some color segmentation.

this is my code:

```
Mat covar, selection, meanBGR;
selection = src(roi);
calcCovarMatrix(selection, covar, meanBGR, CV_COVAR_NORMAL|CV_COVAR_ROWS);

```

the Mat src is from webcam and standard BGR opencv format, so CV\_32FC3. pixels are stored (i think) in row vector order (blue, green, red).. so i think my code is correct. but i recive this runtime error:

> 
> Assertion failed (src.channels() == 1) in mulTransposed
> 
> 
> 

i tried to make a vector too in this way:

```
vector<Scalar> samples;

for(int i=0; i<selection.rows; i++) {
    for(int j=0; j<selection.cols; j++) {

        Scalar pixel = selection.at<Scalar>(i,j);
        Scalar sample(pixel[0], pixel[1], pixel[2]);
        samples.push_back(sample);
    }
}

calcCovarMatrix(samples, covar, meanBGR, CV_COVAR_NORMAL|CV_COVAR_ROWS);

```

but i always get the same error. reading the [manual](http://opencv.willowgarage.com/documentation/cpp/core_operations_on_arrays.html#calcCovarMatrix) doesn't make any kind of idea.