Mask Merge🐰
Paste every processed region back onto the original
- original_image
- processed_images
- masks
- merged_image
Mask Merge is the finish line of ComfyUI-Loop-image's batch pipeline. After CyberEve_MaskSegmentation split your mask into regions and CyberEve_BatchImageLoopOpen/CyberEve_BatchImageLoopClose processed each one separately, you've got a pile of individually-edited region images and their masks. Mask Merge is what stitches them back into one coherent picture - pasting each processed region into its correct spot on the original, and leaving everything outside the masks exactly as it was.
The principle behind it
This is the same rule that shows up all over inpainting workflows: don't let processing touch pixels it wasn't meant to. The community's long-standing habit for that is compositing only the changed region back onto the original image rather than re-decoding the whole frame - precisely so untouched areas don't pick up compression artifacts, color drift, or a VAE round-trip they never needed. Mask Merge does that structurally instead of leaving it to you to remember: it takes the full, original image as ground truth and only overwrites the pixels inside each mask.
That's also why it needs the original full image as input, not a crop - the merge has to know what "untouched" looks like everywhere outside your masked regions, and the original is the only thing that guarantees that.
Inputs and outputs
original_image(required, IMAGE) - the full, unprocessed source image. This supplies everything outside the masked regions.processed_images(optional, IMAGE) - the edited regions, normally wired straight fromCyberEve_BatchImageLoopClose'sresult_imagesoutput.masks(optional, MASK) - the matching masks for those regions, fromCyberEve_BatchImageLoopClose'sresult_masksoutput.
Output: merged_image - the original image with every processed region composited back in at the right spot.
processed_images and masks are optional in the schema, but in practice this node has one job and needs both to do it - leave them unconnected and there's nothing to composite, so you'd just get the original image back out unchanged. In a normal batch pipeline they're always wired from Loop Close.
Installing it
Ships with the rest of ComfyUI-Loop-image. Through ComfyUI Manager, search "ComfyUI-Loop-image" and install. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/WainWong/ComfyUI-Loop-image
Restart ComfyUI. No model weights involved - this is pixel compositing, so it's fast and CPU-side. You'll find it filed under CyberEveLoop🐰.
Common issues
Seams or hard edges at region boundaries. Because this is a straight mask-based paste, not a feathered blend, if your masks from Mask Segmentation have hard edges, the composite will too. If you need soft transitions between processed and untouched pixels, feather your masks before they go into the loop (or after Mask Segmentation, before the loop opens) rather than expecting Mask Merge to soften anything for you.
Getting the original image back unchanged. Almost always means processed_images/masks aren't actually connected, or aren't connected to Loop Close's outputs - double-check the wiring rather than assuming the node is broken.
Regions pasted in the wrong place. Since the masks travel alongside the images through the entire loop, a misplaced region usually means the mask and image got decoupled somewhere upstream - most often a CyberEve_LoopIndexSwitch branch that swapped in a different image without also swapping the matching mask.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| original_image | IMAGE | — | |
| processed_imagesopt | IMAGE | — | |
| masksopt | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| merged_image | IMAGE | — |