Nodes/was-node-suite-comfyui/Mask Threshold Region
ComfyUI Node Runs on cloud

Mask Threshold Region

Clamp a soft mask into a clean black-and-white one

By WASasquatch·Created 3 years ago·Updated about a year ago· 1,812
Mask Threshold Region

      Got a mushy, gray, gradient-y mask and want it crisp? This node thresholds a mask between a black point and a white point: everything below the black value becomes fully black (excluded), everything above the white value becomes fully white (included), and the in-between gets remapped. The pack's own words: "apply a thresholded image between a black value and white value."

      It's a cleanup node. Segmentation models, depth maps, and luminance-derived masks often come out soft - lots of ambiguous mid-gray around the edges. Sometimes that softness is what you want (feathered blending). Sometimes it's noise, and you want a decisive mask where a pixel is either in or out. Mask Threshold Region gives you that decision.

      Why you'd reach for it

      Masking is only half of inpainting; the quality of the mask decides how clean the result is. A mask with a haze of low gray values will leak the model's changes into areas you meant to protect, or fail to fully commit to areas you meant to edit. Thresholding lets you say "anything dimmer than this is definitely background, anything brighter is definitely foreground," which turns a fuzzy salience map into a usable selection.

      Two thresholds instead of one is the useful bit. A single cutoff is a hard on/off. A black point and a white point lets you crush the noise floor to black while pinning the confident region to white, and control how the middle band maps - cleaner than a blunt binarize when your source mask has a gradient you partly want to keep.

      How it works

      Per pixel: compare the mask value against your black and white thresholds. Below black → 0. Above white → 1. Between → remapped across that range. The output is a mask with the ambiguity squeezed out according to where you set the two points.

      The inputs and outputs that matter

      • the mask - your input MASK (or an image acting as one).
      • black threshold / white threshold - the two dials. Raise the black point to kill more of the faint noise; lower the white point to pull more of the mid-tones into "included." These two settings are the whole node - tune them by eye against a preview.

      The output is a cleaned-up MASK, ready for a Set Latent Noise Mask, an inpaint encode, or further mask ops (dilate, blur, combine).

      Installing it

      Part of WAS Node Suite. ComfyUI Manager: search WAS Node Suite, install, restart. Or:

      cd ComfyUI/custom_nodes
      git clone https://github.com/WASasquatch/was-node-suite-comfyui
      

      install requirements.txt against your ComfyUI Python, restart.

      Common issues

      Edges got harsh and jagged. That's thresholding doing its job - it removes softness. If you still want feathered edges after cleaning up the noise, threshold first, then run the result through a gaussian/blur mask node to re-soften the boundary deliberately. WAS has a Mask Gaussian Region node for exactly that.

      Mask went all black or all white. Your thresholds crossed or are set past the mask's actual value range. If the black point is above the white point, or both are outside the data, you get a flat result. Preview the raw mask's brightness and set the two points inside its real range.

      Node missing after a ComfyUI update. Pack-level. WAS Node Suite is retired and no longer maintained; its dependency pins collide with ComfyUI updates and throw "Import Failed," taking every WAS node down at once. Reinstall the pack's requirements against the correct ComfyUI venv to bring them back.

      This lives in WAS's deep bench of mask utilities - Dominant Region, Dilate, Erode, Smooth, Fill, Combine, and friends. Threshold Region is the one you reach for when the values in a mask are messy, as opposed to its shape. For picking out the largest blob or cropping to a region, that's a different WAS node.

      Categoryx

      Inputs (0)

      No inputs

      Outputs (0)

      No outputs