Nodes/ComfyUI-TextureAlchemy/Color Selection Mask
ComfyUI Node

Color Selection Mask

Photoshop's Color Range, Minus the $20/Month

By amtarr·Created 9 months ago·Updated 4 months ago· 58
Color Selection Mask
  • image
  • mask
target_color#FF0000
tolerance0.20
feather0.10
mode
invertfalse

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.

CategoryTexture Alchemist/Masks

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
target_colorSTRING#FF0000Target color in hex format (#RRGGBB)
toleranceFLOAT0.200–1Color matching tolerance
featherFLOAT0.100–0.5Edge softness
modeCOMBO3 options: rgb, hsv, luminance
invertBOOLEANfalse

Outputs (1)

NameTypeDescription
maskIMAGE