转载自:https://blog.csdn.net/Gaowang_1/article/details/103129311
cv2.threshold()函数的作用是将一幅灰度图二值化,基本用法如下:
#ret:暂时就认为是设定的thresh阈值,mask:二值化的图像
ret,mask = cv2.threshold(img2gray,175,255,cv2.THRESH_BINARY)
plt.imshow(mask,cmap='gray')
上面代码的作用是,将灰度图img2gray中灰度值小于175的点置0,灰度值大于175的点置255
具体用法如下:
threshold(src, thresh, maxval, type[, dst])->ret,dst
src::灰度图
thresh:阈值
maxval:最大值
type:阈值类型