ComfyUI Node Runs on cloud

HSVThresholdMask

Select by color, not by geometry

By EllangoK·Created 3 years ago·Updated 2 years ago· 256
HSVThresholdMask
  • image
  • IMAGE
low_threshold0.2
high_threshold0.7
hsv_channel

Drawing a mask around a subject is easy. Selecting "everything that is this color" is the thing that's genuinely hard to do by hand, and it's exactly what HSVThresholdMask is for. It converts your image to HSV - hue, saturation, value - and returns a mask of every pixel whose chosen channel falls between two thresholds. Want to isolate a sky by hue, or a shiny highlight by value? This node finds it in one pass. It's the pack's answer to chroma-keying without the green screen.

How it works

The image is converted to HSV with OpenCV, one channel is selected, and cv2.inRange returns a binary mask of pixels within the low/high band. The output comes back normalized to 0–1 (white = selected), which is the format ComfyUI masks expect.

  • hsv_channel - pick which channel you're thresholding:
    • hue - the actual color. This is your "everything that's this hue" selector. Note hue here is measured 0–1, mapped internally to OpenCV's 0–180 degrees, so 0.5 ≈ 90° - pure green territory.
    • saturation - how vivid the color is. Threshold low-to-high to grab just the muted pixels, or just the punchy ones.
    • value - brightness. Useful for selecting highlights or shadows regardless of color.
  • low_threshold (0–1, default 0.2) and high_threshold (0–1, default 0.7) - the band of values that become the mask.

Output is an IMAGE (a grayscale mask).

Install

HSVThresholdMask is one of ~22 nodes in ComfyUI-post-processing-nodes.

  • ComfyUI Manager: search "post processing nodes", install, restart.
  • Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/EllangoK/ComfyUI-post-processing-nodes

Restart after. No requirements.txt or downloads - it needs cv2, which stock ComfyUI ships. It's under postprocessing → Masks in the node menu.

Where it shines

The classic combo: threshold by value to make a highlight mask, then feed that mask into the pack's DodgeAndBurn to brighten or tone the lit areas - instant relighting without touching the shadows. Or threshold by hue around skin tones to mask a face for targeted processing. The one thing that trips people up is the hue wrap: hue is a circle, so "red" spans both ends of the 0–1 range, and a single low/high band won't capture both sides - you may need two masks OR'd together for reds. Otherwise it's one of the more satisfying "it just works" nodes in the pack.

Categorypostprocessing/Masks

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
low_thresholdFLOAT0.20–1
high_thresholdFLOAT0.70–1
hsv_channelCOMBO3 options: hue, saturation, value

Outputs (1)

NameTypeDescription
IMAGEIMAGE