title: An alternative way to skeletonize in OpenCV Python?
body: <p>I'm trying to skeletonize the features below, in order to extract information about 1) the length of the features 2) the curvature of the features. I came across this <a href="http://opencvpython.blogspot.com/2012/05/skeletonization-using-opencv-python.html" rel="nofollow noreferrer">skeletonization approach</a>, which iteratively erodes and erodes the image. Shown below is the result - which looks awful. Can some one recommend a different approach to skeletonizing my features?</p>
  
  <p><a href="https://i.stack.imgur.com/2MCnW.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2MCnW.jpg" alt="enter image description here"></a><a href="https://i.stack.imgur.com/uWW5U.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uWW5U.png" alt="enter image description here"></a></p>
  
  <p>Here's the example from the link above:</p>
  
  <pre><code>import cv2
  import numpy as np
  
  img = cv2.imread('sofsk.png',0)
  size = np.size(img)
  skel = np.zeros(img.shape,np.uint8)
  
  ret,img = cv2.threshold(img,127,255,0)
  element = cv2.getStructuringElement(cv2.MORPH_CROSS,(3,3))
  done = False
  
  while( not done):
      eroded = cv2.erode(img,element)
      temp = cv2.dilate(eroded,element)
      temp = cv2.subtract(img,temp)
      skel = cv2.bitwise_or(skel,temp)
      img = eroded.copy()
  
      zeros = size - cv2.countNonZero(img)
      if zeros==size:
          done = True
  
  cv2.imshow("skel",skel)
  cv2.waitKey(0)
  cv2.destroyAllWindows()
  </code></pre>