图像分区 · 手涂遮罩画布
The node that turns your auto mask into something you can actually paint on
- source_image
- generated_image
- automatic_mask
- mask_editor_rgba
- red_cyan_visible_preview
- automatic_mask_passthrough
- report_json
Auto masks are great until they're wrong, and in regional editing they're wrong a lot: SAM nails the object but bleeds onto the sleeve, or it misses half the cable you're trying to remove. The Region Edit Toolkit's answer is a two-node hand-correction path - and this is the first half. RegionEditMaskEditorCanvas bakes your automatic mask into a special image that ComfyUI's built-in MaskEditor can open, so you can add to and erase from it with a brush instead of rebuilding the mask from scratch.
Here's the trick, and it's genuinely neat. The node takes three inputs - source_image, generated_image, and automatic_mask - and packs them into one RGBA image. The red channel is the source photo in grayscale and the cyan channel is the generated edit in grayscale, so you see the before/after difference as a red-cyan overlay (that's the red_cyan_visible_preview output, great for eyeballing what actually changed). The alpha channel is 1 - automatic_mask, which is the secret sauce: ComfyUI's MaskEditor is wired so that a PNG's alpha is the mask it hands back to you. Paint where the alpha is low to add to the mask, erase where it's high to trim it.
You don't wire mask_editor_rgba straight into MaskEditor. The intended path, straight from the README:
- Feed
mask_editor_rgbainto an Impact PackPreviewBridge. - Open the PreviewBridge image in ComfyUI's MaskEditor, paint your additions and erasures, save.
- Feed the PreviewBridge
MASKoutput - now your complete edited mask - intoRegionEditMaskEditorApply.
That Impact Pack dependency is the one thing to know before you commit to this path. PreviewBridge is how the editor's result travels back into the graph, and it doesn't exist in core ComfyUI. If you already run Impact Pack for FaceDetailer or the like, no extra cost - if you don't, it's a heavyweight install just for a brush. Also note source_image and generated_image must be the exact same pixel dimensions or the node throws a ValueError; that's deliberate, since a red-cyan diff only means anything when both frames line up.
There's a subtle bug-save built in. Before you've saved anything, PreviewBridge returns a 64x64 empty placeholder, and a naive correction node would read that as "user erased everything." RegionEditMaskEditorCanvas handles it upstream - the sibling RegionEditMaskEditorApply detects that placeholder and keeps your automatic mask instead of treating it as a full wipe. If you were hand-rolling this with core nodes, that's the footgun that would eat an afternoon.
The other outputs are automatic_mask_passthrough (your unedited mask, handy for wiring a second branch) and report_json (the author's standard self-diagnostic dump).
Install: ComfyUI Manager, search Region Edit Toolkit (registry ID native-region-tile-planner-merge), or git clone https://github.com/Liu-Bot24/ComfyUI-Region-Edit-Toolkit.git into custom_nodes, pip-install requirements.txt with the Python ComfyUI actually uses, restart. You only need it installed for this node; remember to grab Impact Pack too if you're following the README's interactive path.
One honest caveat: this pack is new and quiet - there's no community lore to lean on yet, so if the red-cyan overlay looks inverted, trust the math (grayscale source + grayscale generated, diff on the brain) before the UI.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| source_image | IMAGE | — | |
| generated_image | IMAGE | — | |
| automatic_mask | MASK | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| mask_editor_rgba | IMAGE | — |
| red_cyan_visible_preview | IMAGE | — |
| automatic_mask_passthrough | MASK | — |
| report_json | STRING | — |