Add non-flat background mode (--no-chroma / chroma.enabled: false)

No colour key at all: segmentation alone drives the trimap (mode forced
to 'seg', whose chroma terms degrade to no-ops on a zero background-
confidence map), ViTMatte still refines the unknown band at full
resolution, and pymatting still estimates edge foreground colour. Every
colour-keyed stage is bypassed: background auto-detect, the directional
hue split, chroma alpha suppression, despill, the cross-check veto (its
suspect zone is background-hued by definition; with reuse_as_seg the
second opinion still serves as the segmenter), and the unmix fallback.

Guards: requires segmentation.enabled and matting_method 'vitmatte'
(clear errors otherwise); despill/foreground handle model=None.

Validation: flat-background default path is bit-identical pre/post
(alpha and RGB |D|max = 0 on TestImage3). On a known-alpha subject
composited over a gradient+blotch background, recovered alpha scores
MAE 0.0018 / IoU@0.5 0.993 (0.995 with --cross-check-as-seg); the same
input correctly fails auto-detection in default mode.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-14 11:13:08 +08:00
parent f22af16517
commit e61fbe84f0
8 changed files with 78 additions and 18 deletions
+13
View File
@@ -59,6 +59,19 @@ background-hued residual such as blue trapped between hair strands). Switch with
`--trimap-mode seg` (topology only, no hue split) or `directional-hard-bg` (aggressive
— hard-removes background-hued pixels; can eat cool/shadowed white cloth).
## Non-flat backgrounds
Pass `--no-chroma` (or `chroma.enabled: false`) to matte images whose background is
**not** one flat colour — gradients, textures, scenes. There is no colour key in
this mode: the segmentation mask alone drives the trimap (mode forced to `seg`),
ViTMatte still refines the unknown band at full resolution, and pymatting still
estimates edge foreground colour. Every colour-keyed stage is bypassed: background
auto-detection, the directional hue split, chroma alpha suppression, despill, and
the cross-check veto (with `--cross-check-as-seg` the second model still provides
the segmentation mask). Requires the segmentation pipeline; quality then rests
entirely on the segmenter's mask, so expect flat-background results to stay
stronger on hair-level detail.
## Background colour
By default (`screen_color: null`) the background colour is **auto-detected** from the