Mat class: element access II
{"Image DocumentName": "Mat class: element access II", "Image ImageDescription": "Old C style. // compute sum of positive matrix elements. double sum=0; for(int i = 0; i < M.rows; i++) { const double  Mi = M.ptr<double>(i); //we know it s double data. for(int j = 0; j < M.cols; j++) sum += std::max(Mi[j], 0.); } STL-like iterators. // compute sum of positive matrix elements, iterator-based variant. MatConstIterator_<double> it = M.begin<double>(), it_end = M.end<double>(); for(; it != it_end; ++it) sum += std::max( it, 0.); This iterators can be used with STL functions, like std::sort() 26/10/11.", "Image XResolution": "37", "Image YResolution": "37", "Image ResolutionUnit": "Pixels/Centimeter", "Image Software": "SlidePlayer", "Image YCbCrPositioning": "Centered"}