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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM