void minMaxLoc(const SparseMat& a, double* minVal,
double* maxVal, int* minIdx = 0, int* maxIdx = 0);
统计图像中最小最大值,并返回最小最大值的像素点位置
void meanStdDev(InputArray src, OutputArray mean, OutputArray stddev,
InputArray mask=noArray());
计算mask区域内的均值及标准差。入参没有mask则统计全图的。
void OpencvExample::Example_PixelStat(Mat &image)
{
Mat gray,mean,stddev;
double minValue, maxValue;
Point minPoint, maxPoint;
cvtColor(image, gray, COLOR_BGR2GRAY);
imshow("gray",gray);
//输入只能是单通道图像
minMaxLoc(gray, &minValue, &maxValue, &minPoint, &maxPoint);
cout << "maxvalue: " << maxValue << "minValue: " << minValue << endl;
cout << "maxPoint: " << maxPoint<<"minPoint: "<< minPoint <<endl;
//输入既可以是单通道也可以多通道
meanStdDev(gray, mean,stddev);
cout << "mean: " << mean << "stddev: " << stddev << endl;
}