Nodes/comfyui_bmad_nodes/Hue Mode (InRange hsv)
ComfyUI Node Runs on cloud

Hue Mode (InRange hsv)

Set how hue wraps in color thresholding — Hue Mode (InRange hsv)

By bmad4ever·Created 3 years ago·Updated 9 months ago· 70
Hue Mode (InRange hsv)
    • IR_HUE_MODE
    ir_hue_modeSMALLEST

    Hue Mode (InRange hsv) is a one-widget node that produces the hue-handling strategy for the pack's InRange (hsv) color thresholder. It looks like a dropdown glued to a wire - because that's exactly what it is. The dropdown lives here so that the threshold node gets the choice as a typed input it can't accidentally skip.

    The reason it exists is the seam on the hue wheel. In OpenCV's HSV, hue runs 0 to 179, and it wraps: hue 0 and hue 179 are both red. If you define a color range between two bounds that straddle that seam, a naive "everything between the min and max" check selects the wrong arc - it grabs the colors between your two bounds going the long way around, which is usually everything you didn't want. The InRange (hsv) node therefore lets you choose how to interpret the two colors, and this node supplies that choice.

    The modes

    Five options, and knowing them is the whole game:

    • SMALLEST (default) - pick the shorter arc between the two hue bounds. Handles the seam automatically: if the short way crosses 0/179, it splits the check into two. This is the one to reach for 90% of the time.
    • LARGEST - pick the longer arc. For "everything except this narrow hue band."
    • IGNORE - throw hue away entirely and threshold only on saturation and value. Useful when brightness/saturation is what distinguishes the region, not color.
    • SINGLE - one plain min..max check between the bounds, ignoring which arc is smaller. Fine for ranges that never cross the seam; wrong if they do.
    • SPLIT - two checks split at the two hue bounds and OR'd together. The explicit "my range crosses the seam" mode.

    The node returns the mode as an IR_HUE_MODE value, which is what the hue_mode input on InRange (hsv) consumes.

    How it works

    Under the hood it's the pack's ComboWrapperNode metaclass: a tiny pattern that turns an enum widget into a typed output. The output IR_HUE_MODE is a custom type, which is why you can't just type "SPLIT" into the threshold node - the socket only accepts this node's wire. It's a clean way to make a required parameter explicit in the graph instead of hiding it as a widget that gets forgotten.

    Inputs and outputs

    • ir_hue_mode - an enum widget, default SMALLEST, choices: SMALLEST, LARGEST, IGNORE, SINGLE, SPLIT.
    • Output: one IR_HUE_MODE, wired into InRange (hsv)'s hue_mode socket.

    Install

    Ships in bmad4ever/comfyui_bmad_nodes. Via ComfyUI Manager, search "comfyui_bmad_nodes" ("Bmad Nodes"), install, restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/bmad4ever/comfyui_bmad_nodes
    cd comfyui_bmad_nodes
    pip install -r requirements.txt
    

    Restart ComfyUI after. No model files; OpenCV comes from the requirements.

    Common issues

    The main confusion is forgetting what the default is doing. If your color range crosses the 0/179 hue seam and you leave it on SINGLE, you'll silently select the wrong half of the color wheel - switch to SMALLEST or SPLIT. Conversely, if your range is entirely within one side of the wheel, SMALLEST and SINGLE behave the same, so don't overthink it. And if you ever see an empty hue_mode socket on InRange (hsv), this node is what you're missing - the threshold node won't run without it.

    CategoryBmad/CV/Thresholding

    Inputs (1)

    NameTypeDefaultDescription
    ir_hue_modeCOMBOSMALLEST5 options: SMALLEST, LARGEST, IGNORE, SINGLE, SPLIT

    Outputs (1)

    NameTypeDescription
    IR_HUE_MODEIR_HUE_MODE