Page 1 of 1

### Need to remove line from image

Posted: Fri Jun 15, 2018 2:39 pm
I'm spending lots of time searching a way to remove straight line from the image but still no luck. Please someone help me .... I attached sample image
sample-2.gif (12.2 KiB) Viewed 4572 times
.

### Re: Need to remove line from image

Posted: Fri Jun 15, 2018 4:18 pm
sample-1.gif (11.26 KiB) Viewed 4568 times
another sample image

### Re: Need to remove line from image

Posted: Sat Jun 16, 2018 5:54 pm
Have a look at Hough Transformation (OpenCV tutorial). It will not be easy though, but something to start from.

### Re: Need to remove line from image

Posted: Sat Jun 16, 2018 7:04 pm
Thanks Andrew, I'm start looking at it, will give update
andrew.kirillov wrote:Have a look at Hough Transformation (OpenCV tutorial). It will not be easy though, but something to start from.

### Re: Need to remove line from image

Posted: Sun Jun 17, 2018 10:55 pm
I found this code,but detect only 1 line not all line. need help ..

# Python program to illustrate HoughLine
# method for line detection
import cv2
import numpy as np

# Reading the required image in
# which operations are to be done.
# Make sure that the image is in the same
# directory in which this python program is

# Convert the img to grayscale
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

# Apply edge detection method on the image
edges = cv2.Canny(gray,50,150,apertureSize = 3)

# This returns an array of r and theta values
lines = cv2.HoughLines(edges,1,np.pi/180, 200)

# The below for loop runs till r and theta values
# are in the range of the 2d array
for r,theta in lines[0]:

# Stores the value of cos(theta) in a
a = np.cos(theta)

# Stores the value of sin(theta) in b
b = np.sin(theta)

# x0 stores the value rcos(theta)
x0 = a*r

# y0 stores the value rsin(theta)
y0 = b*r

# x1 stores the rounded off value of (rcos(theta)-1000sin(theta))
x1 = int(x0 + 1000*(-b))

# y1 stores the rounded off value of (rsin(theta)+1000cos(theta))
y1 = int(y0 + 1000*(a))

# x2 stores the rounded off value of (rcos(theta)+1000sin(theta))
x2 = int(x0 - 1000*(-b))

# y2 stores the rounded off value of (rsin(theta)-1000cos(theta))
y2 = int(y0 - 1000*(a))

# cv2.line draws a line in img from the point(x1,y1) to (x2,y2).
# (0,0,255) denotes the colour of the line to be
#drawn. In this case, it is red.
cv2.line(img,(x1,y1), (x2,y2), (0,0,255),2)

# All the changes made in the input image are finally
# written on a new image houghlines.jpg
cv2.imwrite('linesDetected.jpg', img)

### Re: Need to remove line from image

Posted: Fri Aug 03, 2018 9:08 pm
mabruk wrote:I'm spending lots of time searching a way to remove straight line from the image

(I believe, the topicstarter find a solution)

This captcha type can be solved (accuracy 100%) without removing this lines, without any smart algoritms, even without Statistic.

Just binarisation: background color - false; any another color - true; you get 2D boolean array and looking for prepared templates arrays.

Similar situation with any images created by computer programs, e.g. screenshots, reports. Just different algorithms binarisation and prepared templates. Pluses are - accuracy practically 100%, very fast, very easy algorithm. Minuses - need prepare templates each time, it useless for another similar task, and if in future something will be changed on input images, this program is absolute not robust for it.