Skip to content

feat: add tint for whole-image color wash#204

Draft
wkentaro wants to merge 3 commits into
mainfrom
feat/tint
Draft

feat: add tint for whole-image color wash#204
wkentaro wants to merge 3 commits into
mainfrom
feat/tint

Conversation

@wkentaro

Copy link
Copy Markdown
Owner

Summary

  • Add imgviz.tint(image, color, alpha=0.3) for a whole-image color wash, e.g. flagging a thumbnail in a tile sheet by red-tinting it: out = (1-alpha)*image + alpha*solid_color.
  • color accepts any cmap-compatible value (name, hex, or (r, g, b) tuple; ints in [0, 255] or floats in [0, 1]), parsed via cmap.Color.
  • alpha=0 returns the input unchanged, alpha=1 the solid color; out-of-[0, 1] alpha raises. Supports uint8 [0, 255] and float [0, 1] with @overload dtype preservation. RGB-only, with an error pointing to imgviz.asrgb.

tint

Test plan

  • tests added: tests/unit/_tint_test.py — wash changes pixels, alpha=0 returns an unchanged copy, alpha=1 is the solid color, color formats (name/hex/tuple), float dtype preserved, and guards for non-RGB shape / invalid dtype / invalid alpha (negative, >1, NaN)
  • example added: uv run python examples/tint.py --save; README table refreshed via generate_readme.py
  • uv run pytest tests/unit/_tint_test.py — 13 passed
  • uv run ruff check / uv run ruff format --check / uv run ty check clean on touched files (incl. test + example)

Closes #130

@wkentaro wkentaro self-assigned this Jun 10, 2026
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.

feat: add tint for whole-image color wash

1 participant