Image Mix Color by Mask
Tint exactly where your mask says — the node that makes mask-based color grading easy
- image
- mask
- IMAGE
Image Mix Color by Mask is the "color grade by selection" node: give it an image, a color, and a mask, and it paints that color into exactly the masked region. It's the compositing equivalent of a selective-color adjustment - the thing you use when you want the sky bluer but the ground untouched, or a subject tinted while the background stays put.
How it works. The math is dead simple and worth knowing because it tells you how the mask behaves:
result = image × (1 − mask) + color × mask
The mask is the blend factor. Where your mask is white (1), you get the pure color; where it's black (0), the image is untouched; gray gives a partial mix. So a soft-edged mask gives you a soft tint edge, which is usually exactly what you want. The inputs are image, the three color channels r / g / b (0–255, same as picking a color in an editor, default black), and mask - note that mask is a true MASK type, not an IMAGE, so it plugs straight into the socket from SAM, a mask editor, or any mask-generating node. Output is an IMAGE. It's pure tensor math, no PIL round-trip, so it's fast and handles batches without fuss.
One convention trap. This pack has two mask-blending nodes, and they disagree on mask polarity. ImageBlendMask inverts its mask internally; this one does not. Here, white in your mask = where the color lands. Swap the two blind and you'll spend an hour wondering why your tint is on the wrong half of the image. When in doubt, check your mask against a bright color - that's actually an underrated use of this node: run a known mask through it with a loud red, and you can see exactly which pixels your mask covers.
Where you'd reach for it: separate color-grading of subject vs. background (mask the subject, tint it, keep the world neutral); a duotone or color-wash over a masked region before compositing; or as a debugging tool for mask alignment, as above. There's no opacity slider - the strength is baked into the mask. To weaken the effect, blur the mask or pull your color toward the image's average tone before you plug it in.
Install is the same for the whole pack: ComfyUI Manager → search "KMCDev" → Install, then restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/kevinmcmahondev/comfyui-kmcdev-image-filter-adjustments
then restart ComfyUI. Nothing heavy - the pack only needs numpy, Pillow and torch, all already present in ComfyUI.
Troubleshooting. If the color covers everything, your mask is inverted - flip it with a mask-invert node. If the tint edges are harsh, blur the mask before feeding it in. If the math does something weird, the usual culprit is a mask whose dimensions don't match the image - keep them the same size, and if a mask came out of an upscaled workflow, resize it first.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| r | INT | 00–255 | — |
| g | INT | 00–255 | — |
| b | INT | 00–255 | — |
| mask | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |