I am trying to first remove the captcha numbers by thresholding and then eroding it ,to get slim continuous lines to get better output.
Problem:the eroded image is not continuous as u can see
Original Image:
Threshold Image:(Here digits area is to thick,so i want it to be shrink,slim and continous)
my output:
Desired Output/Result wanted:
code:
import os
import os.path
import cv2
import glob
import imutils
import matplotlib.pyplot as plt
import numpy as np
CAPTCHA_IMAGE_FOLDER = "generated_captcha_images"
OUTPUT_FOLDER = "extracted_letter_images"# Get a list of all the captcha images we need to process
captcha_image_files = glob.glob(os.path.join(CAPTCHA_IMAGE_FOLDER, "*"))
counts = {}# loop over the image paths
for (i, captcha_image_file) in enumerate(captcha_image_files):print("[INFO] processing image {}/{}".format(i + 1, len(captcha_image_files)))filename = os.path.basename(captcha_image_file)captcha_correct_text = os.path.splitext(filename)[0]image = cv2.imread(captcha_image_file)gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)thresh = cv2.threshold(gray, 36, 255, cv2.THRESH_BINARY_INV)[1]erode = cv2.erode(thresh, np.ones((2, 2), np.uint8), iterations=1)plt.imshow(erode, cmap="gray")plt.show()