Y7 Color Match (Masked)
The color-shift fix for every inpainting job that leaves a tint
- image_ref
- image_target
- mask
- image
You inpainted a red car to blue, and now the whole scene has a faint red tint. Classic. The problem isn't the inpainted region - it's the rest of the image: the color transfer calculation included the inpainted area, and that area's new color bled into the correction applied everywhere. Y7 Color Match (Masked) is the targeted fix: it color-matches the target image to a reference while excluding masked regions from the calculation, so the inpainted area doesn't contaminate the result.
It's from the Y7Nodes pack, and it's based on kijai's ColorMatch node from KJNodes, with the masking logic added on top. The color-matcher library it uses is the one powering the classic color transfer methods.
How it works
You give it three things: a reference image, a target image, and a mask. The reference is usually the original before inpainting; the target is the result after. The mask is where white (1.0) means "exclude this region from the color calculation" - i.e., the inpainted area itself.
The node computes the color correction using only the non-masked pixels of both images, then applies that correction across the whole target. Because the inpainted region was excluded from the math, the correction doesn't try to "fix" the new blue paint back toward red - it only shifts the untouched areas to match the reference's color mood.
The algorithm is selectable via method:
mkl- Monge-Kantorovich, a full color transfer. Default, and usually the best-looking.hm- histogram matching.reinhard- the classic Reinhard statistical transfer.mvgd- Multi-Variate Gaussian.hm-mvgd-hmandhm-mkl-hm- chained hybrids that tend to hold color better.
The other inputs are simple: strength (0 = no change, 1 = full correction, default 1) blends the result back toward the original, and feather (0–100 px) blurs the mask edge so the transition into the corrected region is soft instead of a hard line.
Output is a single image - the color-matched result with the masked area preserved unchanged.
Where it shines
The inpainting essay in our knowledge base makes the point that masked inpainting's remaining superpower is bit-identical unmasked pixels - you composite the mask back and nothing else moves. The problem is that the colors of the unmasked region often don't match the reference anymore, either from the inpaint's global color shift or from re-encoding. This node is the cleanup pass for exactly that: fix the surrounding color cast, leave the inpainted region alone.
Typical setup: crop a region, inpaint it, then run original → inpainted result through this node with a mask covering the inpainted area, feather set to maybe 10–30px, and let it even out the scene.
Installing it
The node itself is small, but it needs the color-matcher library:
cd ComfyUI/custom_nodes
git clone https://github.com/yushan777/ComfyUI-Y7Nodes
cd ComfyUI-Y7Nodes
pip install -r requirements.txt
color-matcher is in the pack's requirements, so the standard install covers it. Restart ComfyUI (or use Manager → search "Y7Nodes").
Gotchas
The mask direction trips everyone up: white means exclude. If you habitually use masks where white means "affected region," you'll invert this the first time and get the opposite of what you want. Also note the mask is optional - if you don't connect one, the node color-matches the entire image, which is just kijai's original behavior. And strength is the dial to turn when the full correction overshoots; a lot of the "why is my whole image gray" reports come from running mkl at full strength on a bright scene, so don't be shy about dropping it to 0.5–0.8.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image_ref | IMAGE | Reference image for color matching (e.g., original before inpainting) | |
| image_target | IMAGE | Target image to apply color correction to (e.g., result after inpainting) | |
| method | COMBO | mkl | Color transfer method: mkl (Monge-Kantorovich), hm (histogram), reinhard, mvgd (Multi-Variate Gaussian) |
| maskopt | MASK | Mask where white (1.0) = areas to exclude from color matching (e.g., inpainted region). If not provided, color matching is applied to the entire image. | |
| strengthopt | FLOAT | 1.000–1 | Blend strength between original and color-matched result (0=no change, 1=full correction) |
| featheropt | INT | 00–100 | Feather/blur radius for the mask edge transition in pixels |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |