Refining lines in an image with openCV
If you are trying to remove the gaps during hough transform, you can set minLineLength(Minimum length of line. Line segments shorter than this are rejected) and maxLineGap (Maximum allowed gap between line segments to treat them as single line) in cv2.HoughLinesP()

EDIT

Some results from the morphological operations: