I am supposed to have an image consisting of overlapping curves. What I have is an image where the curves are missing certain segments of them. However with the human eye we can tell that certain segments are part of the same curve. (see attached figures). I want to know how I can write a program to connect curves with splines that visually we know are related. In other words if I have a bunch of segments, how do I connect them with splines so that I get what my human eye is telling me is the correct match. This is a difficult problem so any reference would also be very helpful.