ComfyUI Node
CV Color Range From Sample
Learns a colour band from the image itself: it samples the pixels (inside `region` if given, else the whole image), takes their per-channel center and spread, and keeps everything within `sigma` * spread of that center. Spread is the standard deviation for linear channels and the CIRCULAR standard deviation for a hue channel (set via `format`), so a reddish sample straddling the 179/0 seam is measured correctly. Seed `region` with a scribble or the polygon mask of 'CV Annotate Points' over the colour you want. Outputs the mask plus the derived `center` and `tolerance` (feed them to 'CV Color Range' to reuse the band on another image, or inspect them).
CV Color Range From Sample
- image
- region
- mask
- center
- tolerance
◄sigma2.5►
◄formatlinear - no circular channel (BGR/RGB/Lab/Luv/YCrCb/gray)►
Categoryimage/CV/segmentation
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | NPARRAY,IMAGE | Colour array to sample and threshold (set 'format' to match its colour space). A ComfyUI IMAGE arrives as BGR uint8. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size. | |
| sigma | FLOAT | 2.50–20 | Band half-width in standard deviations: tolerance = sigma * spread per channel. ~2-3 keeps most of a normally-distributed colour; raise to be more permissive. |
| format | COMBO | linear - no circular channel (BGR/RGB/Lab/Luv/YCrCb/gray) | Which channel (if any) is a circular hue, and its period. The hue center/spread are then computed circularly. |
| regionopt | NPARRAY,MASK | Mask marking which pixels to sample (non-zero = sample). The polygon output of 'CV Annotate Points' plugs in directly. Omit to sample the whole image. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| mask | NPARRAY | uint8 0/255 mask of the in-range pixels. |
| center | NPARRAY | Per-channel sampled center (circular mean for the hue channel) - float64, one element per channel. |
| tolerance | NPARRAY | Per-channel sigma * spread used for the band - feed it and 'center' into 'CV Color Range'. |