Nodes/WAS Node Suite v3/Mask Minority Region
ComfyUI Node Runs on cloud

Mask Minority Region

Keep only the smallest blob in a mask

By WASasquatch·Created 3 years ago·Updated 6 days ago· 1,844
Mask Minority Region
  • masks
  • MASKS
threshold128
drawn_mask
drawn_combineunion

The mirror image of WAS's Mask Dominant Region: where that node keeps only a mask's largest connected blob, this one - per the README - "returns the smallest region in a mask (the smallest area)." Most of the time the smallest blob in a messy mask is exactly the noise you're trying to get rid of, which makes Minority Region a slightly unusual ask on its own. But there's a real use for it: sometimes the small thing genuinely is your target - a stray marker, a small defect flagged by a detection step, a tiny feature that a segmentation pass happened to isolate as its own separate island alongside a much bigger region you don't actually care about.

How it works

It identifies every separate connected region of white pixels in the mask - the same region-finding pass Mask Dominant Region uses - measures each one's area, and keeps only the single smallest, zeroing out everything else including the dominant blob. It doesn't reshape, smooth, or crop the surviving region; it purely removes the competition. If you also want a tight crop around that smallest region instead of a full-size mask with everything else blacked out, WAS's paired Mask Crop Minority Region node does that.

What it takes and gives back

Mask in, mask out. A MASK goes in; a MASK containing just the minority region comes out, ready to drop into whatever was going to consume the original - a targeted fix, a crop node, a compositing step.

Where it's genuinely useful

Isolating a specific small feature that a noisier or looser upstream mask also captured alongside a large, irrelevant region - a defect detector that also lit up the whole background, a color threshold that grabbed both a small object and a big swath of similarly-tinted floor. Rather than trying to hand-paint out the large region, Minority Region just discards it automatically by size.

How to install it

ComfyUI Manager: search "WAS Node Suite," install, restart. Manually:

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

then, from inside that folder, install requirements - path/to/ComfyUI/python_embeded/python.exe -s -m pip install -r requirements.txt on portable, plain pip install -r requirements.txt on system Python - and restart. It's under the WAS Suite menu, no model download involved.

Common issues & troubleshooting

The output is empty or unexpected. Usually the input mask genuinely doesn't have a clean minority region to find - several small fragments of near-identical size, or a mask that's mostly one connected blob with no real second region. Preview the input mask first; it's often telling you something true about the source that isn't obvious at a glance.

It picked a different small region than the one I wanted. "Minority" strictly means smallest area. If your mask has multiple small fragments, whichever is marginally smallest wins the comparison, even if it's not the specific feature you had in mind. Clean the mask first - a threshold pass, Mask Fill Holes - so the region you actually want is unambiguously the smallest.

Whole pack fails to import. This is a simple morphological operation with no dependency of its own, so it's unlikely to break on its own merits. The risk that applies is pack-wide: WAS Node Suite has had no active development since December 2023, and the recurring complaint since is the entire suite failing to import after a ComfyUI update - a shared dependency clash, not anything specific to this node. Reinstall requirements with your embedded Python interpreter, not a system one, if it happens.

CategoryWAS Suite/Image/Masking

Inputs (4)

NameTypeDefaultDescription
masksMASKThe mask to subtract a region from. A batch is handled one mask at a time, each losing its own smallest region.
thresholdINT1280–255Brightness cut-off, on a 0-255 scale, above which a pixel counts as part of a region. 128 splits at mid-grey; lower it to take in faint areas, raise it to keep only near-white ones.
drawn_maskoptSTRINGThe mask painted on the node, written by the interface and saved with the workflow. Empty means nothing was painted, and the node then produces the region mask alone. The node has to have run once before there is a mask to paint on. Clear the field to remove the painting.
drawn_combineoptCOMBOunionHow the painting joins the mask this node produced. union keeps whichever of the two is brighter at each pixel, subtract takes the painting away from the mask, intersect keeps whichever is darker, and off ignores the painting without deleting it. The painting is resized to the mask when the two differ.

Outputs (1)

NameTypeDescription
MASKSMASKEverything except the smallest connected region, as hard black and white with no grey levels left: the smallest region is the one area that comes back unset. Anything painted on the node is joined in.