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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM