Skip to main content

Partial color processing - keep specific regions in color, rest in monochrome

Project description

patcolour

CI PyPI

Partial color processing for visual-novel style artwork.

patcolour keeps selected regions in color while the rest becomes monochrome. It is meant to sit between raw photo editing and the larger skirts-colour production pipeline, and to be callable from other tools that need stable image-processing behavior.

Why patcolour?

The target use case is not generic "selective color" photography. The real goal is more specific: keep emotionally important parts in color while the rest falls back to memory-like grayscale. That makes mask quality, edge softness, and region selection workflow more important than a huge option surface.

Just as importantly, this tool is expected to become reusable infrastructure for other repos, including name-name-based skirts-colour workflows and future image-processing utilities.

Install

uv tool install patcolour

Or from source:

git clone https://github.com/kako-jun/patcolour.git
cd patcolour
uv sync --group dev
uv run patcolour --help

Usage

Mask-based

patcolour photo.jpg --mask mask.png -o output.png

White areas in the mask stay in color. Black areas become monochrome.

Coordinate-based

patcolour photo.jpg \
  --rect 120,40,220,180 \
  --ellipse 540,260,110,80 \
  --feather 12 \
  -o output.png

Auto-detect colorful regions

patcolour photo.jpg --auto-detect -o output.png

Sample a target color from the image

patcolour photo.jpg --sample 420,180 --lab-radius 16 -o output.png

This mode samples one pixel from the input and keeps nearby colors using Lab chroma distance, which is a better fit than raw RGB distance for "keep this hue family" workflows.

Keep only the front flower, not every similar color in the scene

patcolour photo.jpg \
  --sample 420,180 \
  --lab-radius 16 \
  --ellipse 420,180,90,120 \
  --feather 10 \
  -o output.png

Color alone is not enough for many scenes. In practice, the user often needs to combine a color sample with a spatial guide.

Batch processing

patcolour ./photos/ --mask-dir ./masks/ -o ./output/

Current behavior

  • --mask uses an external grayscale mask
  • --rect and --ellipse define keep-color regions
  • --auto-detect keeps broad HSV-detected colorful areas
  • --sample keeps colors near a sampled reference point in Lab chroma space
  • --feather softens coordinate-based region edges

The CLI is the first interface, but not the only intended interface. The filter logic should stay predictable enough to be reused from other tools.

Just as importantly, this is a human-guided tool. If the scene contains several similar purples, reds, or greens with different semantic roles, the user must be able to tell the tool which region is the intended subject.

If --auto-detect is combined with coordinate regions, the result is their intersection.

Limitations

  • Auto-detection is currently tuned for broad colorful regions and is easy to over-select
  • There is no semantic selection yet such as "left flower only" or "girl's ribbon only"
  • Batch mode currently assumes one mask per file and does not validate coverage quality

Docs

  • docs/overview.md — positioning, goals, non-goals
  • docs/spec.md — CLI and processing behavior
  • docs/roadmap.md — internal roadmap and quality targets
  • CLAUDE.md — AI-facing internal guide

Development

uv sync --group dev
uv run ruff check .
uv run pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

patcolour-0.1.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

patcolour-0.1.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file patcolour-0.1.0.tar.gz.

File metadata

  • Download URL: patcolour-0.1.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.8

File hashes

Hashes for patcolour-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5cbad19f7b58d0b86a98a7c9b442b6752e9150135e434c77e3b6f2a938689852
MD5 c5737371348173663fce3b004c9e8c4a
BLAKE2b-256 a99f4735f4038e94a23bd541b8bcb33f904131383ffe0ff7f2bde3b99f99eee7

See more details on using hashes here.

File details

Details for the file patcolour-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: patcolour-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.8

File hashes

Hashes for patcolour-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 504d6b7e8a996726674fa970699cb956a0d1a4ea61aedec23264ac33e46b1889
MD5 051ba2217d3b94d65d35201b795ab9b6
BLAKE2b-256 2d434b58fa0d8f588a0f0a779a6094e8afaa10c55bb3ed3894aeac72fc5031b1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page