openCV minMaxLoc

    xiaoxiao2021-03-25  104

    转自: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),不使用不传递即可

    /

    OpenCV 中 minMaxLoc 用法

    函数原型:  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

    转载请注明原文地址: https://ju.6miu.com/read-34882.html

    最新回复(0)