Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Whatever you're trying to do this is a terrible way to do it. You're trying to get the mean and standard deviation for each element of a vector, I think?

The technical problem is that rata is not a number, or a Mat the same size as chg[s]. Basically, subtract can remove a single number from every element of the matrix (pass in a double for 1 channel or a Scalar for multiple channels). It can also subtract one matrix from the other, but they must be the same size and number of channels.

The smarter way to do this is this

Mat allVec(ay[0].size(), 4, CV_32F);//Or whatever code matches the type of the vectors.
for(int abc = 0; abc<4; abc++)
    Mat(ay[abc]).copyTo(allVec.col(0));

for(int size = 0; size<ay[0].size(); size++)
{
    Scalar mean, stdDev;
    meanStdDev(allVec.row(size), mean, stdDev);
    std::cout<<"Element 1 Mean = "<<mean(0)<<" StdDev = "<<stdDev(0)<<endl;
}