Nodes/Region Edit Toolkit/图像分区 · 应用手涂遮罩
ComfyUI Node

图像分区 · 应用手涂遮罩

Turn your hand-painted mask edits into a final mask without nuking the auto result

By Liu-Bot24·Created 2 months ago·Updated about a month ago· 1
图像分区 · 应用手涂遮罩
  • difference_image
  • automatic_mask
  • edited_mask
  • processing_support_mask
  • mandatory_core_mask
  • final_mask
  • manual_add_mask
  • manual_erase_mask
  • correction_preview
  • report_json
support_threshold0.001
lock_mandatory_corefalse
apply_manual_editortrue

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 flip lock_mandatory_core on - 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_editor is 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.

CategoryRegion Edit Toolkit/Mask

Inputs (8)

NameTypeDefaultDescription
difference_imageIMAGE
automatic_maskMASK
edited_maskMASK
processing_support_maskMASK
support_thresholdFLOAT0.0010–1
mandatory_core_maskoptMASK
lock_mandatory_coreoptBOOLEANfalse
apply_manual_editoroptBOOLEANtrue

Outputs (5)

NameTypeDescription
final_maskMASK
manual_add_maskMASK
manual_erase_maskMASK
correction_previewIMAGE
report_jsonSTRING