Mat grab = imread("image_grab\\grab_bak.bmp"); Mat g_gray; cvtColor(grab, g_gray, COLOR_BGR2GRAY); adaptiveThreshold(g_gray, g_dts, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, 7, -2); void adaptiveThreshold( InputArray src, //需要进行二值化的图像 OutputArray dst, //输出图像的二值图像; double maxValue, //非零值, 用于对满足条件的阈值进行赋值; int adaptiveMethod, //选择一种自适应阈值算法: ADAPTIVE_THRESH_MEAN_C // ADAPTIVE_THRESH_GAUSSIAN_C int thresholdType, //二值化类型: THRESH_BINARY // THRESH_BINARY_INV int blockSize, //参与计算的像素的领域范围使用奇数; double n); //计算过程中容忍程度;