1 double m[4][4] = {1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0}; 2 Mat M = Mat(4, 4, CV_64F ,m); 3 4 Scalar sca=sum(M); 5 double sum= sca.val[0]; 6 cout<<sum<<endl; 7 cout<<sum/(M.rows*M.cols)<<endl;
相当于matlab两次means()
1 double m[4][4] = {1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0,16.0}; 2 Mat M = Mat(4, 4, CV_64F ,m); 3 4 Scalar sca=sum(M); 5 double sum= sca.val[0]; 6 cout<<sum<<endl; 7 cout<<sum/(M.rows*M.cols)<<endl;