[#67] Tier 2: region-coverage as the default colour engine (clean outlines + economy)#70
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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/(montagetier2-before-after.png):Principle #1 (clean flats) preserved
_TIER2_REGION_COVERAGE = Falserestores 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)
coverage_region_max_px).Full suite green (the lone local
test_version_is_single_sourcedis 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.