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
+1 -3
View File
@@ -18,10 +18,8 @@ REQUIRED_DEBUG_FILES = {
"bg_confidence.png",
"trimap.png",
"alpha.png",
"despill_mask.png",
"foreground_rgb.png",
"foreground_background.png",
"foreground_correction.png",
"color_mask.png",
"preview_black.png",
"preview_white.png",
"preview_gray.png",