Extract Red
Isolate the red markup, kill everything else — before anything else tries to read your diagram
- image
- image
If you've ever fed a marked-up drawing into a line detector and watched it try to count your red annotation strokes as actual lines, you already know why this node exists. Extract Red does one thing: it turns every pixel that isn't "red enough" into pure white, leaving you with only the red markings on a clean background. It's the sibling of the pack's Extract Black, aimed at the opposite job - pulling annotations, corrections, or highlighted regions out of a diagram so the rest of the pipeline stops tripping over them.
How it works
This is a per-pixel color test, not a model, and it's fast enough to run on anything. A pixel counts as "red" when three conditions hold at once: the red channel is at least red_threshold, red beats the higher of green and blue by at least red_dominance, and both green and blue stay under max_other_channels. Every pixel that fails the test becomes white. Everything that passes keeps its original color (or gets flattened to pure (1,0,0) red if you turn off preserve_original_red).
That three-way check is what separates "red" from "orange" and "pink." A salmon-colored fill can have a high red channel, but it also has green and blue high enough that it fails the dominance test. If you're finding yellow or pink sneaking through, tighten red_dominance and lower max_other_channels; if your reds are faded or light, lower red_threshold from its 0.4 default.
The inputs that matter
red_threshold(0–1, default 0.4) - how bright red must be. 0.0 means "any hint of red," 1.0 means "pure red only."red_dominance(0–1, default 0.2) - how much red must outrank green/blue. This is your "redness" knob.max_other_channels(0–1, default 1.0) - cap on green and blue. Lower it for purer reds.invert_output- swaps to a white-on-red output if some later node wants that.
The single output, image, wires straight into the pack's LineDetector or RasterToUniformSVG, or anywhere else that expects a clean binary-ish image.
Install
Extract Red ships inside ComfyUI-HappNodeSet (author mikemojen, "Happrecision"), so you get the whole pack - the line counter family, the SVG tools, the laser-path stuff. ComfyUI Manager: search HappNodeSet and install. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/mikemojen/ComfyUI-HappNodeSet.git
pip install -r ComfyUI-HappNodeSet/requirements.txt
Then restart ComfyUI. The deps are numpy, OpenCV, scipy, scikit-image, Pillow, torch, and svgwrite - nothing exotic, though if your venv is already battle-scarred from other nodes, that's the usual spot for conflicts (the classic custom-node dependency dance, as the ecosystem docs love to warn about).
Common issues
The main gotcha is the opposite of what you'd expect: too strict detection. Red pen scans badly - cheap red ink reads more like a dark maroon, and your red strokes can vanish entirely at the defaults. Drop red_threshold toward 0.25–0.3 for scanned pencil-and-red markup. Second gotcha: antialiased edges. A red stroke blended over white produces pink edges that fail the dominance test and stay white, giving you slightly thinned lines. That's usually fine before a skeletonizer, but if you're measuring lengths, don't be surprised by a small underestimation. Run a quick Preview Image node on the output before committing to downstream numbers - the whole point of this node is that what you see is what gets measured.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| red_threshold | FLOAT | 0.400–1 | Minimum red channel value required (0.0 = any red, 1.0 = pure red only) |
| red_dominance | FLOAT | 0.200–1 | How much the red channel must exceed green and blue (0.0 = no dominance required, higher = stricter) |
| max_other_channelsopt | FLOAT | 1.000–1 | Maximum allowed value for green and blue channels (lower = purer reds only) |
| preserve_original_redopt | BOOLEAN | true | If enabled, keeps original red pixel colors; if disabled, converts red pixels to pure red (1,0,0) |
| invert_outputopt | BOOLEAN | false | If enabled, outputs white background with inverted colors |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |