6

I have several png files that look similar to this this:

enter image description here

Everything is transparent but the black path. What I am trying to do is create a UIBezierPath from the non transparent part.

Edit: So I was thinking what about creating a mask with the png then from the mask go to a UIBezierPath. Would that work?

Edit Again: I found the solution, look at my answer.

Jonathan
  • 507
  • 5
  • 15
  • 1
    yikes. this is a hard problem - more like a science project than a coding question 1) need to extract points from the image, 2) need to fit a bezier to the data. Check out http://docs.opencv.org/doc/tutorials/ios/image_manipulation/image_manipulation.html for feature extraction, and http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/spline/Bezier/bezier-construct.html for Bezier derivation. – danh Mar 06 '13 at 16:18

2 Answers2

6

I went a different direction. Instead of using PNGs I went with SVG and used PocketSVG to parse the file. It works great.

Jonathan
  • 507
  • 5
  • 15
1

The process you're looking for is known as skeletonization, there's a good summary of techniques in this post: Determine the midline of a bent, elongated region

Community
  • 1
  • 1
kineticfocus
  • 492
  • 4
  • 16