liveBook · Manning

Image vectorization

As explained in Geometry for Programmers

Image vectorization is the conversion of raster or scanned image data into vector-based geometric representations.

Image vectorization converts raster or scanned image data into geometric representations such as lines, circles, splines, or smooth curves. It replaces pixel-scale boundaries with shapes that remain useful when scaled or edited. section 12.4

Why vectorize an image?

A satellite image becomes more useful as a map when roads remain straight during zooming. Similarly, vectorizing scanned blueprints makes their geometry editable in modern CAD software instead of leaving it as an unmodifiable raster. section 12.4

A teaching-oriented vectorization pipeline follows these ideas:

  • Start with an 8-bit, one-channel image whose values range from 0 to 255, and choose a threshold such as 128 to separate dark from light. section 12.4.1
  • Place contour segments between neighboring cells whose values lie on opposite sides of the threshold, producing an initial pixel-scale boundary. section 12.4.2
  • Replace the rough pixel border with smooth curves, using geometric ideas including signed distance functions, partial derivatives, and tangent vectors. section 12.4.2 section 12.4.6
Figure 12.18 The difference between raster and vector graphics (Yug, modifications by 3247 [CC BY-SA 2.5])
12-18

Compare raster graphics, whose detail is tied to square grid cells, with vector graphics, whose geometric features scale smoothly. section 12.4

The basic algorithm demonstrates the mathematics clearly but is not a practical replacement for advanced vectorization software: an artist can produce a better result quickly, and practical systems need more elaborate algorithms. section 12.4.6

How Geometry for Programmers covers it

How deep it goes
Demonstrates thresholding, contour extraction, and smooth-curve construction while stopping short of production-grade computer vision or machine learning.
Examples
Uses satellite imagery, zoomable maps, scanned blueprints, and an 8-bit grayscale arrow image.
What it assumes
Assumes familiarity with pixels and geometric data while introducing thresholds, contours, image masks, voxels, and representation conversions.
What you can do after
Understand and implement a basic threshold-based contour vectorization algorithm while recognizing when more elaborate methods are necessary.
How it connects
Connects raster graphics, CAD, signed distance functions, partial derivatives, tangent vectors, and voxel models.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Geometry for Programmers. The section links point to the parts of the book it draws on.