Skip to content

fix(color): preserve visible colors against hidden RGB bias - #92

Merged
phil-r merged 1 commit into
mainfrom
fix/color-transparent-palette-fidelity
Oct 8, 2026
Merged

phil-r merged 1 commit into
mainfrom
fix/color-transparent-palette-fidelity

Conversation

@phil-r

@phil-r phil-r commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Description:

Keep the snail navy instead of near-black when vectorizing its transparent PNG with 3 colors. Hidden black RGB shares a visible cluster, so all 3 palette slots survive and the slot recovery in #91 does not trigger.

Numeric requests now compensate shared palette centers for masked RGB contributions without reclustering, reordering layers or changing masks. Auto and binary behavior stay unchanged. This preserves the existing filtering and assignments rather than promising exact source colors.

This PR includes:

  • The exact snail.png fixture and palette/render regressions for both profiles, plus alpha-boundary and independent per-cluster reference checks.
  • Corrected Aftermath fill expectations, with its approved mask and geometry hashes unchanged and the original lower-level palette separately tested.

How to run:

docker compose --profile testing run --build --rm test \
  python -m pytest vectorizing/tests/test_color_numeric.py \
  vectorizing/tests/test_color_p3.py

Validation: 855 offline tests and all pre-commit hooks passed. test_integration.py (HTTP/S3/gallery integration) was excluded. Before/after captures confirm unchanged geometry and alpha; unaffected cases match exactly. No existing PNG baselines were replaced. Generated visual evidence remains local.

Local medians (M4 Pro, ARM64 Docker/Python 3.11, single-threaded, 5 fresh-process samples plus warmup):

Snail, 3 colors Before After
current 42 ms 46 ms
experimental 37 ms 40 ms

Mean-bias checking adds 22–33 ms on measured 1MP transparent inputs, including about 10–11% overhead on a populated palette whose output is unchanged. Peak RSS showed no meaningful increase. Timing excludes decoding, HTTP/S3 and rasterization; production concurrency was not tested.

Checklist (based on PR guidelines):

  • I have self-reviewed this PR, according to these points
  • This PR falls into maximum three of these categories
  • I feel comfortable taking responsibility for merging this code to production
  • The code is high quality, well-tested, follows styles guides (Frontend), clean, and well documented

Compensate shared numeric palette centers for masked RGB contributions while keeping cluster assignments, paint order and geometry fixed. Leave auto and binary processing unchanged.

Add the exact snail fixture and regressions for navy preservation, alpha boundaries, independent bias references and no-op behavior. Check corrected Aftermath fills without replacing approved mask or geometry hashes, and retain the original lower-level palette test.
@phil-r
phil-r merged commit 1fb307d into main Oct 8, 2026
2 checks passed
@phil-r
phil-r deleted the fix/color-transparent-palette-fidelity branch October 8, 2026 14:06
@phil-r phil-r mentioned this pull request Oct 8, 2026
phil-r added a commit that referenced this pull request Oct 8, 2026
Compensate shared numeric palette centers for masked RGB contributions while keeping cluster assignments, paint order and geometry fixed. Leave auto and binary processing unchanged.

Add the exact snail fixture and regressions for navy preservation, alpha boundaries, independent bias references and no-op behavior. Check corrected Aftermath fills without replacing approved mask or geometry hashes, and retain the original lower-level palette test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant