I have this source image:
My goal is to remove the bottom line while keep the letters/numbers untouched.
This is the code I use:
import cv2
import numpy as np
img = cv2.imread('src.png')
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray,100,200,apertureSize = 5)
minLineLength = 0
maxLineGap = 19
lines = cv2.HoughLinesP(edges,1,np.pi/180,15,minLineLength,maxLineGap)
for x in range(0, len(lines)):
for x1,y1,x2,y2 in lines[x]:
cv2.line(img,(x1,y1),(x2,y2),(255,255,255),2)
cv2.imshow('hough',img)
cv2.waitKey(0)
The best result I achieved by now is this:
How can I improve it more, to clean the image as much as possible ? For example, all the debris all around the image, points and (still) lines under the words, how can I remove them ?
Thank you.
OT: is there a way to create a trackbar of this which change the parameters (apertureSize, minLineLength, maxLineGap, etc) to see results in real time ?
As per @Link 's request:
I have limited experience in python so I don't know how thread safe this code is, but this should show you the basics of creating trackbars in python OpenCV.