I'm trying to convert an image that looks like:
Into one that looks something like (I drew this):
I want to detect and draw lines in the image where the thick/thin sections are smoothed out to create a somewhat even width and where the lines are overlapping if the pixels in the image are touching. (if you zoom in on the original image you can see even the thin segments do have pixels connecting them)
The two problems I'm running into are:
- Thin sections of pixels in the original image end up broken up. So the pixels of the transformed image are not overlapping where they are in the original, thus creating gaps in the lines.
- Some of the lines are close enough together, that if I dilate things to try and fix #1, the detected lines end up overlapping each other where they shouldn't.
I'm currently trying to mess with Canny/Hough to get this working, but thus far have been unsuccessful.
edges = cv2.Canny(img, 50, 200, None, 3)
hough_img = np.copy(img) * 0 # creating a blank to draw lines on
lines = cv2.HoughLinesP(img, rho=1, theta=np.pi / 180, threshold=35, lines=np.array([]),
minLineLength=3, maxLineGap=2)
for line in lines:
for x1, y1, x2, y2 in line:
cv2.line(hough_img, (x1, y1), (x2, y2), (255, 0, 0), 2)




