Nodes/Jovimetrix/THRESHOLD (JOV) πŸ“‰
ComfyUI Node

THRESHOLD (JOV) πŸ“‰

Clip any input to clean 0-or-1 masks

By AmoranoΒ·Created 3 years agoΒ·Updated 12 months agoΒ· 397
THRESHOLD (JOV) πŸ“‰
  • πŸ‘Ύ
  • πŸ–ΌοΈ
  • 😷
β—„πŸ§¬ADAPT_NONEβ–Ί
β—„βš’οΈBINARYβ–Ί
β—„πŸ“‰0.500β–Ί
β—„πŸ“3β–Ί
β—„πŸ”³0.00β–Ί

The pack's own description nails this node in six words: "Clip an input to explicit 0 or 1." THRESHOLD takes any image or mask and turns it into a hard binary version - every pixel ends up fully on or fully off. If you've ever had a soft gray mask that needed to be a crisp selection, or a color image where you wanted to isolate the bright parts, this is the node.

It's built on OpenCV's threshold functions, exposed in a friendly wrapper. πŸ‘Ύ is the input (image or mask). 🧬 Adapt picks between ADAPT_NONE (one global cutoff) and ADAPT_MEAN or ADAPT_GAUSS (a cutoff computed locally per pixel - the fix for uneven lighting). βš’οΈ Function is the flavor of threshold: BINARY (the default - above the line goes white, below goes black), TRUNC (caps bright pixels at the threshold instead of flipping them), or TOZERO (zeroes dark pixels, keeps bright ones as-is). πŸ“‰ is the threshold value itself (0–1, default 0.5) - the dividing line. πŸ“ Size is the adaptive block size (3–103) used when you switch to adaptive mode. πŸ”³ is an invert toggle (0–1), so a quick flip gives you "everything below the line" instead of above.

Outputs are πŸ–ΌοΈ IMAGE and 😷 MASK, both as lists, and you'll almost always want the mask one. The image output is there because sometimes the binary result is easier to preview or needs to go into a color pipeline, but the mask is what plugs into compositing, inpainting, and masking nodes.

The workflow it lives in: take something messy - a soft matte, a noisy grayscale, a channel from PIXEL SPLIT - and THRESHOLD turns it into a decision. Inpainting regions, subject extraction, alpha clean-up, edge maps; any time a downstream node wants a firm yes/no, this is the gate. The two knobs that matter most: πŸ“‰ for where the line sits, and 🧬 for whether the line is global or local. Start with ADAPT_NONE and tweak; switch to ADAPT_MEAN when the lighting is uneven and the mask comes out patchy.

A small trap: adaptive thresholding needs a block size that suits your image resolution - too small and it picks up noise, too big and it's basically global again. And TRUNC/TOZERO are not binary at heart; don't expect a hard mask out of them. For the strictly binary result, BINARY is your mode.

This is the current, maintained THRESHOLD node - not one of the pack's legacy ghosts (that would be "πŸ“‰ Threshold (jov)", the older build with extra resize controls). It lives in JOVIMETRIX πŸ”ΊπŸŸ©πŸ”΅/ADJUST. Install is pack-wide: ComfyUI Manager β†’ search "Jovimetrix", or

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

then restart. Dependencies are the shared light set - numpy, opencv-contrib-python (where the actual threshold math lives), Pillow, matplotlib, cozy-comfyui helpers - with no model downloads. Keep ComfyUI at 0.1.3+ with a current frontend.

CategoryJOVIMETRIX πŸ”ΊπŸŸ©πŸ”΅/ADJUST

Inputs (6)

NameTypeDefaultDescription
πŸ‘Ύopt*β€”
🧬optCOMBOADAPT_NONE3 options: ADAPT_NONE, ADAPT_MEAN, ADAPT_GAUSS
βš’οΈoptCOMBOBINARY3 options: BINARY, TRUNC, TOZERO
πŸ“‰optFLOAT0.5000–1β€”
πŸ“optINT33–103β€”
πŸ”³optFLOAT0.000–1β€”

Outputs (2)

NameTypeDescription
πŸ–ΌοΈIMAGEβ€”
😷MASKβ€”