Another, simpler way, which is probably better converted to OpenCV , since it uses convolution rather than serial Perl / C code.
Basically set all black pixels to 10 and all white pixels to 0 , then collapse the image with the following 3x3 core:
1 1 1 1 10 1 1 1 1
Now the black pixel in the middle of the kernel will give 100 (10x10), and any other black pixel in the neighborhood will give 10 (10x1). Therefore, if we need points with a central black pixel with one adjacent black pixel, it will have a value of 110 (100 + 10). So let the color of all pixels having a value of 110 V with red. This gives the following command:
convert EsmKh.png -colorspace gray -fill gray\(10\) -opaque black -fill gray\(0\) -opaque white -morphology convolve '3x3: 1,1,1 1,10,1 1,1,1' -fill red -opaque gray\(110\) out.png
with the resulting image (you may need to increase the spaces to see red):

If you need a list of red pixels, replace the output file name with txt: and search as follows:
convert EsmKh.png -colorspace gray -fill rgb\(10,10,10\) -opaque black -fill rgb\(0,0,0\) -opaque white -morphology convolve '3x3: 1,1,1 1,10,1 1,1,1' txt: | grep "110,110,110"
which gives:
86,55: (110,110,110) #6E6E6E grey43 459,55: (110,110,110) #6E6E6E grey43 83,56: (110,110,110) #6E6E6E grey43 507,59: (110,110,110) #6E6E6E grey43 451,64: (110,110,110) #6E6E6E grey43 82,65: (110,110,110) #6E6E6E grey43 134,68: (110,110,110) #6E6E6E grey43 519,75: (110,110,110) #6E6E6E grey43 245,81: (110,110,110) #6E6E6E grey43 80,83: (110,110,110) #6E6E6E grey43 246,83: (110,110,110) #6E6E6E grey43 269,84: (110,110,110) #6E6E6E grey43 288,85: (110,110,110) #6E6E6E grey43 315,87: (110,110,110) #6E6E6E grey43 325,87: (110,110,110) #6E6E6E grey43 422,104: (110,110,110) #6E6E6E grey43 131,116: (110,110,110) #6E6E6E grey43 524,116: (110,110,110) #6E6E6E grey43 514,117: (110,110,110) #6E6E6E grey43 122,118: (110,110,110) #6E6E6E grey43 245,122: (110,110,110) #6E6E6E grey43 76,125: (110,110,110) #6E6E6E grey43 456,128: (110,110,110) #6E6E6E grey43 447,129: (110,110,110) #6E6E6E grey43 245,131: (110,110,110) #6E6E6E grey43 355,135: (110,110,110) #6E6E6E grey43 80,146: (110,110,110) #6E6E6E grey43 139,151: (110,110,110) #6E6E6E grey43 80,156: (110,110,110) #6E6E6E grey43 354,157: (110,110,110) #6E6E6E grey43 144,160: (110,110,110) #6E6E6E grey43 245,173: (110,110,110) #6E6E6E grey43 246,183: (110,110,110) #6E6E6E grey43 76,191: (110,110,110) #6E6E6E grey43 82,197: (110,110,110) #6E6E6E grey43 126,200: (110,110,110) #6E6E6E grey43 117,201: (110,110,110) #6E6E6E grey43 245,204: (110,110,110) #6E6E6E grey43 248,206: (110,110,110) #6E6E6E grey43 297,209: (110,110,110) #6E6E6E grey43 309,210: (110,110,110) #6E6E6E grey43
Now you can process the list of red dots, and for each of them find the nearest other red dot and connect them with a straight line - or make some curve if you feel very sharp. Of course, there may be some kind of processing, and you can set the maximum length of the gap filling line.