A blend pixel took a side of its edge only when the picture's own colors
on both sides lay within 2 px of it. With a limited palette, an edge
blurred over more than about 4 px kept the middle of its ramp in the
palette's in-between tones, which traced as rings of thin paths around
the edge.
With a Limited palette of at most 16 colors (3 Colors, 6 Colors,
16 Colors) and in Grayscale with at most 16 grays (Shades of Gray),
settled_wide looks for the own colors within 8 px, pairs the 8 of them
nearest to the pixel's color, and moves the pixel to the nearer side of
the best pair when that pair explains it twice as well as its own color,
or when it lies between the two and off the line between them by less
than 0.15 of their distance apart. These values are VectorCraft's own.
Of two pairs that explain it equally well it takes the closer one. A
pixel keeps its color when an own pixel of that color lies within 4 px
or when its color is one of the pair. Grayscale compares lightness. The
colors within reach are kept as bitsets for a strip of 7 columns at a
time.
High Fidelity Photo, Low Fidelity Photo, Black and White and the other
palettes keep the 2 px rule unchanged.
On the quality harness, blurred and scanned flat art with 6 and
16 Colors goes from 6 to 9 paths to 3, and from 0.23 to 0.26 px off to
0.07 to 0.11. Askew shapes take up to 11 px more area in colors the art
does not have, thin lines with 16 Colors lose more (largest distance
23.5 to 45.3 px), and Shades of Gray traces thin lines in 7.3 paths
where it took 5.3.
Noisy images settle more of their pixels: the dense grouping test
traces 150 x 150 noise instead of 120 x 120 to keep more than its 500
paths.
Covers the limited-palette part of #1911 (leogrox).
Docs: docs/target-app-parity.md, docs/image-trace-quality.md.
Color and Grayscale traces smoothed a gray photo before choosing its
colors, but a tinted photo with the same tones skipped smoothing: the
0.065 error rule applied only to pictures whose channels stay within 8
levels of each other. A picture whose opaque pixels lie, 19 in 20, within
6 levels of one tone curve now takes the same rule. The curve runs
through the median color of each 8-level stretch along the colors' main
direction, and a pixel on it must also lie within 6 levels of the plane
the colors spread along most, so art in several unrelated colors is not
counted. The sixteen-versus-eight exception still keeps clean flat art
on the flat-art route.
The continuous-tone test asked whether 8 colors leave more than a tenth
of the error of one color. A gray picture's tones lie along one line,
where 8 colors come nearer to them, so some gray photos scored 0.078 to
0.093 and were traced as flat art, without the smoothing color photos
get. Their noise then mixed neighboring tones (a 16 Colors trace could
keep 10 or 12 colors) and stepped the edges.
A picture with at least 95% of its opaque pixels within 8 levels across
their channels now also counts as continuous tone when 8 colors leave
more than 0.065 of the error of one color, unless 16 colors leave at
most a fifth of the error of 8. These are VectorCraft's own values. The
exception keeps gray flat art of up to 16 clean levels on its old
route. Pictures with more than 5% of their opaque pixels outside that
8-level range are unchanged.
Anti-aliased or noisy gray flat art can now take the smoothed route as
well. Very noisy gray scans of flat art get fewer specks and staircase
edges; some gray illustrations and sketches get more anchors and
staircase edges at 16 Colors and High Fidelity Photo. Some 16 Colors
and High Fidelity Photo palettes of gray photos grow toward the
requested count, with more anchors and regions, and some 6 Colors
traces get more staircase edges.
Regions are a linked list of pixels with a union-find over region ids instead of a Vec<usize> per region and BTreeMaps per merge. Same merge order and output; about 2.7x less peak memory and up to 1.9x faster on 25 MP noisy labels.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>