I want to remove the colored circles in the picture below. Please advise how to do this with opencv
pic1
pic2
Things I tried :
import pytesseract
import cv2
import numpy as np
from PIL import Image
image = cv2.imread("captcha.jpg")
assert image is not None, "file could not be read, check with os.path.exists()"
gray = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
ret, thresh = cv2.threshold(gray,0,255,cv2.THRESH_BINARY_INV+cv2.THRESH_OTSU)
cv2.imwrite("captcha2.jpg", thresh)
image=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
se=cv2.getStructuringElement(cv2.MORPH_RECT , (8,8))
bg=cv2.morphologyEx(image, cv2.MORPH_DILATE, se)
out_gray=cv2.divide(image, bg, scale=255)
out_binary=cv2.threshold(out_gray, 0, 255, cv2.THRESH_OTSU )[1]
cv2.imwrite("captcha1.jpg", out_binary)
New contributor
Pouriya Asakereh is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.