Efficient Line Smoothing and/or Simplification

后端 未结 3 618
生来不讨喜
生来不讨喜 2020-12-25 15:26

I am creating a painting application in Actionscript (although my question is not Actionscript related). The basic idea is to start painting when the mouse is press

相关标签:
3条回答
  • 2020-12-25 16:06

    See Efficient Curve Fitting by Sarah Frisken. Also available at the author's page.

    0 讨论(0)
  • 2020-12-25 16:09

    (bumped into your question while looking for same, and happened to put together something of our own)

    http://willowsystems.github.com/jSignature/#/about/linesmoothing/

    (SEO-compatible link to same: http://willowsystems.github.com/jSignature/%2523%252Fabout%252Flinesmoothing%252F.html)

    The issue you describe is two-fold. 1. You want to 'simplify' the capture data. 2. You want to draw a nice-looking line ('fit a curve') within the points.

    Simplify.js quoted above is indeed good, but it only gives you points. For jSignature we wanted to a super-efficient, non-lagging curve-fitting algorithm.

    See link above for explanation of one (our) approach to fitting (Bezier aka 'cubic') curves between points. It allows you to keep the line the user drew and just lag on connecting the last 2 coordinates, or you can simplify and redraw the the whole line like that.

    (Our publication of the algorithm was intentional, as to establish "prior art" and preclude petentability of the combined method. This means, we don't put our own patent yoke on the algorithm and, searched hard and did not find it to be patented elsewhere. Of course there can be some patent troll out there that may find an issue with you implementing the method, but, at least, not us. So, enjoy.)

    The demo link is using 4-pixel skip on mouse movement. This is crude, but OK for real-time 'simplification' of data. If you have the luxury of capturing the whole stroke and redrawing it all, certainly, use simplify.js.

    0 讨论(0)
  • 2020-12-25 16:12

    Mike Bostock has some good examples here Line Simplification. He points out that the Douglas-Peucker algorithm is well know. However Visvalingam appears to be more effective.

    0 讨论(0)
提交回复
热议问题