I have these images and I want to eliminate the lines that appear, so that the date remains without any other noise. How can I do it in python with openCV?
Advertisement
Answer
JavaScript
x
22
22
1
import cv2
2
import numpy as np
3
4
img = cv2.imread('img.jpg')
5
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
6
edges = cv2.Canny(gray,50,150,apertureSize = 3)
7
8
lines = cv2.HoughLines(edges,1,np.pi/180,100)
9
for rho,theta in lines[0]:
10
a = np.cos(theta)
11
b = np.sin(theta)
12
x0 = a*rho
13
y0 = b*rho
14
x1 = int(x0 + 1000*(-b))
15
y1 = int(y0 + 1000*(a))
16
x2 = int(x0 - 1000*(-b))
17
y2 = int(y0 - 1000*(a))
18
19
cv2.line(img,(x1,y1),(x2,y2),(255,255,255),10)
20
21
cv2.imwrite('output.jpg',img)
22