Vectorize

Study

Working question: how can raster images become useful plotter paths without pretending that every image wants the same treatment?

The thing is a raster-to-SVG tool with several strategies: edges, posterized tracing, and centerline extraction.

The current page explains the pipelines. The study note still needs the practical learning: which images suit which strategy, what single-stroke paths demand, and where automatic vectorization stops being helpful.

A tool that converts raster images into clean SVG vector graphics. Load a photograph, a scanned sketch, or a logo, and Vectorize traces it into paths that a pen plotter, laser cutter, or vinyl cutter can follow.

Source: github.com/utrost/Vectorize · License: AGPL-3.0

Three Pipelines

The tool has three distinct processing pipelines, each suited to different source material.

Canny Edge Detection

The classic approach. Convert to grayscale, detect edges with a Canny filter, trace the contours, then simplify. Produces polylines or polygons. Works best for line art, technical drawings, and anything where outlines are the point.

Four simplification strategies operate on the detected contours: Douglas-Peucker for general-purpose reduction, straight line fitting for architectural drawings, convex hull for shape bounding, and raw output for debugging.

Optionally, polylines can be converted to smooth cubic Bézier curves using Catmull-Rom interpolation.

Whole-Image Trace

Instead of detecting edges, this pipeline traces the entire image. It quantizes colors first (reducing to N palette colors), then traces the boundaries between color regions. The output is filled Bézier paths that reproduce the image as a posterized vector graphic.

Two engines are available: DrPTrace (a potrace variant) for outline tracing, and ImageTracer for full-color filled paths.

Centerline / Skeleton

This pipeline finds the single-pixel-wide spine of shapes through morphological thinning. The result is a single-stroke path per shape, not an outline. This is what plotters need: one continuous line per stroke, not a boundary around a stroke.

The threshold controls binarization, the tolerance controls how aggressively the skeleton is simplified.

The GUI

A Swing application with FlatLaf dark and light themes, featuring a split-pane view: original image on the left, live SVG preview on the right. The controls panel offers presets (Line Art, Photo Detailed, Photo Simplified, Logo, Sketch) that configure all parameters at once. Every slider change triggers a debounced re-vectorization after 400ms.

A full menu bar (File, Edit, View, Help) with standard keyboard accelerators gives quick access to everything. The image viewer supports zoom-to-cursor on scroll, fit-to-window, and a checkerboard transparency background for PNGs with alpha. A three-column status bar shows image dimensions, SVG stats with processing time, and zoom percentage.

Features:

  • Drag-and-drop image loading

  • Auto Canny Thresholds: computes optimal edge detection from the image histogram, no manual tuning needed

  • Custom stroke color picker (any hex color, not just presets) and configurable width

  • Undo/redo for parameter states (Ctrl+Z / Ctrl+Y)

  • Background processing with cancel support and stage-by-stage progress reporting

  • Batch processing: point at a folder, process all images with the same settings

  • Export to SVG, PNG, or PDF directly from the GUI

Choosing a Strategy

SourceStrategyReasonLine art, technical drawingsdpPreserves corners and line precisionScanned sketches, handwritingdp + Smooth CurvesCleans noise, smooths pencil strokesLogos with flat colorsbezierTraces outlines of color regionsPhotos (posterized look)bezier2Colored filled shapesPlotter or laser cutter inputcenterlineSingle-stroke skeleton pathsArchitectural drawingslineFits straight lines to contours

Reproducibility

Every run writes a JSON sidecar file alongside the SVG, recording all parameters used. Feed that JSON back with --config to reproduce the exact same result, or use it as a starting point with overridden parameters. This turns parameter exploration into a traceable, repeatable process.

Tech Stack

Java 17, BoofCV for computer vision, Apache Batik for SVG rendering and the GUI preview, FlatLaf for the modern UI, DrPTrace and ImageTracer for whole-image tracing. SVG output is automatically optimized (coordinate rounding, whitespace cleanup). Built with Maven, tested with JUnit.

Part of the Toolchain

Vectorize sits between capture and preparation in the plotter toolchain:

  • Input: photographs, scans, screenshots, any raster image

  • Output: clean SVGs

See also: From Pixel to Pen, Gantry, PPCT, SVGToolBox, SVG2WaterColor, Generative Art, Primitive