Mask_splitMask
Picking out one region from a multi-blob mask
- mask
- masks
Run a detector or segmentation model on an image with several people or objects in it, and you often get one mask back with several separate, disconnected blobs in it - not what you want if your next step only cares about one of them. Mask_splitMask picks a single connected region out of a multi-blob mask by index.
What it does
Worth flagging up front, same as this pack's Mask_math: cardenluo's ComfyUI-Apt_Preset files this node under mask/backup rather than the main mask category, which suggests the author considers it an older or superseded approach kept around for compatibility rather than the current recommended tool. It still does a genuinely useful job, though - if your input mask has multiple disconnected regions (say, three detected faces), this node splits them into individual connected components and lets you pull out just one via index.
ignore_threshold sets a minimum size (in pixels, 0â2048) below which a region is discarded entirely before indexing - this filters out noise: small stray specks in a mask that shouldn't count as a "real" region and would otherwise throw off which index corresponds to which actual blob. index then picks which surviving region to output, 0 through 99, most likely ordered by size or position (test this against your own mask to see which - the schema doesn't specify the ordering rule).
Inputs and outputs
mask- the input mask, potentially containing multiple disconnected regions (required).ignore_threshold- minimum region size to keep, in pixels (0â2048, default 0 - meaning nothing is filtered by default).index- which surviving region to output (0â99, default 0).
Single masks output - despite the plural name, this is one selected region per run, not the full split set.
If you need every region rather than just one, you'll likely need to loop this node across increasing index values (0, 1, 2, ...) until you run out of regions, since it returns one selection per call rather than a batch of all regions at once.
Where this fits
Use this after any detector or segmentation step that can return multiple disconnected regions in a single mask, when your downstream step (an inpaint, a crop, a per-object edit) needs to work on exactly one region at a time rather than all of them merged together. Pair ignore_threshold with a real image first to figure out a sensible cutoff for your specific use case - the right value depends entirely on your image resolution and how big the objects you care about actually are.
Installing it
Through ComfyUI Manager: search ComfyUI-Apt_Preset. Manual install:
cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git
Run install.bat (Windows) or install requirements.txt yourself, restart ComfyUI. No external models needed - this is mask/region processing only.
Troubleshooting
If the node's missing, check for a pack-wide import failure first - ComfyUI-Apt_Preset is large and there's a documented IMPORT FAILED report from at least one user; check the ComfyUI console at startup for the actual missing-dependency error.
For this node: if index returns an empty or unexpected mask, you've likely run past the number of regions your mask actually has after ignore_threshold filtering - a mask with two real blobs and ignore_threshold set high enough to drop a third small one only has indices 0 and 1 to give you. And since this node lives in the pack's backup folder, if you can't find it searching just "mask" in the node browser, check the full category tree rather than assuming it's not installed.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | â | |
| ignore_threshold | INT | 00â2048 | â |
| index | INT | 00â99 | â |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| masks | MASK | â |