Nodes/ComfyUI-FisheyeTransform/🐟 Fisheye Redistort
ComfyUI Node

🐟 Fisheye Redistort

The node that un-curves your inpaint result

By QuackPhucΒ·Created 8 months agoΒ·Updated 8 months agoΒ· 0
🐟 Fisheye Redistort
  • image
  • params
  • mask
  • image
  • mask

If you found this node first, back up. Fisheye Redistort is the "put it back" half of a two-node dance, and on its own it does nothing useful. Its sibling, Fisheye Undistort, flattens a fisheye photo into a rectilinear image so an inpainting model doesn't paint straight-line perspective onto a curved lens. Redistort re-curves the result afterward so the final image still looks like it came out of that dashcam or Korean street cam - barrel distortion and all.

The reason this matters: diffusion models are trained overwhelmingly on flat, rectilinear photos, so when you ask one to inpaint a region inside a heavily curved frame, it happily draws in a perspective that contradicts the lens. The undistort-then-redistort pattern sidesteps that entirely. You do the generation in a world the model understands, then put the lens back. This is the node that puts it back.

How it works

Redistort takes the FISHEYE_PARAMS that Fisheye Undistort saved (its strength and zoom values) and rebuilds the distortion the other node removed. Under the hood it's a geometric remap, no ML anywhere: for each pixel it computes the distance from the image center, reapplies the barrel term r * (1 + kΒ·rΒ²) with k = strength * 0.3, and resamples the image with cv2.remap using Lanczos interpolation. Same math as Undistort, just sign-flipped - undistort removes barrel, redistort adds it back.

One caveat worth knowing: the params object carries the original image shape, but Redistort regenerates its maps at the current size of whatever image you feed it. If your inpainted result comes back at a different resolution than the flattened input, you won't get a pixel-perfect geometric round-trip. Close enough for almost everyone, annoying if you're pixel-peeping.

Inputs and outputs

  • image (IMAGE, required) - your flat, inpainted result.
  • params (FISHEYE_PARAMS, required) - straight from the matching Fisheye Undistort output. Not optional, and it's the entire reason the round-trip works.
  • mask (MASK, optional) - warps a mask along with the image, mirroring the Undistort side, so your inpaint region stays aligned with the final frame.

Outputs: image (IMAGE) and mask (MASK). Wire the image into your save or upscale node; the mask only matters if you've been tracking one through the whole chain.

The workflow

fisheye image β†’ Fisheye Undistort β†’ inpaint (masked region)
                                      ↓
fisheye result ← Fisheye Redistort ← inpainted flat image + params

That diagonal params line is the part beginners miss. It's saved state, so Undistort and Redistort have to stay in one matched chain. Change strength on the Undistort after the fact and the distortion won't line up anymore.

Install and troubleshooting

Same pack as Fisheye Undistort - if you have one, you have the other. In ComfyUI Manager, search ComfyUI-FisheyeTransform, hit install, restart ComfyUI. Or the manual route:

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

Then restart. No models to download and no extra dependencies - it only uses numpy, torch and OpenCV, all of which ship with ComfyUI already.

If the final image looks off, check the params wiring first; that's the failure mode nine times out of ten. If the edges look pinched or stretched, your Undistort and Redistort strengths don't match - go back to the Undistort node and read its value. If nothing happens at all, the params input is empty or wired to the wrong node, because this node is a state machine: no params, no distortion, no output worth keeping.

Categoryimage/transform

Inputs (3)

NameTypeDefaultDescription
imageIMAGEβ€”
paramsFISHEYE_PARAMSβ€”
maskoptMASKβ€”

Outputs (2)

NameTypeDescription
imageIMAGEβ€”
maskMASKβ€”