Add cvd_simulate: simulate colour-vision deficiency and flag collisions#442
Merged
Conversation
Status UIs lean on colour (green ok / red error), but for the ~8% of men with a colour-vision deficiency those can be indistinguishable and nothing could check it. simulate_cvd maps RGB through a dichromat matrix (protan/deuter/tritan) at a severity; colors_collide reports whether two colours become confusable under it. Pure stdlib over RGB tuples, no deps.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 28 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
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
First feature of the ROUND-15 perception lane. Status UIs lean on colour (green "ok" vs red "error"), but for the ~8% of men with a colour-vision deficiency those can be indistinguishable — and nothing in the framework could check it.
utils/cvd_simulate/:simulate_cvd(map RGB through a dichromat simulation matrix — protanopia/deuteranopia/tritanopia — at a givenseverity, with friendly aliases),colors_collide(simulate two colours and report whether they become confusable: perceptualredmeandistance belowthreshold),color_distance(the redmean metric). Pure standard library — no numpy/OpenCV — operating on plain RGB tuples, fully testable.__all__;AC_simulate_cvd/AC_colors_collideexecutor commands (RGB inputs accept a JSON list); matching read-onlyac_*MCP tools; Script Builder under Image.v214_features_doc.rst+WHATS_NEW.md.Test
test/unit_test/headless/test_cvd_simulate_batch.py— severity-0 identity, neutral-grey invariance (row sums = 1), red-shift under protanopia, aliases, unknown-kind raises, severity clamp,color_distancezero/symmetry, CVD reduces red-green distance, a genuinely colliding pair, black/white never collide, threshold respected, plus JSON-list executor coercion and facade + executor/MCP/builder wiring. All 15 green;ruff+bandit+radonclean;pytest.approx(no float==); package stays Qt-free.