Skip to content

[#67] Tier 2: region-coverage as the default colour engine (clean outlines + economy)#70

Merged
realproject7 merged 2 commits into
mainfrom
task/67-tier2-region-coverage
Jun 24, 2026
Merged

[#67] Tier 2: region-coverage as the default colour engine (clean outlines + economy)#70
realproject7 merged 2 commits into
mainfrom
task/67-tier2-region-coverage

Conversation

@realproject7

Copy link
Copy Markdown
Owner

Summary

Promotes perceptual-coverage quantization (#65) from a narrow gated path to the default colour engine, by adding a connected-component min-AREA cleanup pass. This fixes the gaps real-world v0.3.0 testing surfaced (#69): gradients inside hard-edged shapes, path over-segmentation, and ragged dark outlines.

The mechanism (one knob, no per-category switch)

After coverage quantization, merge by connected-component area, not global colour mass:

  • a gradient band is thin-but-long (large area → kept) → smooth gradients survive, even inside shapes;
  • an anti-alias sliver / linework fringe is thin-but-short (sub-area → absorbed into its nearest-ΔE neighbour) → ragged dark linework collapses into clean continuous outlines, and flat art stays economical.

This is why the same pass covers #66 (outline continuity) and #69 (gradient-in-shape + economy) at once.

Validated end-to-end through the real tracer

Renders + metrics in z-design/SVGSmith_Convert/test-v0.3.0/ (montage tier2-before-after.png):

image 0.3.0 (current) 0.4.0 Tier 2 reference
logo 747 paths / 257 KB / banded 34 paths / 17 KB / smooth 33 paths
pigeon ragged outlines + arm blotches / 125 KB clean continuous outlines / 30 KB 59 KB
16-gradient (no-regress) SSIM 0.966 0.968, far fewer paths
flat corpus no regression (golden suite green)

Principle #1 (clean flats) preserved

  • The step stays at the Tier 1 value (ΔE76 4.0) — only the area filter + the widened gate are new. Gradient fidelity is not regressed (16-grad 0.966→0.968; 17-grad 0.877≈0.873).
  • Flat corpus goldens stay green; the gradient-bars regression test now asserts the clean economical coverage output.
  • SAFE-REVERT is one flag: _TIER2_REGION_COVERAGE = False restores pure Tier 1 (narrow full-frame-gradient gate, no region cleanup). No code path removed; the supersample path remains as the coverage fallback when a trace still explodes (>4000 paths).

Follow-ups (non-blocking)

  • JPEG pre-quant denoise to bring the pigeon colour count toward the reference (filed separately).
  • Vectorized RAG for the region-merge hot spot (perf, not correctness).
  • Per-axis px clamp on the area threshold for 4K+ inputs (already added: coverage_region_max_px).

Full suite green (the lone local test_version_is_single_sourced is a worktree egg-info artifact — clean build metadata is 0.4.0; CI regenerates it). No external-tool brand names.

Closes #66, closes #67, closes #69.

realproject7 and others added 2 commits June 24, 2026 12:33
…lines + economy)

Perceptual-coverage quantization (#65) only reached full-frame gradients: the
narrow edge<0.008 gate skipped gradients *inside* hard-edged shapes, and the
baseline path over-segmented outlined art (a gradient-filled logo traced to 747
paths with banding; cartoon outlines came out ragged/doubled).

Add a connected-component min-AREA cleanup pass to quantize_coverage and widen
the gate so any rich-colour input (>256 distinct) takes the coverage engine. The
area filter is the key: a gradient band is thin-but-long (large area → kept) while
an anti-alias sliver / linework fringe is thin-but-short (sub-area → absorbed into
its nearest-ΔE neighbour). The SAME knob therefore (a) reaches gradients inside
shapes, (b) collapses ragged dark linework into clean continuous outline regions,
and (c) keeps flat art economical — with no per-category switch.

Validated end-to-end through the real tracer (z-design test-v0.3.0):
- logo: 747 paths/257 KB banded -> 34 paths/17 KB smooth (reference is 33).
- pigeon: ragged outlines + arm blotches -> clean continuous outlines, 125 KB -> 30 KB.
- gradients NOT regressed: corpus gradient fixtures keep similarity (16-grad
  SSIM 0.966 -> 0.968) with far fewer paths.
- flat corpus: no regression (golden suite green).

Step stays at the Tier 1 value (ΔE76 4.0); the only change is the area filter +
the widened gate. SAFE-REVERT is one flag: _TIER2_REGION_COVERAGE = False restores
pure Tier 1 (narrow full-frame-gradient gate, no region cleanup). The supersample
path remains as the coverage fallback when a trace still explodes (>4000 paths).

Closes #66, closes #67, closes #69. Comparison: z-design/.../test-v0.3.0/tier2-before-after.png.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@realproject7 realproject7 merged commit 5809df4 into main Jun 24, 2026
4 checks passed
@realproject7 realproject7 deleted the task/67-tier2-region-coverage branch June 24, 2026 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant