Repository navigation
fix(color): preserve visible colors against hidden RGB bias - #92
Merged
Merged
Conversation
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.
Merged
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.
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.
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:
snail.pngfixture and palette/render regressions for both profiles, plus alpha-boundary and independent per-cluster reference checks.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.pyValidation: 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):
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):