Line endpoint detection
Hi, I would like to find enpoints of lines in my image and then connect them to fix line breaks. The blue part in the image are the line breaks I would like to fix. The green part is the houghline detected.
I have tried probabilistic hough transform but it is detecting only one line instead of all the lines. What other methods can be used for this purpose? Please guide or provide me with relevant literature. Thank you.
import numpy as np
import cv2
import matplotlib.pyplot as plt
img = cv2.imread(r"C:\Users\Sachet\Desktop\7c563eea-8b71-4cb9-8136-ce445ce10fde.jpg")
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray,50,150,apertureSize = 3)
#cv2.imshow('lol',edges)
minLineLength = 40
maxLineGap = 5
lines = cv2.HoughLinesP(edges,1,np.pi/180,100,minLineLength,maxLineGap)
for x1,y1,x2,y2 in lines[0]:
cv2.line(img,(x1,y1),(x2,y2),(0,255,0),2)
cv2.imwrite(r"C:\Users\Sachet\Desktop\houghlines5.jpg",img)
I would hesitate to simply "fix" electrical diagrams. it's a visual language. if you make non-connecting lines cross, you have to also signify connecting lines, but differently. that would typically be a bold dot on the intersection. your diagram doesn't show this style used.