Nodes/MdColorMod/Color Threshold (MD)
ComfyUI Node

Color Threshold (MD)

Turn any image into a hard black-and-white matte

By MdONeilsl·Created 2 months ago·Updated 2 months ago· 0
Color Threshold (MD)
  • image
  • mask
  • image
ChannelValue
Low127
High255

Thresholding is the oldest trick in image processing: pick a channel, pick a cutoff, and collapse the image into pure black and pure white. mdColorThreshold does exactly that, and it's surprisingly handy in a ComfyUI graph - it's how you build a hard matte from a luminance map, extract a silhouette, or give a render that brutal high-contrast graphic look without touching a single generation parameter.

How it works

The node picks one of seven channels to measure, computes that value for every pixel, and compares it against Low and High. Pixels whose channel value lands between Low and High go white; everything outside that band goes black. The channel choices:

  • Value - the max of RGB per pixel, i.e. HSV Value. Default, and the bluntest.
  • Red / Green / Blue - a single color channel.
  • Alpha - the alpha channel (all ones if you feed RGB, so it's a no-op unless you have RGBA).
  • Luminance - Rec.601-weighted brightness (0.299 R + 0.587 G + 0.114 B), the "does this pixel read as bright" option.
  • RGB - all three channels must be inside the band for white; the strict one.

It's a band-pass, not a one-sided cut. With the defaults - Low 127, High 255 - everything at or above the Low goes white and the band is effectively "everything brighter than 127," which is the classic threshold. Drag High down and you carve out a middle band instead. If you set Low above High, the node just swaps them for you.

The inputs that matter

  • image - your IMAGE.
  • Channel - the dropdown above.
  • Low / High - 0–255 thresholds. Default 127/255.
  • mask - optional, restricts where the threshold applies (masked areas stay original).

Output is a binary image - pixels are literally 0 or 1. Alpha is preserved for RGBA input. One gotcha: the output type is IMAGE, not MASK; if the node downstream specifically wants a mask socket you may need a conversion step. For building selection-ish helpers, feed this into whatever accepts an IMAGE.

Install

Zero dependencies, no models, same as the rest of the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/MdONeilsl/ComfyUI-MdColorMod

Restart ComfyUI or install "MdColorMod" via ComfyUI Manager.

Where people get burned

The name promises "below Low goes one way, above High goes the other" - actually it's the in-between band that goes white, which surprises people the first time they set Low to 50 and High to 200 and watch the middle of the range light up instead of the extremes. If all you want is "everything above this brightness goes white," leave High at 255 and you'll never hit the surprise. Also pick the channel deliberately: Value and Luminance look similar but behave differently on saturated colors - a saturated red pixel can have high Value and low Luminance at the same time, which decides which side of the threshold it lands on.

Categorymd/image/color

Inputs (5)

NameTypeDefaultDescription
imageIMAGEInput image tensor.
ChannelCOMBOValueChannel to use for thresholding.
LowFLOAT1270–255Lower threshold value (0-255).
HighFLOAT2550–255Upper threshold value (0-255).
maskoptMASKOptional mask to restrict the adjustment area.

Outputs (1)

NameTypeDescription
imageIMAGEThe thresholded image.