Home | Img32.Extra |

**function** SmoothToBezier(**const** path: TPathD; closed: Boolean; tolerance: double; minSegLength: double = 3): TPathD; **overload**;

**function** SmoothToBezier(**const** path: TPathsD; closed: Boolean; tolerance: double; minSegLength: double = 3): TPathsD; **overload**;

This function replaces roughly curved sections of flattened paths with series of smooth Bezier curves. The returned path (or paths) is a series of consecutive Cubic Beziers where the end vertex of one Bezier becomes the start vertex of the next. (These can easily be converted back to flattened paths using the **FlattenCBezier** function).

*closed*: as inferred from the parameter's name, this function will smooth both open and closed paths.*tolerance*: specifies the maximum allowed variance between the existing vertices and the new Bezier curves. More tolerance will produce fewer Beziers and simpler paths, but at the cost of less precision. Usually a value of 3-4 produces the best results. (Range: 1 - 10).*minSegLength*: When vectorizing raster images, the produced vector paths will consist of axis aligned segments that trace pixel boundaries. These paths will also contain many 1 unit segments that are at right angles to their adjacent segments. Importantly, these very short segments will cause artifacts in the solution unless they are trimmed before proceeding to curve smoothing. Usually just removing vertices that are within 1 unit of their preceding vertices will circumvent 'pixel' artifacts. However, when a bitmap has been enlarged before vectorization, meaningful pixel dimensions will also increase and, to avoid 'pixel' artifacts there, 'minSegLength' will also need to be increased. (Default = 3)

This function is a very useful adjunct to the **Vectorize** function that's found in the **Img32.Extra** unit. Both functions are demonstrated in the **VectorizeImages** sample application.

*Note: This function is based on "An Algorithm for Automatically Fitting Digitized Curves" by Philip J. Schneider as published in "Graphics Gems", Academic Press, 1990.*

Before: |
After: |

Copyright ©2019 Angus Johnson - Image32 ver. 4.0 - Documentation last updated on 20-January-2022