提问人:Winnie Sheng 提问时间:11/18/2023 最后编辑:Christoph RackwitzWinnie Sheng 更新时间:11/19/2023 访问量:39
如何对复杂的验证码进行降噪?[关闭]
How can i denoise complicated captchas? [closed]
问:
有谁知道如何对这些验证码进行降噪?我正在尝试制作一个验证码识别器作为我的第一个机器学习项目(仅供个人使用),但不确定图像应该有多干净才能获得更好的准确性(我将手动标记它们)。以下是我能得到的最好的结果,但部分数字被删除,同时留下了一些噪音......如果有人能帮忙,非常感谢!!
这是我当前的代码:
def preprocess_image(src_filepath, dst_filepath):
image = cv2.imread(src_filepath, cv2.IMREAD_GRAYSCALE)
image = cv2.resize(image, (140, 48), interpolation=cv2.INTER_CUBIC)
_, binary_image = cv2.threshold(image, 125, 255, cv2.THRESH_BINARY_INV)
kernel = np.ones((2, 2), np.uint8)
opening = cv2.morphologyEx(binary_image, cv2.MORPH_OPEN, kernel, iterations=1)
closing = cv2.morphologyEx(opening, cv2.MORPH_CLOSE, kernel, iterations=1)
cleaned_image = cv2.bitwise_not(closing)
contours, _ = cv2.findContours(cleaned_image, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
for cnt in contours:
area = cv2.contourArea(cnt)
if area < 5:
cv2.drawContours(cleaned_image, [cnt], 0, (0,0,0), -1)
cv2.imwrite(dst_filepath, cleaned_image)
答: 暂无答案
评论