Удаление фоновых шумных линий из изображения Captcha с помощью PYTHON PIL

У меня обработанное изображение капчи (увеличено) выглядит так:

Как видите, размер шрифта "ТЕКСТ" немного больше, чем ширина шумных линий.

Поэтому мне нужен алгоритм или код для удаления шумных линий с этого изображения.

С помощью библиотеки Python PIL и алгоритма измельчения, упомянутого ниже, яt получить выходное изображение, которое может быть легко прочитано с помощью OCR.

Вот'Код Python, который я пробовал:

import PIL.Image
import sys

# python chop.py [chop-factor] [in-file] [out-file]

chop = int(sys.argv[1])
image = PIL.Image.open(sys.argv[2]).convert('1')
width, height = image.size
data = image.load()

# Iterate through the rows.
for y in range(height):
    for x in range(width):

        # Make sure we're on a dark pixel.
        if data[x, y] > 128:
            continue

        # Keep a total of non-white contiguous pixels.
        total = 0

        # Check a sequence ranging from x to image.width.
        for c in range(x, width):

            # If the pixel is dark, add it to the total.
            if data[c, y] < 128:
                total += 1

            # If the pixel is light, stop the sequence.
            else:
                break

        # If the total is less than the chop, replace everything with white.
        if total 

Ответы на вопрос(3)

Ваш ответ на вопрос