BD Color Extract
Pull every blue pixel out of an image as a mask — no model required
- image
- mask
- color_mask
- mask
Sometimes you don't need a segmentation model to find the thing - the thing is just a color. A blue viseme atlas where you need the blue pixels. A painted shadow region that's a specific hue. A wardrobe item that's a flat color on a transparent render. BD ColorExtract finds every pixel close to a target color and hands you a mask. Zero model load, zero inference, milliseconds - and it's the kind of deterministic op the KB's post-processing doc would tell you to reach for instead of another diffusion pass.
The default is set up for the pack's own use case: target_b is 1.0 and the mode is hue, so out of the box it extracts blue. The defaults literally spell out "Default 0.0 (for blue)" in the tooltips. Change the RGB floats to pick any color.
The inputs that matter
- image - the source.
- target_r / target_g / target_b - the target color, each 0–1. Defaults are blue (0, 0, 1).
- match_mode - the heart of it.
hue(default) matches by color identity in HSV, ignoring brightness - "any blue, dark or light." That's the one for painted shadow extraction, where the same hue appears across many brightness levels.rgb_distancematches a strict RGB triplet within a tolerance - for when you want only pixels very near one exact color. - tolerance - how loose the match is. In hue mode, 0.15 ≈ ±54° of hue. Lower = stricter.
- min_saturation - hue mode only: pixels below this saturation are ignored, so greys and near-whites don't falsely match the target hue (their hue is noise). Set 0 to include them.
- soft_edge - smoothstep falloff around the tolerance boundary, 0 = hard binary cut.
- gradient_mode - ON gives a continuous mask scaled by how close each pixel is to the target color (target = 1.0, far = 0.0). The "how blue is this pixel" extraction, useful for tint maps. OFF gives the thresholded mask.
- invert - flip to extract everything except the color.
- mask (optional) - restrict extraction to a region; output is zero outside it, so you can limit color matching to skin areas, for example.
Outputs come in both flavors: color_mask (a 3-channel greyscale image, R=G=B=mask value) and mask (a single-channel MASK for nodes that want that type). You don't have to convert - both are there.
The workflow shape
[render/atlas] → [BD ColorExtract] → mask → [inpaint / composite / mask-flatten / pack]
target: your color
match_mode: hue
A natural pairing is with the pack's other segmentation outputs: use a mask from this node to drive a crop, an inpaint region, or feed a mask-flatten for a game texture. Because it's a lookup-style op it runs instantly, so you can afford to tune tolerance and soft_edge live and watch the mask update.
Installing it
Part of BizaNator/ComfyUI-BrainDead (BrainDeadGuild). ComfyUI Manager → search "BrainDead" → install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/BizaNator/ComfyUI-BrainDead
cd ComfyUI-BrainDead
pip install -r requirements.txt
Restart; it's under 🧠BrainDead/Segmentation.
Gotchas
Hue mode is powerful and has a trap: pure greys and whites have unreliable hue, which is exactly why min_saturation defaults to 0.1 - if you're getting noise from neutral areas, raise it. And remember hue-mode matching is brightness-blind by design, so if you actually need "that exact mid-blue and not the dark navy version," switch to rgb_distance and tighten tolerance. Two output channels can confuse people at first - a node wanting IMAGE gets color_mask, a node wanting MASK gets mask; they're the same data in two wrappers. Finally, on very desaturated or color-graded sources, tune tolerance from a known pixel - guessing the value blind is how you get a mask that covers half the image.
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. |