从具有线条和曲线噪声的图像中提取代码

时间:2019-06-20 13:04:52

标签: python python-imaging-library tesseract

我正在尝试使用python和tesseract从附加的图像中提取代码。但是,我的尝试没有成功。我只能继续下面的代码。

代码:

def get_captcha_text(self):        
    self.im = Image.open(self.PATH)
    self.im = self.im.filter(ImageFilter.MedianFilter()) # blur the image, the stripes will be erased
    self.im = ImageEnhance.Contrast(self.im).enhance(2)  # increase the contrast (to make image clear?)
    self.im = self.im.convert('1')                       # convert to black-white image
    self.im.save(self.PATH)
    self.text = image_to_string(self.im, config ="--psm 11 -c tessedit_char_whitelist=0123456789abcdfghijkmnlopqrsturstuvwxyzABCDEFGHIJKMNLOPQRSTUVWXYZ")
    print ("text={}".format(self.text))

图片:

View image here

结果:qjm

您能建议一些代码来清洁图像并提取信息而没有问题吗?

0 个答案:

没有答案