I need to display all underlined texts from this type of image.
Or process with OpenCV so that only underlined texts remain on the photo
The volume of text in the photo is dynamic, this is just an example.
I tried this code example from Extract text with strikethrough from image
import cv2
img = cv2.imread('juFpe.png', cv2.IMREAD_GRAYSCALE)
thresh = cv2.threshold(img, 0, 255, cv2.THRESH_BINARY_INV )[1]
kernel = cv2.getStructuringElement(cv2.MORPH_RECT,(1,5))
kernel2=cv2.getStructuringElement(cv2.MORPH_RECT,(8,8))
detect_thin = cv2.morphologyEx(thresh, cv2.MORPH_OPEN, kernel)
detect_thin = cv2.morphologyEx(detect_thin, cv2.MORPH_DILATE, kernel2)
marker=cv2.compare(detect_thin, thresh,cv2.CMP_LT) # thin lines
while True: #morphological reconstruction
tmp=marker.copy()
marker=cv2.dilate(marker, kernel2)
marker=cv2.min(thresh, marker)
difference = cv2.subtract(marker, tmp)
if cv2.countNonZero(difference) == 0:
break
cv2.imwrite('lines.png', marker)
But it doesn't work in my example. You can adapt this code to my example or write your own
I do not have experience with OpenCV
question from:
https://stackoverflow.com/questions/65602319/extract-underlined-text-from-image-opencv 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…