title: Python Stroke Width Transform
body: <p>I'm trying to implement the Stroke Width Transform in Python. I have gone through numerous stack overflow questions and answers and other resources on the internet but have not found an implementation for it. So I decided to try on my own.</p>
  
  <p>After performing Canny edge detection, my first step is to calculate the x and y derivatives of the image</p>
  
  <pre><code>sobelx = cv2.Sobel(img,cv2.CV_64F,1,0,ksize=5)
  sobely = cv2.Sobel(img,cv2.CV_64F,0,1,ksize=5)
  </code></pre>
  
  <p>How do I then combine these to get the gradient at each point in the image? Also, how do I then calculate the width of the stroke?</p>
  
  <p>I'm using the steps given in the original <a href="http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=5540041" rel="nofollow noreferrer">IEEE Paper</a> (freely accessible paper direct from Microsoft <a href="https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/1509.pdf" rel="nofollow noreferrer">here</a>) for reference. The description of the steps is on the bottom of the right hand side on page 3.</p>