图像像素值统计
统计图像中像素的最大值、最小值、以及对应的点坐标
minMaxLoc(img, &minv, &maxv, &minLoc, &maxLoc);(//minMaxLoc的输入需要是单通道)
统计图像像素的方差。
meanStdDev(img, mean, stddev);
void QuickDemo::pixel_statistic_demo(Mat &image) {
double minv, maxv;
Point minLoc, maxLoc;
std::vector<Mat> vec, mv;
//minMaxLoc的输入需要是单通道
split(image, mv);
for (int i = 0; i < mv.size(); i++) {
minMaxLoc(mv[i], &minv, &maxv, &minLoc, &maxLoc);
std::cout << "No. channels:" << i << " min value:" << minv << " max value:" << maxv
<< "maxPoint:" << maxLoc << "minPoint" << minLoc << std::endl;
}
Mat mean, stddev;//求均值和标准差
Mat redback = Mat::zeros(image.size(), image.type());
redback = Scalar(40, 40, 200);
meanStdDev(redback, mean, stddev);
imshow("redback", redback);
std::cout << "means:" << mean << std::endl;
std::cout<< " stddev:" << stddev << std::endl;
}