Nodes/comfy_Pond_Nodes/🐳遮罩图像拼接
ComfyUI Node

🐳遮罩图像拼接

Paste a subject into a spot you point at with a mask

By Pondowner857·Created about a year ago·Updated 21 days ago· 45
🐳遮罩图像拼接
  • background_image
  • subject_image
  • subject_mask
  • position_mask
  • 拼接图像
  • 最终遮罩
alignment
scale_factor1.00

Most compositing in ComfyUI is "paste at a fixed coordinate" - you hand a node an x/y and it stamps. 🐳遮罩图像拼接 (AdvancedMaskImageComposite) does it the smarter way: you give it a position mask whose white area marks where the subject should land, and it figures out placement, scaling, and blending from that. If the target spot moves between frames, you don't re-derive coordinates - you just move the mask, and it follows. That makes it the paste-back stage in a lot of mask-driven workflows.

The mechanism is refreshingly transparent. It takes four visual inputs: background_image (the base layer), subject_image (what you're inserting), subject_mask (the cutout for the subject), and position_mask (white region = target zone, per the tooltips). Inside, it runs a small pipeline: validate that image and mask dimensions match (and smart-resize anything that doesn't), extract the subject with its mask, find the bounding box of the position mask's white region, scale the subject to fit that region, then blend with the mask so the seam is feathered. If the position mask has no white pixels at all, it gracefully returns the background unchanged - no crash, which is more than some nodes manage.

The inputs that matter

  • position_mask - this is the star. A white blob anywhere in the frame defines the target. Draw it with a mask editor node, or get it from a detector and you've got automatic compositing.
  • alignment - where inside the target region the subject sits: 中 (center), 上/下/左/右. "Center" is the default and usually right.
  • scale_factor - 0.1 to 2.0, default 1.0. Controls subject size relative to the target region. Crank to 1.2 when you want the subject to overflow the spot a bit.

Outputs

Two: 拼接图像 (the composite IMAGE) and 最终遮罩 (the scaled, positioned subject mask). That second output is the sleeper useful one - you can feed it into an inpaint pass or a detailer so whatever happens next only touches the placed subject. This is the same detect → crop → re-render → paste-back loop that the detailing docs describe; this node is a solid paste-back for it.

Installing and using it

From the comfy_Pond_Nodes pack (Manager search "comfy_Pond_Nodes"):

cd ComfyUI/custom_nodes
git clone https://github.com/Pondowner857/comfy_Pond_Nodes
cd comfy_Pond_Nodes && pip install -r requirements.txt

It imports OpenCV (cv2) for the resize and blend work, so that's a hard dependency. It's the only mask-composite node in the pack that does positioned compositing - the sibling mask nodes here are boolean/merge operations, not placement.

Where people get burned: feeding it a subject whose mask is noisy. A ragged mask means a ragged seam. Run your mask through AutoMaskSolidifier (same pack) or a mask feather first. And remember this is a deterministic paste - it won't light-match the subject to the background. That's the job of a color-match node after, not this one.

Category🐳Pond/mask

Inputs (6)

NameTypeDefaultDescription
background_imageIMAGE背景图像 - 作为底层的图像
subject_imageIMAGE主体图像 - 要拼接的图像
subject_maskMASK主体遮罩 - 用于抠取主体的遮罩
position_maskMASK位置遮罩 - 白色区域表示拼接位置
alignmentCOMBO对齐方式 - 在目标区域内的对齐位置
scale_factorFLOAT1.000.1–2缩放因子 - 控制主体相对于目标区域的大小

Outputs (2)

NameTypeDescription
拼接图像IMAGE
最终遮罩MASK