MATLAB: How to connect the nerves together

image processingimage segmentationMATLAB

Hello every one
I have this segmented image with a lot of breaks between the detected nerves as shown in the attached image. How can I connect them together?
Your help in this regard is highly appreciated.

Best Answer

The expected output image is like this: