1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#include <iostream> #include <opencv2/core/core.hpp> #include <opencv2/imgcodecs/imgcodecs.hpp> #include <opencv2/highgui/highgui.hpp> using namespace cv; using namespace std; int main() { cout << CV_VERSION << endl; Mat lena = imread("1.jpg"); Mat lenaGray = imread("1.jpg",0); double min, max; Point minLoc, maxLoc; minMaxLoc(lenaGray, &min, &max, &minLoc, &maxLoc); cout << "最小值:" << min << ", 位于:" << minLoc << endl; cout << "最大值:" << max << ",位于:" << maxLoc << endl; //if you're focus in specified rect //Rect roi = Rect(0,0,5,5); //Scalar scalar = mean(lena(roi)); Scalar scalar = mean(lena); cout << "平均值:" << scalar << endl; Mat meanMat,stdDevMat; meanStdDev(lena, meanMat, stdDevMat); cout << "平均值:" << meanMat << endl; cout << "标准差:" << stdDevMat << endl; waitKey(0); return 0; } |