minMaxLoc opencv

来源:互联网 发布:什么是高阶数据 编辑:程序博客网 时间:2024/04/29 13:42

转自:http://www.cnblogs.com/xiangwengao/archive/2012/03/27/2419831.html 

函数原型:
void minMaxLoc( const Mat& src,  double* minVal, double* maxVal=0, Point* minLoc=0, Point* maxLoc=0, const Mat& mask=Mat() );
void minMaxLoc(const MatND& src, double* minVal, double* maxVal, int* minIdx=0, int* maxIdx=0, const MatND& mask=MatND() );
void minMaxLoc(const SparseMat& src, double* minVal, double* maxVal, int* minIdx=0, int* maxIdx=0);

说明:
1  minMaxLoc寻找矩阵(一维数组当作向量,用Mat定义) 中最小值和最大值的位置.
2  参数若不需要,则置为NULL或者0,即可.
3  minMaxLoc针对Mat和MatND的重载中 ,第5个参数是可选的(optional),不使用不传递即可.

代码:
Mat tmpCount(8, 1, CV_32FC1);
float tmpCountMinVal = 0, tmpCountMaxVal = 0;
Point minPoint, maxPoint;
minMaxLoc(tmpCount, &tmpCountMinVal, &tmpCountMaxVal, &minPoint, &maxPoint);
minMaxLoc(temp1, &minVal, NULL, &minCoor,NULL);    // 不需要的数据,参数置为NULL
cout<<minVal<<endl;
minMaxLoc(temp1, 0, &maxVal, 0,& maxCoor);    // 不需要的置为0
cout<<maxVal<<endl;


结果:
10.9525 13.4054 17.6646 10.5643 1.22926 5.95938 11.14 4.83435
1.22926 17.6646
1.22926
17.6646

原创粉丝点击