Cleaning up captcha image

前端 未结 3 1534
忘掉有多难
忘掉有多难 2021-02-01 19:12

I\'m trying to clean up the image above I\'ve tried several different methods using open cv, I either erode the original image too much to the point where parts of the

3条回答
  •  自闭症患者
    2021-02-01 19:47

    Take a closer look to your captcha. most of the dust in that image has a different grayscale value than the text.

    The text is in 140 and the dust is in 112.

    A simple grayscale filtering will help a lot here.

    from scipy.misc import imread, imsave
    import numpy as np
    
    infile = "A1nO4.png"
    outfile = "A1nO4_out.png"
    
    im = imread(infile, True)
    out_im = np.ones(im.shape) * 255
    
    out_im[im == 140] = 0
    
    imsave(outfile, out_im)
    

    Now use cv2.dilate (cv2.erode on a white on black text) to get rid of the remaining dust.

提交回复
热议问题