#include
#include
#include
int main(int argc, char** argv) {
cv::Mat src(5, 4, CV_8UC3, cv::Scalar(10,20,30));
std::cerr << src << std::endl;
cv::Mat mean, stddev;
cv::meanStdDev(src,mean, stddev);
double m = 0, sd = 0;
std::cerr << mean << std::endl;
m = mean.at<double>(0, 0);//返回第一通道均值
std::cerr << "第一通道均值=" < std::endl;
m = mean.at<double>(1, 0);//返回第二通道均值
std::cerr << "第二通道均值=" << m << std::endl;
m = mean.at<double>(2, 0);//返回第三通道均值
std::cerr << "第三通道均值=" << m << std::endl;
std::cerr << stddev << std::endl;
sd = stddev.at<double>(0, 0); //返回第一通道标准偏差
std::cerr << "第一通道标准偏差=" << sd << std::endl;
sd = stddev.at<double>(1, 0); //返回第二通道标准偏差
std::cerr << "第二通道标准偏差=" << sd << std::endl;
sd = stddev.at<double>(2, 0); //返回第三通道标准偏差
std::cerr << "第三通道标准偏差=" << sd << std::endl;
cv::waitKey(0);
return 0;
}