python3 验证码去噪

  处理前图像:

  

  处理后图像

  

  代码

#coding:utf8
import os
from PIL import Image,ImageDraw,ImageFile
import numpy
import pytesseract
import cv2
import imagehash
class pictureIdenti:
    # 点降噪
    def clearNoise(self, img_name="D:\work\python36_crawl\pictureParser\V10.png", x=0, y=0):
        if os.path.exists(img_name):
            image = Image.open(img_name)
            image = image.convert('L')
            image = numpy.asarray(image)
            image = (image > 135) * 255
            image = Image.fromarray(image).convert('RGB')

            # image.show()
            save_name = "D:\work\python36_crawl\pictureParser\V19.png"
            image.save(save_name)
            return image

猜你喜欢

转载自www.cnblogs.com/shaosks/p/9700262.html