I have an image where I have a horizontal line underlying the text ; after applying through various techniques in order a. HoughLineP and HoughLine and this code
image = cv2.imread('D:\\detect_words.jpg')
gray = 255 - cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
for row in range(gray.shape[0]):
avg = np.average(gray[row, :] > 16)
if avg > 0.25:
cv2.line(image, (0, row), (gray.shape[1]-1, row), (0, 0, 255))
cv2.line(gray, (0, row), (gray.shape[1]-1, row), (0, 0, 0), 1)
cv2.imwrite('D:\\words\\final_removed.jpg',image)
after this phase; I am applying erosion and dilation
kernel = np.ones((3,3), np.uint8)
img_erosion = cv2.erode(255-gray, kernel, iterations=1)
img_dilation = cv2.dilate(img_erosion, kernel, iterations=1)
cv2.imwrite('D:\\words\\final_removed4.jpg',255-img_dilation)
My question is; removing the horizontal lines although removes but there is pixel loss for words; and not all the horizontal lines are removed. Is there a novel approch where this loss can be minimized and all horizontal lines are removed (here the horizontal lines above AGE is still present).