title: Calculating the tangent on a transition point of a black and white image
body: <p>I would like to calculate the angle of the tangent on a given white to black transition point on an image that consists entirely of black and white pixels and displays simple shapes such as squares, circles or triangles.</p>
  <p>Zooming in on an image like that would look like this:</p>
  <p><a href="https://i.stack.imgur.com/TZiW0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TZiW0.png" alt="enter image description here" /></a></p>
  <p>If you were to pick any of the black pixels next to a white one, my solution would be to follow the edge for a few pixels, then define a formula based on the curvature of the pixels and calculate the exact value of the defined point. Is there a simpler way of doing that? The resolution of the images is around 800x600 pixels so a fairly accurate estiamate of the angle of the provided point should be possible.</p>
  <p>In my current approach I follow the edge line of the shape for about ten pixels, but I'm not sure where to go from there. Is there a library that already performs this kind of calculation for you? How many pixels would you need in order to be able to make an accurate judgement of the angle at that point?</p>