Vectorize

function Vectorize(img: TImage32; compareColor: TColor32; compareFunc: TCompareFunction; tolerance: Integer): TArrayOfArrayOfPointD;


This function converts monochrome raster images into raw polygon vectors.

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:

See Also

RamerDouglasPeucker, SmoothToBezier