Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

we can use:

Scalar m = cv::mean(img);
Mat bin = img > m[0]; // syntax sugar for 'threshold()'

but better, opencv has an automatic threshold method:

Mat bin;
cv::threshold(img, bin, 0, 255, THRESH_OTSU);