Dye Image β‘π ‘π π £π
Swap one color for another, with tolerance
- image
- IMAGE
A plain, useful little utility that doesn't need much dressing up: find pixels matching one RGB color and recolor them to another, within a tolerance. It's the tool you reach for when you've got a specific flat color in a render - a green-screen-style background, a UI element, a solid prop color - that you want to swap out without touching anything else in the frame.
How it works
You give it source_rgb (the color to look for) and target_rgb (what to replace it with), both as "R,G,B" strings, plus a tolerance that controls how close a pixel's color has to be to source_rgb to count as a match. At tolerance 0 you're matching that exact color and nothing else; raise it and you start catching near-matches too - anti-aliased edges, slight compression artifacts, or a color that isn't perfectly flat across the whole region. Every matching pixel gets recolored to target_rgb; everything else passes through unchanged.
The inputs and outputs that matter
image(IMAGE, required) - "Input image to be processed."source_rgb(STRING, default"255,255,255") - "Source RGB color to replace in format 'R,G,B'."target_rgb(STRING, default"0,0,0") - "Target RGB color to replace with in format 'R,G,B'."tolerance(default 0.01, range 0β1) - "Color matching tolerance."
Output: a single IMAGE, same dimensions as the input, with matching pixels recolored.
If you're picking colors visually rather than typing RGB triplets by hand, the pack's Color_Picker node outputs an rgb_color string in exactly this "R,G,B" format - wire it straight into source_rgb or target_rgb.
How to install it
Via ComfyUI Manager: search "RyanOnTheInside," install, restart. By hand:
cd ComfyUI/custom_nodes
git clone https://github.com/ryanontheinside/ComfyUI_RyanOnTheInside.git
cd ComfyUI_RyanOnTheInside
pip install -r requirements.txt
then restart ComfyUI. This is straightforward pixel math on the pack's opencv-python/scikit-image stack - no model download.
Common issues & troubleshooting
Nothing gets recolored. Double-check source_rgb is formatted correctly as "R,G,B" (comma-separated, no extra spaces or brackets) - a malformed string is the most common reason a node like this silently matches nothing. Also confirm the color you're targeting is actually close to what you typed; sample the exact pixel value first if you're not sure.
Too much (or too little) of the image gets recolored. That's tolerance. Default is tight (0.01) - if you're not catching anti-aliased edges or slightly varying shades of your source color, raise it gradually. If it's bleeding into colors you didn't intend to touch, lower it.
Edges of the recolored region look rough or aliased. This node does a hard match-or-no-match per pixel based on tolerance - it's not a soft feathered blend at the boundary. For a cleaner edge, either tighten tolerance so it only catches the true flat-color region, or clean up the transition with a separate blur/composite step afterward.
Recolored area has visible seams against a compressed or noisy source image. Compression artifacts mean pixels that look like a flat color to your eye aren't actually uniform at the pixel level - raise tolerance slightly to compensate, or work from an uncompressed source if you have one.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Input image to be processed (IMAGE type) | |
| source_rgb | STRING | 255,255,255 | Source RGB color to replace in format 'R,G,B' (default: '255,255,255') |
| target_rgb | STRING | 0,0,0 | Target RGB color to replace with in format 'R,G,B' (default: '0,0,0') |
| tolerance | FLOAT | 0.0100β1 | Color matching tolerance (0.0 to 1.0) |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | β |