![]() |
![]() |
![]() |
function Vectorize(img: TImage32; compareColor: TColor32; compareFunc: TCompareFunction; colorTolerance: Integer; roundingTolerance: integer = 2): TPathsD;
This function converts monochrome raster images into raw polygon vectors.
compareFunc: usually CompareRGB, CompareHue or CompareAlpha.
colorTolerance: This value will be passed to compareFunc.
roundingTolerance: specifies the minimum distance for adjacent pixels in returned paths.
Vectorize is usually just the first step in completely vectorizing an image. Generally these raw polygon vectors are simplified using RamerDouglasPeucker and then smoothed with SmoothToBezier.
//Example: //vectorize an image, filtering on non-transparency or dark colors if img.HasTransparency then rawPaths := Vectorize(img, $FF000000, CompareAlpha, $80) else rawPaths := Vectorize(img, $FF000000, CompareRGB, $80); //and simplify the result simplifiedPaths := RamerDouglasPeucker(rawPaths, 3); //then smooth the result bezierPaths := SmoothToBezier(simplifiedPaths, true, TrackBar1.Position, 3); //and finally flatten and draw the Bezier paths flattenedPaths := FlattenCBezier(bezierPaths); DrawPolygon(displayImg, flattenedPaths, frEvenOdd, clNavy32);
Before:![]() |
After:![]() |
CompareAlpha, CompareHue, CompareRGB, RamerDouglasPeucker, SmoothToBezier
Copyright ©2019 Angus Johnson - Image32 ver. 1.54 - Documentation last updated on 7-November-2020