I got an artist to draw up a test set for me.
The core of it is a function called "GetRealCorners", which takes a Bezier path,
and returns the real corners. A Bezier path has a corner if the two handles at
a knot point don't form a straight line. But a mathematical corner could represent
either a real corner in the underlying image, or local noise.
So what I am doing is taking ten pixels in curve space on each side of the corner.
If either the leading or the trailing sample isn't at least three times a long as it is
wide, as measured by the bounding box, I say that the corner isn't real. If any
of the leading or the trailing curves overhangs the corner, I say the corner isn't
real. Then I compare the angles of the tangents at the corner point to the vectors
obtained by going from start to end on the leading and trailing curves. If they are
not similar enough, I say the corner isn't real. Finally I take the angle between the
start o fthe leading curve, the corner, and the end of the trailing curve. If it is too
close to 180 degrees, I say the corner isn't real.
Having marked the real corners, I sample the curve at fairly coarse intervals,
apply a Gaussian filter to smoothing things out and then refit it with a sloppy
tolerance factor, which gives me a fairly smooth curve between the corners.
Whilst it works on the test set, the snag is that I had to fiddle with the parameters
in an ad hoc way to achieve this.