我在 X、Y 中有一个连续的点集合,我想将这些点“追踪”到一组贝塞尔曲线中。是否可以为此使用任何开源位图到矢量跟踪算法或库?
3 回答
这取决于你想要完成什么。如果您想查看“最佳拟合”曲线,或者至少是一个粗略的近似值,您应该使用 b_spline。b_spline 将适合自己“内部”给定的点。为了通过有问题的点,我通常会使用 Catmull-Rom 样条曲线,当给定点 1、2、3 时,它将通过点 2,其斜率等于点 1 和 3 之间的斜率。
示例代码: http ://willperone.net/Code/spline.php
算法说明: http ://steve.hollasch.net/cgindex/curves/catmull-rom.html
This is an older question, but I found it because I need an algorithm for autotracing coordinates as they're being drawn, and found this SO post through Google. It looks like for this particular question no one's mentioned Potrace (small wikipedia article on it here), which is pretty much literally what the original question was asking for, and is open source with several ports as well as the papers that describe its function freely available.
如果您希望曲线通过现有的一组点,您希望使用分段 b 样条曲线而不是贝塞尔曲线。
网络上有大量的代码可以做到这一点。