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

Mask Crop Minority Region

Crop straight to a mask's smallest blob

By WASasquatch·Created 4 years ago·Updated 7 days ago· 1,846
Mask Crop Minority Region
  • masks
  • MASKS
padding24

The mirror of Mask Crop Dominant Region: where that node crops to a mask's largest blob, this one - per the README - "crops mask to the minority region with optional padding in pixels," meaning it targets the smallest connected region instead. Most of the time the smallest blob in a mask is noise you're trying to get rid of. This node is for the less common but real case where the small thing is exactly what you want - a stray marker, a small defect, a specific tiny feature that a segmentation pass happened to isolate as its own little island alongside a much bigger region you don't care about.

Why you'd want the smallest blob, cropped

If your target is small relative to the image, carrying a full-canvas mask around wastes effort - same logic as the dominant-region crop, just pointed at the opposite end of the size distribution. Crop straight to the small region's bounding box, with padding so you're not cutting right against its edge, and you've got a tight, workable piece to feed a targeted fix, a close-up regeneration, or a matching image crop at the same coordinates.

How it works

It finds every separate connected region in the mask, measures each one's area, and - instead of keeping the largest like its Dominant sibling - keeps the single smallest one and crops the output down to that region's bounding box. The optional padding sets margin around the crop; without it, you're cropping right up against the tiny blob's edge, which leaves nothing to feather if you're planning to composite the result back in later.

The inputs and outputs that matter

A MASK in, plus padding in pixels for margin around the crop. The output is a MASK cropped tightly to the minority region's bounding box, expanded by whatever padding you set. The same inpainting hygiene applies here as anywhere else in WAS's crop family: modidex's inpainting notes put typical mask feathering around 4–12 pixels, with too little causing a visible hard seam and too much bleeding past the intended edit - treat padding here with the same care.

Installing it

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

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

install requirements.txt against your ComfyUI Python, restart. Pure morphology and cropping - no model to download.

Common issues & troubleshooting

It grabbed a different tiny region than the one I meant. "Minority" means smallest area, and if your mask has several small, similarly-sized fragments, whichever one is marginally smallest wins - which may not be the specific feature you intended. Clean the mask first so the region you actually want is unambiguously the smallest, or isolate it another way before feeding this node.

The crop is basically empty or a single pixel. If the minority region really is tiny noise rather than a real feature, cropping to it produces exactly that - a near-nothing crop. That's usually a sign the mask needs cleanup upstream (a threshold pass, Mask Fill Holes), not that this node is misbehaving.

Whole pack fails to import. WAS Node Suite has been unmaintained since the author marked it retired in December 2023; the recurring failure is the entire suite throwing "Import Failed" after a ComfyUI update because a shared pinned dependency clashes with the new version. Reinstall requirements.txt against the correct, embedded Python interpreter and restart.

CategoryWAS Suite/Image/Masking

Inputs (2)

NameTypeDefaultDescription
masksMASKThe mask to crop. Its smallest connected white area decides where the crop is taken, which on a noisy mask can be a single speck; a batch is cropped one mask at a time.
paddingINT240–4096Margin left around the region, in pixels on each side. 0 crops tight to the region, 24 leaves a 24-pixel border all round and so widens the square output by 48 pixels.

Outputs (1)

NameTypeDescription
MASKSMASKThe cropped region on a square canvas. Its side is the longer edge of the crop plus twice padding, so it is normally not the size of the input. One batch carries one size, so where the masks of a batch crop to different sizes each is centred on the size of the largest.