Flexible color extract v5.1.0
Build a mask from 'close enough to this color'
- image
- MASK
Most "extract this color" nodes do a distance check in RGB space and produce a hard, brittle mask. Flexible color extract is smarter: it treats each pixel's RGB value as a vector in a 4D space (the fourth dimension is derived from how "dark" the color is), then takes the angle between that vector and a reference color vector. Same direction means same hue; length only changes brightness. The result is a smooth mask where pixels of the same hue score high and different hues fall off gently - which is exactly what you want when the thing you're isolating is a garment in slightly-varying light.
Under the hood (in the pack's light_layer.py) it's the math for a normalized dot product between pixel color and reference color, optionally pushed through a smooth-step curve so you can decide how sharp the transition is. This is why the naming is what it is - the node's real name in code is main_light_layer, and "flexible color extract" is the display name. Same node, one mental model.
Inputs that matter
image- what you're masking.ref_r,ref_g,ref_b- the reference color, each 0–255. Default 255/255/255 is white. Pick your target color from a color picker; this trio is the whole point of "flexible."do_scale-enableordisable. Enabled, the similarity score gets stretched through the smooth-step curve; disabled, you get the raw dot product (softer, more permissive).thresh_low(0.6) andthresh_high(1.0) - the low and high ends of the smooth-step stretch when scaling is on. Loweringthresh_lowmakes the mask grab more of the hue, including darker shadows.
Output
A single MASK. Feed it straight into a mask-based recolor, an inpaint, or a composite. In the pack's pipeline it's the entry point for recoloring a garment in a specific color range.
Real-world use
Classic case: you have a product shot with a garment in a known color and you want to isolate just that fabric - for a recolor in LAB space, to generate a mask for an edit, or to measure coverage with something like the pack's mask-area node. Because it's hue-based rather than threshold-based, it survives gradients and shadows far better than "pixels brighter than X."
Gotchas
- The output is inverted from what you might expect if you're used to "white = target." The similarity score is high for the target hue, so after the smooth-step stretch the target pixels come out bright. Check the preview before wiring it into anything that assumes a convention.
- It expects BGR internally (OpenCV convention), so if you're comparing against a reference hex from a web tool, double-check the channel order once if results seem inverted or shifted.
- No models, no downloads - pure numpy/OpenCV inside the pack. Cheap to run in a loop, which makes it a good fit for auto-masking batches.
For color-based masking that doesn't shatter on the first shadow, this is one of the more thoughtful nodes in the pack. Just remember the 4D angle trick when someone asks you why it handles shading so well.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| ref_r | INT | 2550–255 | — |
| ref_g | INT | 2550–255 | — |
| ref_b | INT | 2550–255 | — |
| do_scale | COMBO | 2 options: enable, disable | |
| thresh_low | FLOAT | 0.600–1 | — |
| thresh_high | FLOAT | 1.000–1 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |