图像分区 · 自动/手工/保护遮罩合成
SAM3's auto mask plus your brush, minus the protection
- image
- automatic_mask
- manual_add_mask
- manual_erase_mask
- protection_mask
- final_target_mask
- automatic_mask_resized
- manual_mask_resized
- protection_mask_resized
- overlay
Automatic masks are never quite right. SAM3 nails the object but clips a bit of the spoon next to it, or includes the shadow, or misses the part of the object that blends into the background. RegionEditInteractiveMaskCompose is the node that acknowledges this reality and gives you a clean way to fix it: it combines your automatic mask with manual additions and erasures, then subtracts any protection mask - all in one node, with five explicit blend modes.
It's the mask-compose workhorse of the Region Edit Toolkit, and it's built around ComfyUI's built-in LoadImage → Mask Editor path (the "open mask in editor, paint, save" flow). No Impact Pack required for this one. The README's hand-painting route does offer a fancier version via RegionEditMaskEditorCanvas + PreviewBridge (that's the Impact Pack path), but the plain LoadImage Mask Editor flow feeds this node directly.
How it works
The manual_mode enum is the entire interface, and it's worth reading carefully because the five modes are all you'll ever need:
automatic_plus_add_minus_erase(default) - start with the auto mask, union in yourmanual_add_mask, then subtractmanual_erase_mask. The full toolkit.automatic_plus_manual- auto unioned with manual, no erasing.automatic_only- ignore manual entirely (useful for A/B).manual_only- ignore the auto mask (you want to paint the whole thing yourself).automatic_minus_manual- subtract manual from auto (treat the manual mask as a correction that removes).
Whatever the result, the optional protection_mask is subtracted last and wins, and the whole thing is thresholded at support_threshold (default 0.001 - anything below counts as background noise and gets zeroed).
The image input is used to size everything: all masks are resized to the image's dimensions, which is why the outputs are named automatic_mask_resized, manual_mask_resized, protection_mask_resized. The overlay output is the source image with the final mask shown in red at 52% - look at it before you run anything expensive, because this is the last place you can fix a mistake cheaply.
The one thing beginners miss
manual_add_mask and manual_erase_mask are separate inputs. If you connect your painted mask to manual_add_mask and the auto mask already covers the thing you wanted to erase, nothing gets erased - that's what the erase port is for. Most "why is my fix not sticking" posts in this pack's orbit trace back to this. Also note the masks are resized to the image: feed a mask that's not image-sized and it'll be stretched, not cropped.
Install
ComfyUI Manager → search "Region Edit Toolkit" (package ID native-region-tile-planner-merge) → install → restart. Or git clone https://github.com/Liu-Bot24/ComfyUI-Region-Edit-Toolkit.git into custom_nodes, pip install -r requirements.txt into ComfyUI's Python, restart. Python 3.10+, deps numpy/Pillow/scipy/argostranslate, no models.
Gotchas
If you're using the pack's fancier RegionEditMaskEditorCanvas + PreviewBridge hand-painting route, that path needs ComfyUI Impact Pack installed - the plain LoadImage Mask Editor route doesn't. And if protection wipes out the entire target, downstream nodes in this pack throw hard errors rather than silently editing nothing - that's the pack's strictness, and it's better than discovering the "edit" was a no-op after a 5-minute render.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| automatic_mask | MASK | — | |
| manual_add_mask | MASK | — | |
| manual_mode | COMBO | automatic_plus_add_minus_erase | 5 options: automatic_plus_add_minus_erase, automatic_plus_manual, automatic_only, manual_only, automatic_minus_manual |
| support_threshold | FLOAT | 0.0010–1 | — |
| manual_erase_maskopt | MASK | — | |
| protection_maskopt | MASK | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| final_target_mask | MASK | — |
| automatic_mask_resized | MASK | — |
| manual_mask_resized | MASK | — |
| protection_mask_resized | MASK | — |
| overlay | IMAGE | — |