图像分区 · 应用手涂遮罩
Turn your hand-painted mask edits into a final mask without nuking the auto result
- difference_image
- automatic_mask
- edited_mask
- processing_support_mask
- mandatory_core_mask
- final_mask
- manual_add_mask
- manual_erase_mask
- correction_preview
- report_json
This is the second half of the Region Edit Toolkit's hand-correction path, and it's where your painted edits actually become the mask your pipeline runs on. RegionEditMaskEditorCanvas makes the canvas you paint on; RegionEditMaskEditorApply takes what MaskEditor saved, reconciles it against your automatic mask, and hands back a final_mask you can trust not to silently destroy the work SAM did.
The inputs tell the story: difference_image, automatic_mask, edited_mask, and processing_support_mask, plus a support_threshold (default 0.001, which just sweeps out noise-level pixels). The edited_mask comes from the PreviewBridge MASK output we described on the Canvas page. What this node adds over a naive "just use the edited mask" approach:
- Placeholder detection. Before you've ever saved in MaskEditor, PreviewBridge returns a 64x64 empty placeholder. This node recognizes that placeholder and keeps the automatic mask, instead of interpreting "no edit yet" as "erase everything." Without this guard, an accidental rerun wipes your mask every time.
- Support clipping. Whatever survives is clipped to the
processing_support_mask, so hand-painted blobs that wander outside the region you actually want to edit get cut off. - A mandatory core lock. This is the interesting one. Feed a
mandatory_core_mask(say, the face in a face-edit workflow) and fliplock_mandatory_coreon - the node then restores that core into the final mask even if you erased it with the brush. The tooltip on the widget says it plainly: "keep mandatory core" versus "allow complete erase." It's your insurance against brushing away something you can't afford to lose. apply_manual_editoris a compatibility switch (default on): set it off and the node ignores the edited mask and just passes the automatic one through. Useful for A/B-ing.
The outputs are the reward. final_mask is the one to wire forward. manual_add_mask and manual_erase_mask are the extracted deltas of your brush strokes - where you added coverage and where you took it away - which is genuinely handy for later steps like RegionEditMaskSetCompose that combine add/erase/protection masks separately. correction_preview is an image you can look at to confirm the edit landed where you think it did, and report_json is the pack's usual self-diagnostic dump.
Where people get burned: this path is built around Impact Pack's PreviewBridge, so you need the Impact Pack installed (search "Impact Pack" in ComfyUI Manager). And keep the processing_support_mask honest - if it's smaller than your automatic mask, pixels the auto mask wanted will get dropped at the support threshold, and the only symptom is a mysteriously shrunken final mask. The report_json output exists precisely so you can check the support-pixel counts before scratching your head.
Install (same story as every node in this pack): ComfyUI Manager → search Region Edit Toolkit (native-region-tile-planner-merge), or git clone https://github.com/Liu-Bot24/ComfyUI-Region-Edit-Toolkit.git into custom_nodes, then pip-install requirements.txt into ComfyUI's real Python and restart. Grab Impact Pack too if it's not already there. Like the whole pack, this is new enough that you won't find much community troubleshooting yet - but the failure modes here are all visible in that report_json, so read it before you start rerolling masks.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| difference_image | IMAGE | — | |
| automatic_mask | MASK | — | |
| edited_mask | MASK | — | |
| processing_support_mask | MASK | — | |
| support_threshold | FLOAT | 0.0010–1 | — |
| mandatory_core_maskopt | MASK | — | |
| lock_mandatory_coreopt | BOOLEAN | false | — |
| apply_manual_editoropt | BOOLEAN | true | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| final_mask | MASK | — |
| manual_add_mask | MASK | — |
| manual_erase_mask | MASK | — |
| correction_preview | IMAGE | — |
| report_json | STRING | — |