如何清理验证码图像?

2024-09-30 20:21:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图清除验证码并去掉线路

原始图像:

enter image description here

这就是我目前的情况:

enter image description here

img_raw = cv2.imread("captcha.png", cv2.IMREAD_GRAYSCALE)
img_raw = cv2.bitwise_not(img_raw)
kernel = np.ones((0, 0), np.uint8)
img_m = cv2.morphologyEx(img_raw, cv2.MORPH_OPEN, kernel)
newkernel = np.ones((0, 0), np.uint8)
img_e = cv2.erode(img_m, newkernel, iterations=1)
img_e = cv2.bitwise_not(img_e)
ret,img_final = cv2.threshold(img_e,100,255,cv2.THRESH_BINARY)

试图找出如何改善结果,如果有任何提示,我们将不胜感激


Tags: 图像imgrawnponesnot情况cv2