Nodes/was-node-suite-comfyui/Image Remove Color
ComfyUI Node Runs on cloud

Image Remove Color

Swap one color for another in ComfyUI

By WASasquatch·Created 3 years ago·Updated a day ago· 1,839
Image Remove Color
  • image
  • IMAGE
target_red255
target_green255
target_blue255
replace_red255
replace_green255
replace_blue255
clip_threshold10

Say you generated something on a flat green backdrop and you want that green gone - flattened to white, or swapped for a color you'll key out later. That's the job here. Image Remove Color finds one color in an image and paints another color over it. Nothing fancier, and that plain-ness is the point.

Worth clearing up the name first, because it trips people: this node does not give you transparency. It doesn't cut a hole or add an alpha channel - it replaces the color you picked with a solid color you choose, and hands you back a normal RGB image. If you actually want a background knocked out to alpha, that's a different node in the same pack (Image Remove Background (Alpha)). This one recolors.

How it works

You tell it which color to hunt for and which color to lay down in its place, plus how loose the match should be. It walks the image, and any pixel close enough to your target color gets rewritten to the replacement. "Close enough" is the tolerance - that's the knob that decides whether you catch just the pure green pixels or all the muddy near-green ones around the edges too.

It's a pixel-color operation, not segmentation. It has no idea what a "background" is; it only knows color. So it'll happily recolor a green shirt in the foreground if the shirt matches your target. Keep that in mind when you pick your target.

The inputs and outputs that matter

You feed it an image, then set three things: the color to remove, the color to replace it with, and a tolerance for how near a pixel has to be to count. Out comes an image you wire onward - into a save node, a compositing step, or a mask node if you replaced the color with a clean black or white you can threshold.

The tolerance is the one you'll actually fiddle with. Everything else is "pick the color, pick the new color."

How to install it

It ships inside WAS Node Suite, so you install the whole suite once. Easiest route is ComfyUI Manager: open Manager, search WAS Node Suite, install, restart. By hand:

cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui
pip install -r was-node-suite-comfyui/requirements.txt

then restart ComfyUI. On the Windows portable build, run the pip line with python_embeded\python.exe -s -m pip install -r ... so it lands in the right environment - there's also an install.bat that tries to find and activate that env for you.

Common issues & troubleshooting

Halos around the edges. Generated images have anti-aliased edges - a fringe of pixels that are almost your target color but not quite. Set the tolerance too tight and you leave that fringe behind as an ugly rim. Nudge tolerance up until the edge goes clean, then stop before it starts eating colors you wanted to keep.

It's removing more than you meant. Same knob, other direction. Too high a tolerance and it grabs everything in the neighborhood of your color. If a foreground object shares the hue, it goes too. There's no "background only" here, so isolate first with a mask if the color you're killing also appears where you don't want it.

You wanted transparency and got a solid color. By design - see above. Reach for Image Remove Background (Alpha) instead.

The whole suite won't load. WAS Node Suite is a big, older pack (unmaintained since late 2023) that pulls in a pile of dependencies, and the classic symptom is an "Import Failed" on the pack after you update ComfyUI - usually a package-version collision (opencv is a repeat offender, especially if you also run ReActor/insightface). Reinstall the requirements against your actual ComfyUI Python, or run install.bat, and restart. The node itself is stable; it's the install that bites.

CategoryWAS Suite/Image/Process

Inputs (8)

NameTypeDefaultDescription
imageIMAGEThe image to repaint.
target_redINT2550–255Red level of the colour being looked for, 0 to 255.
target_greenINT2550–255Green level of the colour being looked for, 0 to 255.
target_blueINT2550–255Blue level of the colour being looked for, 0 to 255. The three together default to white.
replace_redINT2550–255Red level of the colour painted over every match, 0 to 255.
replace_greenINT2550–255Green level of the colour painted over every match, 0 to 255.
replace_blueINT2550–255Blue level of the colour painted over every match, 0 to 255. Leave all three at 255 and the matched area is painted white; set them to 0 for black.
clip_thresholdINT100–255How far a pixel may differ from the target colour and still be repainted. 0 repaints only exact matches, 10 tolerates slight gradients and compression noise, and a high value repaints most of the image.

Outputs (1)

NameTypeDescription
IMAGEIMAGEThe image with every matched pixel repainted in the replacement colour.