PerfectVector
Studio
By Irene Kim

Potrace Turn Policy: Trace Separate Diagonal Paths

Compare Potrace black, white, and minority turn policies on two pixel blocks that touch at a corner. Check which setting gives you separate SVG paths.

5 min read
On this page

Potrace’s turn policy decides how the tracer follows a boundary when dark and light pixels meet diagonally at one grid corner. Use --turnpolicy white to favor the light connection at that corner, or --turnpolicy black to favor the dark connection. Keep the source mask fixed while comparing them. Potrace command reference

Two traces can look alike and still contain different numbers of paths. That matters when a pair of marks needs to remain separately selectable or when the light space between them needs to survive later edits.

Try it on your own image
Open the full tool
Free to try. Drop an image to preview your vector, no sign-up needed.

Identify the ambiguous corner

Draw a 2 × 2 grid. Put black squares at the upper left and lower right, and white squares in the other two cells. All four cells touch at the center vertex. The boundary can turn there in either direction, which changes which color stays connected across the corner. The Potrace algorithm paper explains this path-decomposition step.

SettingWhat it favors at an ambiguous corner
blackA connection between black pixels
whiteA connection between white pixels
minorityThe locally less common color. This is Potrace’s default.
majorityThe locally more common color

The fixed left and right policies choose a turn direction. Start with black and white when your design gives you a clear foreground or background preference.

Trace one bitmap with the same settings

The test uses Potrace and a plain-text PBM, a monochrome bitmap format. In PBM, 1 means black and 0 means white. Save this as corner.pbm. Its two 5 × 5 blocks meet at one corner. Netpbm PBM specification

P1
12 12
0 0 0 0 0 0 0 0 0 0 0 0
0 1 1 1 1 1 0 0 0 0 0 0
0 1 1 1 1 1 0 0 0 0 0 0
0 1 1 1 1 1 0 0 0 0 0 0
0 1 1 1 1 1 0 0 0 0 0 0
0 1 1 1 1 1 0 0 0 0 0 0
0 0 0 0 0 0 1 1 1 1 1 0
0 0 0 0 0 0 1 1 1 1 1 0
0 0 0 0 0 0 1 1 1 1 1 0
0 0 0 0 0 0 1 1 1 1 1 0
0 0 0 0 0 0 1 1 1 1 1 0
0 0 0 0 0 0 0 0 0 0 0 0
for policy in black white minority; do
  potrace corner.pbm --svg --turnpolicy "$policy" \
    --turdsize 0 --alphamax 0 --output "$policy.svg"
done

The two fixed flags keep the corner comparison simple. --turdsize 0 disables speckle removal, and --alphamax 0 makes the output polygonal. Compare the saved SVGs in the same editor and expand their group in the object list. Alternatively, open them as text and count the <path> elements for this fixture.

In Potrace 1.16, black and minority each produced one closed path. White produced two independently selectable closed paths. Both white paths retain the corner point in this test, so they can still look like they touch. Use a geometric gap in the input if the deliverable requires physical separation.

A corner-touching bitmap beside Potrace output with one path for black policy and two paths for white policy
The same bitmap traced with black and white turn policies. Display colors identify separate path objects without changing their geometry.

Diagnose a merge that persists

Check the thresholded bitmap first. If the dark shapes already share a pixel edge, the turn policy cannot create a gap there. Clean up that border in the bitmap or adjust the threshold, then rerun your comparison. The Potrace PNG preparation guide covers the conversion from PNG to a mask. If two shapes still look like one, use the trace quality checklist to inspect the exported objects and openings.

FAQ

What is Potrace’s default turn policy?

Potrace defaults to minority. At an ambiguous corner, it favors the color that occurs less often in the local neighborhood.

Can turn policy change a shape where pixels share an edge?

Turn policy resolves ambiguous turns at a boundary vertex. To split shapes already joined along an edge, change the mask so they have separate boundaries.

Does the white policy create clearance between two shapes?

It can produce separate paths for corner-touching dark areas. In this sample, those paths still touch at a point. For positive clearance, introduce a gap in the source and measure it in the output.

Start with the original raster

PerfectVector can trace a raster image into editable vector paths.

If you have only the original PNG or JPG, preview a vector trace and check the corner at zoom. Inspect the path list before you decide whether the marks need to be drawn apart.

Sources

  1. Potrace command reference — Turn-policy values, defaults, and tracing flags.
  2. Peter Selinger, Potrace algorithm paper — Ambiguous grid vertices and path decomposition.
  3. Netpbm PBM specification — Pixel values and the plain PBM input format.

More from the blog

PerfectVector

Turn your image into
clean, editable vector paths

Vectorize and inspect previews for free, with no daily limit.