Mask to SEGS
Turn an authored mask into regions Impact Pack and SimpleSyrup can both detail
- image
- mask
- segs
- mask
SEGS is Impact Pack's way of describing a detected region: a crop, a mask, some metadata, all bundled into one value that detailers know how to consume. The problem is that every SEGS workflow seems to start with a detector - you detect faces, or hands, or "everything matching this text." But sometimes you don't want a detector at all. You already made a mask by hand, or in an image editor, and you just want the detailer machinery to work on it. SimpleSyrup.MaskToSEGS is the bridge: mask in, SEGS out, no detector involved.
That's genuinely useful because it makes the whole detect-crop-refine stack address anything you can paint. Hand-painted a mask over a costume detail you want refined? Convert it to SEGS and run the same detailing pass you'd use for a face. The pack is explicitly built so regions move between detectors, masks, and detailers without being re-created, and this node is the "existing mask enters the ecosystem" door.
Mechanically, it's straightforward and the source is honest about it: the mask is thresholded (pixels at or above mask_threshold, default 0.5, count as active), grown or shrunk by mask_dilation if you want, then split into connected regions. Regions smaller than size_threshold (default 10px wide or tall) are discarded. Each survivor gets a crop of surrounding context (crop_factor, default 3 - higher means bigger crops) and the cropped mask can be dilated again with post_dilation to give a detailer room to work. Then the regions are ordered and emitted as SEGS.
The inputs worth actually touching:
mask_threshold- what counts as "on." 0.5 is fine for clean binary masks; lower it if your mask is soft and you want more in.size_threshold/keep_only- the noise filters.size_thresholdkills tiny specks;keep_only(0 = keep all) keeps only the N largest regions, which is your answer when a mask with 40 dust specks becomes 40 SEGS.crop_factor- context around each region. This is the "how much of the surrounding image does the detailer see" knob.combine_segs- if you want one unioned SEG instead of separate regions, flip this. Useful when you're treating the whole mask as a single detail target.
Outputs: segs (the regions, image-associated) and mask - the union of everything that survived, back out as a standard ComfyUI mask. The second output is handy if you want to sanity-check what actually made it through the filtering, or feed it onward as a normal mask.
Install: the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/Artificial-Sweetener/SimpleSyrup
cd SimpleSyrup && pip install -r requirements.txt
or ComfyUI Manager → search SimpleSyrup → Install → restart, with a current ComfyUI (v3 extension API). No extra models. If your SEGS come out empty when the mask clearly has stuff in it, check mask_threshold against how soft your mask is - a feathered mask under a hard 0.5 threshold shrinks a lot - and remember size_threshold is in pixels of the mask bounds.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Source image used to create cropped image data for each SEG. | |
| mask | MASK | Mask whose active regions become SEGS. | |
| mask_threshold | FLOAT | 0.500–1 | Mask value required for a pixel to count as active. |
| size_threshold | INT | 101–8192 | Discard regions smaller than this many pixels wide or tall. |
| keep_only | INT | 00–4096 | Keep only this many largest regions. Use 0 to keep all. |
| mask_dilation | INT | 0-512–512 | Grow or shrink the source mask in pixels before regions are found. |
| post_dilation | INT | 0-512–512 | Grow or shrink each final cropped SEG mask in pixels after cropping. |
| crop_factor | FLOAT | 3.00–100 | Context around each region. Use 0 for the full image; higher values make larger crops. |
| sort_order | COMBO | largest to smallest | Order separate SEGS before output and combining. |
| combine_segs | BOOLEAN | false | Return one unioned SEG instead of separate mask regions. |
| label | STRING | mask | Label stored on each extracted SEG. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| segs | SEGS | Image-associated SEGS created from the mask. |
| mask | MASK | Union of retained SEGS as a standard ComfyUI mask. |