0

Input Image I am trying to remove background gridlines from scanned images using OpenCV, till now I have used HoughLine methods to detect lines and fill it with white color. By this method I'm able to detect horizonal lines but not vertical lines. Here is my code

'''

import cv2
import numpy as np

def rmv_lines(Image_Path):
    img = cv2.imread(Image_Path)
    gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
    edges = cv2.Canny(gray,50,150,apertureSize = 3)
    minLineLength, maxLineGap = 100, 15
    lines = cv2.HoughLinesP(edges,1,np.pi/180,100,minLineLength,maxLineGap)
    for x in range(0, len(lines)):
        for x1,y1,x2,y2 in lines[x]:
        #if x1 != x2 and y1 != y2:
            cv2.line(img,(x1,y1),(x2,y2),(255,255,255),4)
    return cv2.imwrite('removed.jpg',img)

'''

Any help or suggestion...

rajneesh
  • 1
  • 1

0 Answers0