Color Similarity
Find every pixel near a target color and get a mask for it
- image
- mask
- similarity_info
ColorSimilarity is the pack's color-keying node: give it an image and a target color, and it returns a mask of every pixel close to that color, plus JSON describing the match. Where most of the analysis nodes in this pack output strings, this one outputs something you can actually wire into an image pipeline - masks feed directly into inpaint, compositing, or any mask-driven node. If you've ever wanted to "select all the red, please," this is that, as a node.
How it works
It computes a per-pixel distance between each pixel and the target color, in the color space you choose, and thresholds it against similarity_threshold to build the mask. The default color_space is LAB, which is the right call for this kind of work: Euclidean distance in LAB tracks perceived color difference far better than raw RGB distance. Pick RGB if you want strict channel matching (e.g. chroma-keying a specific code), HSV if you care about hue at the expense of brightness.
The target_color input accepts hex (#FF0000) or an RGB value. similarity_threshold runs 0 to 1, default 0.3 - lower means stricter (fewer pixels match), higher means sloppier. For a tight match on a saturated color start around 0.1–0.15; for a loose "all the warm tones" you'll be pushing toward 0.4+.
The outputs
- mask (IMAGE) - a grayscale-like mask where bright = close to target. Feed it straight into a MaskFromImage-compatible node or use it in an inpaint chain. This is the output that makes the node worth having.
- similarity_info (STRING) - the match statistics as JSON: how many pixels matched, at what percentage, and the distance stats. Handy for logging or for threshold tuning - run once, read the "matched %" value, dial the threshold from there.
A workflow worth stealing
The killer use: mask out a background color before an inpaint pass. Load the image, pick the background color with ColorSimilarity, and use the resulting mask to target the inpaint - instead of hand-painting a mask for every image in a batch. It's also a legit palette-location tool: pair it with DominantColors, grab a palette color as your target, and immediately see where that color actually lives in the frame.
Install
Standard pack install - ComfyUI Manager, search "ComfyUI Color Profile Reader," or:
cd ComfyUI/custom_nodes
git clone https://github.com/APZmedia/ComfyUI-color-tools
Restart after. Watch for the README's placeholder clone URL (yourusername/ComfyUI-color-tools.git - use APZmedia/). This node needs numpy and OpenCV (for the HSV/LAB conversions), both in the pack's optional deps that install.py installs at startup. If the color-analysis group is missing from your node list while the reader nodes are present, an optional dependency failed to install - check the startup log.
One honest limitation: this is distance-based, not semantic. It finds pixels near a color, not "the object." A red car and a red shirt both match target red, and there's no shape/region awareness. For per-object selection you want a segmentation node - for raw color keying, this is the right tool and a fast one.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| input_mode | COMBO | tensor | 2 options: file, tensor |
| target_color | STRING | #FF0000 | — |
| similarity_threshold | FLOAT | 0.300–1 | — |
| color_space | COMBO | LAB | 3 options: RGB, HSV, LAB |
| imageopt | IMAGE | — | |
| image_pathopt | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| mask | IMAGE | — |
| similarity_info | STRING | — |