Nodes/ComfyUI-YarvixPA/πŸš€ Unstitch Images and Mask
ComfyUI Node

πŸš€ Unstitch Images and Mask

Unstitch the composite and its mask in one step

By YarvixPAΒ·Created about a year agoΒ·Updated 6 months agoΒ· 15
πŸš€ Unstitch Images and Mask
  • unstitch
  • image
  • mask
  • IMAGE
  • MASK
β—„selection1β–Ί

The mask companion to UnstitchImages. Where that node gives you one edited half back, this one gives you the edited half and its mask in the same slice - which is exactly what you want when your next step is compositing the result back over the original. If you stitched with StitchImagesAndMask, this is how you take it apart again.

It's the final leg of the pack's FaceSwap-style workflow: stitch image+mask, edit the composite, unstitch with this node, then paste the edited slice over the source using the mask that comes back with it. Because both image and mask are sliced with identical coordinates, the alpha boundary lines up with the pixels - no re-alignment, no guessing.

How it works

Same slice math as UnstitchImages, but applied to two tensors at once. It reads the UNSTITCH metadata (direction, original shapes, spacing), computes where image 1 ends and image 2 begins in the composite, and cuts both the image and mask inputs along that seam. The selection input ("1" or "2") picks which half you get back; both the image and the mask come from the same half, so they stay in sync.

Inputs: unstitch (metadata from a StitchImagesAndMask), image (edited composite), mask (edited composite mask), and selection. Outputs: IMAGE and MASK.

Install

ComfyUI Manager (search "YarvixPA") or

cd ComfyUI/custom_nodes
git clone https://github.com/YarvixPA/ComfyUI-YarvixPA

restart. Under ComfyUI-YarvixPA/Image/Stitch.

The pattern, end to end

  1. StitchImagesAndMask joins your two images and masks, and remembers the geometry.
  2. Edit the composite (inpaint the seam, swap the face, whatever).
  3. UnstitchImagesAndMask slices the edited half and its mask back out.
  4. Composite the edited slice over the original with the mask.

The mask coming out of this node is the compositing key - it marks precisely the region that was part of the edited half, so your paste doesn't leave a hard seam. Same caveat as the rest of the family: the metadata is pack-specific and the node trusts it blindly, so keep the unstitch wire intact and only feed it composites produced by this pack's stitch nodes.

CategoryComfyUI-YarvixPA/Image/Stitch

Inputs (4)

NameTypeDefaultDescription
unstitchUNSTITCHβ€”
imageIMAGEβ€”
maskMASKβ€”
selectionCOMBO1Choose which slice to output: 1=first, 2=second

Outputs (2)

NameTypeDescription
IMAGEIMAGEβ€”
MASKMASKβ€”