ComfyUI Node

LatLong Reinsert Projection

Put the retouched view back on the sphere

By cedarconnor·Created about a year ago·Updated about 15 hours ago· 2
LatLong Reinsert Projection
  • panorama
  • edited_patch
  • projection_context
  • IMAGE
feather16

Reinsert is the second half of the pair. You took a flat view out of a panorama with LatLong Extract Projection, you did something to it outside the sphere - upscaled it, inpainted a face, repainted a horizon - and now it has to go back without a visible patch edge.

If you know the crop-and-stitch pattern that took over inpainting workflows in 2026, this is that, wrapped around a sphere. The project that made the pattern standard is valued for one property: it doesn't touch the unmasked part of the image, not even through a VAE round trip. Same idea here - only the projected region gets overwritten, and everything else on the sphere is bit-identical to what you passed in. That's the entire reason to prefer this over "regenerate the whole 360 and hope the seams land."

How it works

It reprojects the flat patch back onto the panorama canvas through the inverse of the extraction, using the yaw, pitch, roll and FOV saved in the context - it does not re-derive the camera from your inputs, which is why the context is a required socket and not three float widgets. The patch is pasted with an alpha layer, and the final pixel is alpha * patch + (1 - alpha) * panorama.

feather (0–512, default 16) softens the boundary, and its units are the useful detail: it's measured in patch source pixels, i.e. feather 16 means a 16-pixel ramp in the flat view's own coordinate space before it's warped onto the sphere. So the same number gives you a much smoother blend near the pole, where a patch pixel covers much less sky, than it does at the equator - the opposite of what people expect. Start at the default, and go up if you still see a ring; you rarely need more than a few dozen.

The extraction/reinsert path does not clip values, so float work survives the round trip.

Inputs

  • panorama - the sphere you're editing into. Same dimensions and alignment as the one you extracted from.
  • edited_patch - your flat result.
  • projection_context - straight from Extract. Don't cache it across graphs; if you re-extract with different framing you must use the fresh one.
  • feather - 0–512, default 16. Zero gives you a hard paste edge, which is occasionally what you want when you've already blended the patch yourself.

One IMAGE output: the panorama with the edit composited in, ready for a viewer, Diagnostics, or an Edge Blender pass.

Batch behaviour

Both ends wrap. Panorama frames iterate normally; the patch index cycles as i % len(patches). So a single edited patch reinserts into every frame of a panorama batch - handy if you're stamping one corrected view across an animated sweep - and a 4-frame patch against an 8-frame panorama applies the same four edits twice.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/cedarconnor/comfyui-LatLong
cd comfyui-LatLong
python -m pip install -r requirements.txt

Manager users, search "ComfyUI LatLong". Needs ComfyUI's Python (3.10+) and the pack's five dependencies - numpy, opencv-python, scipy, torch, Pillow. No models. Restart and it's under LatLong/Outpaint, next to Extract.

Common issues

Three errors, and they're all informative rather than mysterious:

"Edited patch aspect ratio must match the extracted projection" - you cropped, padded or squashed the patch. Equal-proportion upscales are explicitly supported (a 2× patch reinserts fine, which is the whole point of extracting a view in the first place). Changing the aspect is not, and shouldn't be: the camera's FOV no longer describes the image.

"Patch and panorama channel counts must match" - usually an alpha channel from something upstream, or a grayscale pass. 3-channel in, 3-channel out.

"Unsupported projection context version" - you're feeding it a context from a different (older or newer) build. Re-extract with the version you have installed.

If the edit lands visibly in the wrong place, check the panorama dimensions first. The context records where the camera was relative to a specific panorama size; hand it a resized panorama and the projection is geometrically correct but describes a different sphere. And if you want to change angular coverage rather than just re-render an existing view - a genuinely different kind of edit - use the pack's Outpaint Setup/Stitch path instead, where scale is an explicit knob.

CategoryLatLong/Outpaint

Inputs (4)

NameTypeDefaultDescription
panoramaIMAGE
edited_patchIMAGE
projection_contextPROJECTION_CONTEXT
featherINT160–512

Outputs (1)

NameTypeDescription
IMAGEIMAGE