Nodes/ComfyUI_ScarlotSoft/ScarlotSoft Mask From Color
ComfyUI Node

ScarlotSoft Mask From Color

Chroma-key style masks from a color picker — the ScarlotSoft Mask From Color node

By scarlotsoft·Created 2 months ago·Updated about a month ago· 0
ScarlotSoft Mask From Color
  • image
  • MASK
color_hex#FF0000
tolerance10

Sometimes the fastest mask isn't a segmenter or a hand-paint - it's "select everything that's this color." ScarlotSoft Mask From Color is that node: give it an image, pick a color, set a tolerance, and it returns a MASK covering every pixel within tolerance of that color. Classic chroma-key thinking, implemented for the green-screen-adjacent cases where your subject sits on a solid background and you need the background gone.

The inputs are minimal: image, color_hex (a string that defaults to #FF0000), and tolerance (0–255, default 10). The JS layer upgrades color_hex from a text field into an actual HTML color picker - click the swatch, pick a color, done - while keeping the hex string in the background so the backend knows what you chose. The mechanism is plain tensor math: convert the hex to RGB, compute the absolute difference between every pixel and the target color across the RGB channels, and build a boolean mask from diff <= tolerance. If the image is 0–1 floats it scales the tolerance accordingly, so it behaves identically regardless of which pipeline produced the image. Output is a single MASK.

Tolerance is the dial that makes or breaks it. Too low and the mask has holes where lighting varies; too high and it swallows the subject's edges. The 0–255 scale maps to per-channel color distance, and the practical range for a flat background is usually 10–40 - start at 10, raise it until the background fills in, and don't chase perfection, because any mask you get here can be feathered downstream. Because it keys on color distance and not on a segmenter's notion of "background," it's also the right tool for selections where the thing you want is defined by its color - a red cape, a blue sky, a specific tint.

Where it slots into a workflow: output the MASK into Easy Mask Conditioning or SetMask for an inpainting pass, or into the suite's ImageMaskPreview to see the selection overlaid before you commit a render. It pairs naturally with the color-overlay preview node, and you'll want the preview - a raw boolean mask on a busy image is hard to judge blind.

Install with the pack - ComfyUI Manager → search ScarlotSoft → install → restart:

cd ComfyUI/custom_nodes
git clone https://github.com/scarlotsoft/ComfyUI_ScarlotSoft

No dependencies, no models. Suite theme; hard-refresh after a UI-mode switch if the color swatch doesn't render.

Honest limits: color distance is color distance - a gradient background or strong shadows will beat it, and it can't do "the subject, whatever color it is" (that's a segmenter's job, e.g. the suite's GroundedSAM). But for solid-background extraction, the color picker plus tolerance is the fastest mask in the graph, and the whole thing is genuinely beginner-friendly: no threshold vocabulary, no model downloads, just pick a color and go.

CategoryScarlotSoft/Masking

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
color_hexSTRING#FF0000
toleranceINT100–255

Outputs (1)

NameTypeDescription
MASKMASK