Nodes/Comfyui_PDuse/PD Mask Split to List
ComfyUI Node

PD Mask Split to List

Split a sticker sheet or meme grid into individual images

By 7BEII·Created 2 years ago·Updated 15 days ago· 53
PD Mask Split to List
  • image
  • mask
  • images
  • masks
min_area10
row_tolerance50
split_iterations0
bbox_padding8

You've got a 2x3 meme sheet or a sticker collage - one image, six or twelve distinct objects - and you want each object as its own image, in reading order, with a clean mask per object. Hand-cropping that is miserable. PD_Maskfenkai ("PD Mask Split to List") does it automatically: it finds each object from the mask, splits the sheet into per-object crops, and returns an image list and a matching mask list, ordered top-to-bottom then left-to-right. It's the closest thing in this pack to an Impact-Pack-style region splitter, minus the AI detection - it works purely off geometry and a mask.

How it works

Connected components, basically. It takes the first frame of your image/mask pair, binarizes the mask, and uses OpenCV's connectedComponentsWithStats to find every separate blob. Each blob above min_area becomes a crop, expanded by bbox_padding so you don't decapitate a sticker's ears. Then it does the clever part: blobs are grouped into rows using row_tolerance (two blobs whose vertical centers are within tolerance share a row), rows are sorted top-to-bottom, and within each row blobs sort left-to-right. That's what gives you stable reading order for a multi-row sheet.

split_iterations handles the sticky case: if stickers touch, it erodes the mask a few times first to separate them, then dilates the seeds back within the original shape so the final mask stays precise. The output images/masks are lists, so each crop drops into a list-aware node - feed them into per-sticker processing, upscaling, or a second pass.

The inputs that matter

  • image + mask - both required. The mask is what drives the split.
  • min_area - ignore blobs smaller than this (default 10). Kill specks.
  • row_tolerance - how close two blobs must be to count as the same row (default 50).
  • split_iterations - erosion passes to separate touching stickers (default 0). Start at 0; bump to 1–3 if stickers are fusing.
  • bbox_padding - pixels of breathing room around each crop (default 8). More padding = less risk of clipping an edge.

The critical gotcha: the mask is inverted

The author's README says it plainly: this node treats black as foreground and white as background - the opposite of ComfyUI's usual white-on-black mask convention. If you load a normal ComfyUI mask and get nothing split out, that's why. The author's recommended starting points for a 2x3 meme sheet: split_iterations=0, bbox_padding=8–16, min_area=10; if stickers are fused, raise split_iterations.

Installing

ComfyUI Manager, search Comfyui_PDuse; or:

cd ComfyUI/custom_nodes
git clone https://github.com/7BEII/Comfyui_PDuse
cd Comfyui_PDuse
pip install -r requirements.txt

Restart. Needs opencv-python and numpy, both already in the pack's requirements (and in ComfyUI).

Gotchas

Only the first frame of a batch is split - feed it a single image, not a batch. The inverted-mask convention will bite you first, so test with a quick preview of what the node thinks is foreground. And row_tolerance tuning is the fiddly part: too small and one row splits into two, too large and two rows merge. If the output order looks wrong, that's the dial to touch - not the others.

CategoryCustom/PD

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
maskMASK
min_areaINT101–999999
row_toleranceINT501–2048
split_iterationsINT00–20
bbox_paddingINT80–512

Outputs (2)

NameTypeDescription
imagesIMAGE
masksMASK