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 SimplifyPaths, and smoothed with SmoothToCubicBezier before finally being 'flattened' using FlattenCBezier.
//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 := SimplifyPaths(rawPaths, 3);
//then smooth the result
bezierPaths := SmoothToCubicBezier(simplifiedPaths, true, TrackBar1.Position);
//and finally flatten and draw the Bezier paths
flattenedPaths := FlattenCBezier(bezierPaths);
DrawPolygon(displayImg, flattenedPaths, frEvenOdd, clNavy32);
After:
SimplifyPaths, SmoothToCubicBezier, FlattenCBezier, CompareAlpha, CompareHue, CompareRGB
Copyright ©2010-2023 Angus Johnson - Image32 4.8 - Help file built on 16 Apr 2025