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

Mask Crop Dominant Region

Crop straight to a mask's biggest blob

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

      Mask Dominant Region finds the largest connected blob in a mask and zeroes out everything else - but it hands you back a full-size mask, same dimensions as the input, just with the noise removed. Mask Crop Dominant Region does the same region-finding, then goes one step further: per the README, it "crops mask to the dominant region with optional padding in pixels." Instead of a full-canvas mask with a blob somewhere in it, you get a tight crop around just that blob, with some breathing room if you ask for it.

      Why crop instead of just cleaning the mask

      This is the detail-pass pattern, applied to mask geometry instead of the image itself: don't carry a full-resolution mask around when only a small piece of it is doing anything. If your subject occupies a 200×200 patch of a 1024×1024 canvas, cropping down to that patch - with the dominant region already isolated - sets you up to do focused work (a targeted fix, a region-specific regeneration, feeding a smaller image into a face-detail step) without the overhead of processing pixels that were always going to be black anyway. Pair it with a matching image crop at the same coordinates and you've got a lightweight version of the crop-fix-paste workflow that WAS's Mask Crop Region node also builds toward.

      How it works

      It finds every separate connected region in the mask, measures their areas, keeps the single largest one - exactly like Mask Dominant Region - but instead of returning a full-size mask with the rest zeroed out, it crops the output down to that region's bounding box. The optional padding adds margin around the crop, which matters: cropping tight against the edge of a blob leaves nothing to feather or blend if you're about to inpaint that region and composite it back.

      The inputs and outputs that matter

      A MASK in, and padding in pixels to control how much margin surrounds the crop. The output is a MASK - cropped to just the dominant region's bounding box plus whatever padding you asked for. As with WAS's inpainting-adjacent mask nodes generally, generous padding is the difference between a clean composite and a visible seam: modidex's own inpainting notes put typical mask feathering in the 4–12 pixel range, with too little producing hard seams and too much bleeding into pixels you didn't mean to touch - the same intuition applies to padding here, just at the crop-boundary level rather than the blur level.

      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. No model download, it's morphology plus a crop.

      Common issues & troubleshooting

      Cropped too tight, ugly seams later. Bump the padding. This is the same failure mode as any tight crop in an inpaint-and-composite chain - no room to blend means the fixed piece butts right up against untouched pixels.

      Wrong region got cropped. Dominant means the largest area, full stop - if your intended subject isn't the biggest blob in the mask, this node will happily crop to whatever is biggest. Clean the mask first (threshold, fill holes) if a stray large region is stealing the crop from your actual target, or reach for Mask Crop Minority Region if what you want really is the smaller blob.

      Whole pack fails to load. WAS Node Suite has been unmaintained since the author marked it retired in December 2023; the recurring issue is the entire suite throwing "Import Failed" after a ComfyUI update from a pinned dependency clash. Reinstall requirements.txt against the correct, embedded Python interpreter and restart.

      Categoryx

      Inputs (0)

      No inputs

      Outputs (0)

      No outputs