In my project I am extracting the lines of an image with openCV2 by firstly creating a skeleton: I convert it to a binary image, invert it (to make it work with morphological operations) and then perform a bunch of morphological operations. Then I apply the canny edge detector on the skeleton and perform a Hough transformation.
Now the important part: In order to remove the gaps I perform a closing operation. My problem now is that there are still some gaps and fragments and I can't apply the closing operation one more time because its idempotent (only applicable once).
I want to refine the lines by closing all gaps and possibly thicken the lines. How may I achieve this?
Here some images to illustrate my problem.
Original image
Processed image
See those tiny lines which protrude from the edges? Or the interruptions in a straight line?
For the gaps in the lines I thought about looping through the matrix and if the points left and right of a pixel are 1 (drawn), then that particular pixel should also be set to 1. Would that be a good solution?