EH - Merge Back (V5+Mask)
The merge node the README will try to gaslight you about
- original_image
- edited_crop
- original_crop
- result
- blend_mask
This is the node this pack exists for. Crop a region, regenerate just the crop - a jacket swap, a face touch-up - and EH - Merge Back (V5+Mask) puts the edit back into the original frame without the seam, the color shift, or the skin that comes back looking like a different person's. It's the "stitch" half of the crop-edit-stitch pattern, and it's the reason anyone installs Element_high at all.
Now the part you need to hear before you build anything: the README will try to gaslight you. Its whole pitch is "connect your inpaint mask to the mask input" - and there is no mask input. Not in the schema, not in the shipped code. The name says "Mask" because the node generates a mask for you (an edge-aware blend mask), not because it takes one from you. If you go hunting for a mask socket to wire your hand-painted region into, you'll come up empty and assume you're doing something wrong. You're not.
The two required inputs are original_image (the full, untouched frame) and edited_crop (the region you regenerated). Everything else is optional. How it actually works, in order:
- Position. Feed
original_crop(the untouched crop you made before editing) and it locates that crop inside the original with template matching (OpenCVmatchTemplate, 0.7 confidence). Leave it disconnected and the edited crop is simply centered - fine when the edit is the same size as the frame, wrong when it isn't. This is the input beginners skip, then wonder why the merge landed off-center. - Alignment.
align(on by default, but only does anything whenoriginal_cropis connected) measures the subpixel shift between the original crop and the edited one via phase correlation (cv2.phaseCorrelate) and warps the edit to match. The README calls this "TPS deformation alignment"; the code is a global affine shift. It fixes drift, not pose changes - don't expect it to un-bend someone's arm. - Color.
color_match_mode(defaultmean_shift) shifts each channel's mean toward the original crop's mean, scaled bycolor_match_strength(default 0.5). Deterministic, instant, and the right tool - this is the "make the patch agree with its neighbors" move from the post-processing playbook. One quirk:histogrammode currently runs the same mean-shift code, so don't expect real histogram matching if you select it. - The blend mask. With
blend_modeonedge_aware(default) andedge_awaretoggled on, it builds a feathered mask that blends fully in the middle of the crop and backs off at the borders - and it actively detects skin-toned and edge pixels (an HSV skin range plus Canny edges) and lowers the blend weight there, so the original skin shows through instead of being replaced by the edit's.edge_pixels(default 12) sets the feather width: raise it toward 30 when edges look hard, drop it toward 2-3 for a sharp replacement. - The blend. Five modes.
edge_awareandalphaare direct alpha blends with that mask (alpha skips the skin detection).mixed_cloneandnormal_cloneare OpenCVseamlessClone(Poisson-style, MIXED_CLONE and NORMAL_CLONE).guided_filteralpha-blends then bilateral-filters the seam smooth. When edges still show,mixed_cloneis the one to try first.
Outputs: result (the merged frame) and blend_mask - a MASK of exactly where it blended, which is also your debugging view of "what did this node actually change."
Troubleshooting, the short version: seams → raise edge_pixels or switch to mixed_clone; skin smearing at the boundary → make sure edge_aware is on; merge landing off-center → you forgot to feed original_crop; and if you followed the README's install URL and got a 404, use the heyzne repo below instead of the dead supElement one.
cd ComfyUI/custom_nodes
git clone https://github.com/heyzne/ComfyUI_Element_high
Or search ComfyUI_Element_high in ComfyUI Manager. No models to download, no pip deps beyond ComfyUI defaults - everything is CPU-side OpenCV and numpy.
Honest verdict: for crop-inpaint-merge, the well-trodden road is lquesada's Inpaint CropAndStitch - battle-tested, huge community, and it structurally guarantees unmasked pixels are untouched. This is the lean, unproven alternative: same idea, fewer nodes, alignment and color matching baked in, but a tiny install base, a README that hasn't caught up to its own code, and a name that promises a mask input it doesn't have. Great for experimenting with auto-aligned merges. Don't build a production batch on week-one software.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| original_image | IMAGE | — | |
| edited_crop | IMAGE | — | |
| original_cropopt | IMAGE | — | |
| alignopt | BOOLEAN | true | — |
| edge_pixelsopt | INT | 120–100 | — |
| edge_awareopt | BOOLEAN | true | — |
| color_match_modeopt | COMBO | mean_shift | 3 options: none, mean_shift, histogram |
| color_match_strengthopt | FLOAT | 0.500–1 | — |
| blend_modeopt | COMBO | edge_aware | 5 options: edge_aware, mixed_clone, normal_clone, guided_filter, alpha |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| result | IMAGE | — |
| blend_mask | MASK | — |