First time here? Check out the FAQ!
answered 2018-08-04 03:33:18 -0600
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);