Mpi Wrap Cut Merge
Splice two renders of the 360 wrap without the doubled ghost line
- image
- reference
- IMAGE
This is the interesting one of the four 360 wrap nodes, and the one worth understanding properly.
After MpiWrapPad and a refine or upscale pass, you have the same strip of pano rendered twice: once as the right-side pad, where the model drew those columns as the continuation past column W−1, and once in place at the left edge, where it drew them as the start of the image. Same content. Two renders. They do not agree pixel for pixel - no model produces identical output for the same region in two different contexts.
The obvious move is a cross-fade across the overlap. And that's the move that produces the artifact: a cross-fade of two images that are the same subject offset by a few pixels shows you that subject twice, as a pale doubled outline. The pack's bench found AnimeSharp then sharpens exactly that into a visible ghost line.
So this node doesn't fade. It cuts.
How it works
Take the overlap O (the pad, scaled to the image's current resolution). R is the right-pad render, C is the same columns rendered in place.
Tone first. The low-pass (σ=32) difference between R and C is a smooth field, and it's ramped out across the overlap so the two agree on overall brightness. A big sigma deliberately: at that scale, the small line offsets between the two renders cancel and what's left is real exposure drift.
Then detail. Each row runs a min-cost path top to bottom through the dilated absolute difference |R−C| - the classic seam-carving dynamic program - with a margin of O/8 at each end forced expensive so the cut has to start and finish inside the overlap. Left of the path you take R, right of it you take C. Then a 2px feather across the cut, so the join isn't a visible hard edge either.
The result: no fade band, no doubled line, and no global loss of sharpness. Because the cut wanders to where the two renders already agree, it hides in the structure rather than crossing a subject.
Inputs and outputs
- image - a wrap-padded image, refined or upscaled since.
- reference - the image as it was before
Mpi Wrap Pad. The pad gets scaled against this width. - pad - the pad you used, default 128, minimum 8.
One output: IMAGE.
Note the default is 128, four times MpiWrapCrop's 32, and the minimum is 8 rather than 0. That's not arbitrary: the cut needs room to move, and the excluded margin is proportional to the overlap. A thin overlap gives you a cut with nowhere to hide.
Installing it
cd ComfyUI/custom_nodes
git clone https://github.com/MadPonyInteractive/ComfyUi-MpiNodes
# restart ComfyUI
No weights. It does use scipy.ndimage (Gaussian and 1-D maximum filters) on top of numpy, and it runs per frame, so a video-length pano pass costs accordingly - this is a per-frame DP solve, not a vectorised one-liner. The pack ships no requirements.txt; scipy comes from the ComfyUI environment, and its import is at module level, so the pack won't load without it.
When to use it (and when not to)
Use it when the model rendered the strip twice and the two renders disagree. Do not use it as a fancy crop: if the padding worked and the image is internally consistent, MpiWrapCrop is exact, instant, and doesn't touch a single pixel of your picture. CutMerge is what you do when a crop would show you the join.
Also worth saying: this replaces the gradient-mask cross-fade that most graphs improvise out of Image Composite Masked plus a blurred mask. Same intent, better outcome, because a fade between two disagreeing renders is the artifact, not the fix.
Where people get burned
The reference has to be the true pre-pad image. The overlap is scaled by comparing widths; a wrong reference gives you the wrong overlap and a cut in the wrong place - visible as a hard vertical line rather than a hidden one.
A pad you set too small for this node (say 32 because that's what you used for padding) leaves an 8-pixel-ish margin and a cut that has almost no freedom. Either pad wider from the start - 128 is the number the author landed on - or accept the crop.
It doesn't blend content that genuinely differs. If the refiner invented a window in one render and left wall in the other, the cut will still choose one side, and you'll see the seam's content change across it. That's a real difference in the picture, not a grading problem, and no merge fixes it. Pad wider so the model has no excuse to diverge.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | A wrap-padded image, refined or upscaled since. | |
| reference | IMAGE | The image as it was BEFORE Mpi Wrap Pad. | |
| pad | INT | 1288–2048 | Mpi Wrap Pad's pad. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |