A few lines of code to make your picture will be clear

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/weixin_44517301/article/details/100060544
# coding=utf-8
import cv2
import numpy as np

img = cv2.imread('shuiyin.png')
retval, thre = cv2.threshold(img, 12, 255, cv2.THRESH_BINARY)

grayscal = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
retval1, thre1 = cv2.threshold(grayscal, 12, 255, cv2.THRESH_BINARY)
gaus = cv2.adaptiveThreshold(grayscal, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 155, 1)
cv2.imshow('re1', img)
cv2.imshow('re2', thre)
cv2.imshow('re3', thre1)
cv2.imshow('re4', gaus)
cv2.waitKey(0)
cv2.destroyAllWindows()

Here Insert Picture Description
Here Insert Picture Description

Here Insert Picture Description
Here Insert Picture Description

Guess you like

Origin blog.csdn.net/weixin_44517301/article/details/100060544