title: thinning algorithm and post processing for binary images
body: <p>I have pictures of networks, and my goal is to process the images in order to extract the skeleton of the network.</p>
  
  <p>My approach lies in two steps :</p>
  
  <p>1) Going from grayscale image to binary image (Using local thresholding or Otsu method, and then a medianfilter (python function medfilt)</p>
  
  <p>2) Using thinning algorithms in order to extract the skeleton of the network.</p>
  
  <p><a href="https://i.stack.imgur.com/WXkRR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WXkRR.jpg" alt="original image"></a>
  <a href="https://i.stack.imgur.com/UWiMD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UWiMD.jpg" alt="Binary image"></a></p>
  
  <p><a href="https://i.stack.imgur.com/amMim.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/amMim.jpg" alt="Skeleton"></a></p>
  
  <p>Considering the quality of the first image, I'm pretty sure I can do a lot better than that. I thus have two question :</p>
  
  <p>1) Taking the last image, how would you remove all the small lines perpendendicular to the ridges, and the small gaps, that are artefacts ?</p>
  
  <p>2) What algorithm would you actually advise me to use for these two steps ?</p>