Nodes/Region Edit Toolkit/图像分区 · 遮罩集合合成
ComfyUI Node

图像分区 · 遮罩集合合成

One node to blend auto mask, brush strokes, and a protection mask into a single target

By Liu-Bot24·Created 2 months ago·Updated about a month ago· 1
图像分区 · 遮罩集合合成
  • image
  • automatic_mask
  • manual_add_mask
  • manual_erase_mask
  • protection_mask
  • final_target_mask
  • confirmed_protection_mask
  • mask_preview
  • report_json
support_threshold0.001

Every regional-edit workflow ends up juggling the same four masks: what a detector found (automatic_mask), what you added by hand (manual_add_mask), what you erased by hand (manual_erase_mask), and what you refuse to let the model touch (protection_mask). RegionEditMaskSetCompose is the node that folds all four into one final_target_mask, and it does it with a formula simple enough to memorize: (automatic ∪ manual add) − (erase ∪ protection).

That subtraction of erasure is the part people underestimate. The node treats your manual erasures as a keep-original instruction, not just a hole in the mask - look at the confirmed_protection_mask output and you'll see it's the union of your protection mask and your erase mask. The idea, straight from the source: if you erased pixels, you're explicitly saying "those stay original," and downstream nodes that build a wide regeneration window need to know that so they don't re-cover them. It's a small semantic choice that saves a whole class of "why did the model repaint the thing I erased" confusion.

The other inputs are the same everywhere in this pack: image (used to build the preview overlay), and support_threshold (default 0.001) which zeroes out noise-level values so you don't edit on dust. After composing, the node raises a clear error if the final mask comes out empty after erase/protection subtraction - which is the correct failure mode, since silently editing nothing would be far more confusing.

Outputs: final_target_mask is the one that feeds your inpainting or Klein conditioning. confirmed_protection_mask is worth wiring out too - it's exactly the set of pixels that must stay untouched, and it plugs straight into the toolkit's various protection-mask slots (RegionEditTileBatchPrepare, RegionEditProtectedDetailHarmonizer, and so on). mask_preview is a red overlay of the target with the confirmed protection shown in blue, so you can sanity-check the composition in one glance instead of squinting at grayscale. report_json logs the pixel counts for each input mask and the final formula - genuinely useful when a mask looks wrong and you want to know which input is lying.

You can also hand-feed it deltas from RegionEditMaskEditorApply's manual_add_mask and manual_erase_mask outputs - that's the clean way to connect the interactive MaskEditor path to this compose step.

Install is the pack-standard: 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 into ComfyUI's actual Python, restart.

The one thing to keep straight: this is the final compose node, so it assumes your automatic, manual, and protection masks are already resolved to full image resolution. If something upstream still has a cropped or downscaled mask, the resize-inside-compose behavior will silently fix dimensions but can shift alignment - feed it same-size masks and the formula does exactly what it says. This pack is young and quiet, so there's no community folklore to lean on; read the report_json when results surprise you.

CategoryRegion Edit Toolkit/Mask

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
automatic_maskMASK
manual_add_maskMASK
manual_erase_maskMASK
protection_maskMASK
support_thresholdFLOAT0.0010–1

Outputs (4)

NameTypeDescription
final_target_maskMASK
confirmed_protection_maskMASK
mask_previewIMAGE
report_jsonSTRING