ComfyUI Node
BD Color Extract
Extract pixels matching a target color from an image as a greyscale mask. Pulls out all pixels close to the target color (within tolerance) and outputs a mask where matching pixels are white. Use hue mode for color-identity matching (any shade of the color regardless of brightness — perfect for painted shadow extraction). Use rgb_distance for strict RGB triplet matching.
BD Color Extract
- image
- mask
- color_mask
- mask
◄target_r0.00►
◄target_g0.00►
◄target_b1.00►
◄match_modehue►
◄tolerance0.15►
◄min_saturation0.10►
◄soft_edge0.050►
◄gradient_modefalse►
◄invertfalse►
Category🧠BrainDead/Segmentation
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Source image to extract color from. | |
| target_r | FLOAT | 0.000–1 | Target color RED component (0-1). Default 0.0 (for blue). |
| target_g | FLOAT | 0.000–1 | Target color GREEN component. Default 0.0 (for blue). |
| target_b | FLOAT | 1.000–1 | Target color BLUE component. Default 1.0 (for blue). |
| match_mode | COMBO | hue | hue (default): matches by color identity in HSV. Brightness-independent — 'any blue' regardless of how dark/light. Best for painted color extraction. rgb_distance: strict RGB Euclidean distance match. Use when you want only pixels very close to a specific RGB triplet. |
| tolerance | FLOAT | 0.150–1 | How loose the match is. In hue mode: tolerance in hue units (0.15 ≈ ±54° of hue). In rgb_distance mode: max distance in RGB space (0.15 ≈ pixels within 0.15 unit sphere of target). Lower = stricter. |
| min_saturation | FLOAT | 0.100–1 | HUE MODE ONLY — pixels with saturation below this are ignored (treated as non-matching). Prevents greys/near-whites from accidentally matching the target hue when their hue calc is unreliable. Set to 0 to match desaturated pixels too. Ignored in rgb_distance mode. |
| soft_edge | FLOAT | 0.0500–0.5 | Smoothstep falloff around the tolerance boundary. 0 = hard binary cutoff. Larger = softer mask edge. |
| gradient_mode | BOOLEAN | false | When ON: output is a smooth gradient based on HOW CLOSE each pixel is to the target color. Pixel at target = 1.0, far pixel = 0.0, smooth fade. Ignores soft_edge. Use for 'how much blue tint does this pixel have' style extraction. OFF: thresholded binary-ish mask with soft_edge. |
| invert | BOOLEAN | false | Invert the output mask (1 - mask). Use to extract everything EXCEPT the target color. |
| maskopt | MASK | Optional region mask. When provided, output is zero outside this region (restricts extraction to e.g. skin areas). |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| color_mask | IMAGE | Greyscale mask (3-channel image, R=G=B=mask_value). White where pixels match the target color, black elsewhere. |
| mask | MASK | Single-channel MASK version for nodes expecting MASK type. |