Color Selection Mask
Photoshop's Color Range, Minus the $20/Month
- image
- mask
If you've used Photoshop's Select → Color Range, you know this node already. Color Selection Mask picks every pixel near a target color and turns it into a selection - with a tolerance slider, edge feathering, and an invert toggle. In the TextureAlchemy pack it's the "make a selection image" tool you reach for when you want to edit only the blue part of a texture, or only the bright part, without touching the rest.
It shares its DNA with the pack's Custom Color to Mask, but there's one difference that matters a lot in a graph: this node outputs an IMAGE, not a MASK type. The mask is drawn as an RGB image (white = selected, black = not). That makes it convenient when the downstream node wants an image - say, an alpha channel to composite, or an input to a blend-mode node - and mildly annoying when it wants a real mask tensor.
How it works
Same core as Custom Color to Mask: it measures per-pixel color distance from target_color using one of three metrics, thresholds with tolerance, and feathers the result with feather. The extra knob here is invert, which flips the selection so you get everything except the target color - handy when the color you want to exclude is easier to describe than the region you want to keep.
The inputs that matter
image- input texture.target_color- hex#RRGGBB(default#FF0000).tolerance(0–1, default 0.2) - how wide a net. Raise it for gradients, skin, weathered surfaces.feather(0–0.5, default 0.1) - soft edge transition.mode- rgb / hsv / luminance. hsv is your friend when the color shifts with lighting; luminance selects by brightness.invert- flip the selection.
Output: mask, an IMAGE where white pixels are selected.
Where it slots in
The classic workflow: albedo → Color Selection Mask → get the gold trim as a mask → pipe it into the pack's Blend Mode Utility as the mask input so a multiply only darkens the trim. Or select the dark crevices of a height map by luminance, invert it, and you've got a highlight mask for edge wear. Because it emits an image, it pairs naturally with blend and color nodes rather than pure mask tooling.
Installing it
Part of TextureAlchemy:
cd ComfyUI/custom_nodes
git clone https://github.com/amtarr/ComfyUI-TextureAlchemy
restart ComfyUI, and it lives under Texture Alchemist → Masks. Manager users: search "Texture Alchemy". No extra dependencies - this is plain tensor math.
Gotchas
Know which output type you actually need. If the node downstream errors with "wrong type," it probably wants a MASK - that's Custom Color to Mask's job. And watch tolerance on noisy photos: because it's distance-based, a high tolerance on a textured surface will happily select half the image, so start at 0.1 and creep up. The invert toggle is the feature people forget exists, and it's usually the difference between fighting a selection and finishing one.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| target_color | STRING | #FF0000 | Target color in hex format (#RRGGBB) |
| tolerance | FLOAT | 0.200–1 | Color matching tolerance |
| feather | FLOAT | 0.100–0.5 | Edge softness |
| mode | COMBO | 3 options: rgb, hsv, luminance | |
| invert | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | IMAGE | — |