Nodes/comfyui_cv/CV Color Range
ComfyUI Node

CV Color Range

Selects the pixels whose colour is within `tolerance` of `center` on every channel - 'cv2.inRange around a value' rather than lower/upper bounds. Unlike the raw inRange it is CIRCULAR-aware: tell it via `format` which channel is a hue and its period, and the band wraps, so a hue centred on 0 also keeps values near the top of the range (red across the 179/0 seam) in ONE pass. Center/tolerance take one value per channel (a 'CV Scalar' literal, or the outputs of 'CV Color Range From Sample'); a single value broadcasts. Outputs a 0/255 mask - chain into morphology / bitwise_and or 'CV Array -> Mask'. Convert to HSV/HLS first (cv2_cvtColor) for intuitive hue/sat/val selection.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Color Range
  • image
  • center
  • tolerance
  • mask
formatlinear - no circular channel (BGR/RGB/Lab/Luv/YCrCb/gray)
Categoryimage/CV/segmentation

Inputs (4)

NameTypeDefaultDescription
imageNPARRAY,IMAGEColour array in whatever space you want to threshold (BGR, HSV, Lab, a single hue channel...). Set 'format' to match. 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.
centerNPARRAYTarget colour, one value per channel, e.g. a 'CV Scalar' (60, 200, 200) for green in 8-bit HSV. A single value broadcasts to every channel.
toleranceNPARRAYAccepted half-width per channel, e.g. (15, 60, 60). A pixel is kept when every channel is within center +/- tolerance; for a circular channel a tolerance >= period/2 accepts every hue.
formatCOMBOlinear - no circular channel (BGR/RGB/Lab/Luv/YCrCb/gray)Which channel (if any) is a circular hue, and its period - numpy arrays carry no colour-space tag. All other channels are treated linearly.

Outputs (1)

NameTypeDescription
maskNPARRAYuint8 0/255 mask of the in-range pixels.