1 | initial version |
A simple solution could be to try a nearest neighbor approach, which may or may not work but will certainly be very slow. For every white pixel in the image find the nearest white pixels within a short distance range. If found, create a line between the two points. This could be speed up by skipping pixels;
An even simpler solution would be be to blur the image a few times, such that you would have a vague gray blur in the gap area. Then threshold the image such that anything not black becomes white.