Add recolor pass to clean residual contamination colour

Add bgfilter/recolor.py: after despill, propagate clean neighbour chroma into
pixels whose colour is still off (residual green, or the magenta a green unmix
overshoots into), keeping luminance partway so hair texture survives. It installs
a real observed colour rather than subtracting, so it cannot overshoot. Despill
already neutralises the matte edge (off ~ 0 there), so recolor only touches the
contaminated interior and the wisps the dropout-fill rescued.

Runs as a final colour pass on the despilled foreground; pymatting + despill keep
their stronger edge handling. On the samples the magenta fringe drops sharply
(TestImage vis-magenta 0.065->0.014, TestImage2 0.085->0.031) with edge green
unchanged (vis-green ~0.02). Debug output color_mask.png replaces the despill /
foreground-background / foreground-correction maps; smoke updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-30 22:19:15 +08:00
parent 42d65b0d25
commit b0a634dfd4
6 changed files with 119 additions and 9 deletions
+11
View File
@@ -52,3 +52,14 @@ despill:
green_excess_margin: 0.015
edge_expand_radius: 2
alpha_weight_floor: 0.35
recolor:
enabled: true
person_threshold: 0.5
coverage_soft: 0.08
contam_low: 0.02
contam_high: 0.12
clean_dom_max: 0.03
propagate_radius_ratio: 0.02
min_reference_weight: 0.05
luminance_strength: 0.5