Color Image Fill Rm
Recolor a mask (or punch a color out) without leaving the graph
- images
- image
Every now and then you get a mask or an overlay that's the right shape and the wrong color. A segmentation output that fills its subject in red instead of white. An annotation layer with boxes in a color your pipeline chokes on. A generated image with a background tone you want to swap for a cleaner one. Normally that's a trip to GIMP or a five-line PIL script, round-trip and back. ColorImageFillRm does it in the graph, in one node, on a whole batch - and it can also make a color fully transparent in the same pass.
It's from comfyui-missed-tool, the small utilities pack by ifmylove2011. The README's framing is honest about the sweet spot: "useful in certain scenes where mask images are overlaid with layers." Think of it as an in-graph chroma-key trimmer for whatever colors your intermediate steps introduced.
How it works
Pure torch, no PIL round-trip. The node looks at the shape of your batch:
- If the input already has an alpha channel, it keeps it. If not, it appends an opaque one on the fly.
- For every color you list in
color_src, it finds matching pixels (within the threshold) and paints them with the matching color fromcolor_replace. - Then it takes
rm_color, finds pixels matching that, and zeroes their alpha - that's the "Rm" in the name, removal to transparency.
The threshold is an Euclidean distance in normalized 0–1 RGB space, and the author's tooltip is refreshingly concrete: a default of 0.05 ≈ about ±13 levels per channel. Small number, small tolerance.
The inputs that matter
images- the IMAGE batch you're cleaning up.color_src- the colors to find, hex with#, comma-separated (default#ffffff,#ff0000).color_replace- the swaps, same comma-separated hex format (default#00ffff,#0000ff). The count must matchcolor_src, or the node throws a ValueError.rm_color- the color to make transparent (default#000000).threshold- match tolerance, default0.05. If your target colors bleed or your image is soft, nudge it up; if you're getting unintended swaps, nudge it down.
The single output, image, is always RGBA after processing - even if your input was plain RGB, it comes out with an alpha channel.
Installing it
Grab it via ComfyUI Manager by searching comfyui-missed-tool, or do it by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/ifmylove2011/comfyui-missing-tool
cd comfyui-missing-tool
pip install -r requirements.txt
Restart, and the node sits under the "missed-tool" menu section. Dependencies are just torch, numpy, Pillow - all already in a stock ComfyUI - and there are no model downloads to babysit. (The README's clone URL uses "comfyui-missed-tool"; the repo is "comfyui-missing-tool", and GitHub redirects either spelling.)
Where people get burned
- Counts must match. Two colors in
color_srcand three incolor_replace? Hard error. Keep them paired one-to-one. - The output has alpha. If the next node in your chain is expecting plain RGB, it'll silently drop the channel or behave like an RGBA tensor - wire a Composite or a dedicated RGBA consumer in if that matters.
- Threshold is small and normalized.
0.05is roughly 13/255 per channel. Colors that look close to you in a thumbnail may be outside the tolerance; that's usually a good thing, but expect to tune it on your first real job. - Replacement colors are opaque. Color swapping never touches alpha - only the explicit
rm_colorpass punches pixels out.
For mask cleanup and color-driven compositing it's a genuinely handy tool, and it being in-graph means the fix is reproducible the moment you save the workflow.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| color_src | STRING | #ffffff,#ff0000 | 要替换的颜色,可以输入多个颜色,用逗号分隔 |
| color_replace | STRING | #00ffff,#0000ff | 对应的替换颜色,数量需与 color_src 相同 |
| rm_color | STRING | #000000 | 要透明化的颜色 |
| threshold | FLOAT | 0.050–1 | 颜色匹配容差(欧氏距离)。0.05≈RGB每通道±13色阶的偏差。 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |