Removing background noisy lines from Captcha Image using PYTHON PIL

后端 未结 3 1581
庸人自扰
庸人自扰 2021-02-06 16:26

I have a processed captcha image(Enlarged) look like :
\"captcha\"

As you can see, the font-size of the \"TEXT\

相关标签:
3条回答
  • 2021-02-06 17:02

    You could use your own dilate and erode functions, wich will remove the smallest lines. A nice implementation can be found here.

    0 讨论(0)
  • 2021-02-06 17:02

    I personally use dilate and erode as stated above but combine that with some basic statistics for width and height, try to find outliers and eliminate those lines as needed. After that, a filter which takes the minimum value of a kernel and turns the central pixel that color in a temporary image (iterating down the old image) before using the temporary image as the original should work. In pillow/PIL the minimum based task is accomplished with img.filter(ImageFilter.MINFILTER).

    IF that is not enough, it should produce an identifiable set for which OpenCV's contours and minimum bounding rotated box can be used to rotate a letter for comparison (I reccomend Tesseract or a commercial OCR at this point since they have a ton of fonts and extra features like clustering and cleanup).

    0 讨论(0)
  • 2021-02-06 17:16

    To quickly get rid of most of the lines, you can turn all black pixels with two or less adjacent black pixels white. That should fix the stray lines. Then, when you have a lot of "blocks" you can remove the smaller ones.

    This is assuming the sample image has been enlarged, and the lines are only one pixel wide.

    0 讨论(0)
提交回复
热议问题