Nodes/ComfyUI-FisheyeTransform/🐟 Fisheye Undistort
ComfyUI Node

🐟 Fisheye Undistort

Inpaint a fisheye photo without the AI drawing a flat world on a curved lens

By QuackPhucΒ·Created 8 months agoΒ·Updated 8 months agoΒ· 0
🐟 Fisheye Undistort
  • image
  • mask
  • image
  • mask
  • params
β—„strength1.00β–Ί
β—„zoom1.00β–Ί

You've got a dashcam clip, a GoPro frame, or a Korean street-cam still with that familiar barrel bulge, and you want to inpaint something in it - a person, a sign, a car. So you mask it, run your inpaint, and the model fills in a scene with perfectly straight, rectilinear perspective. It sticks out instantly, because diffusion models are trained overwhelmingly on flat photos and have no idea the rest of your frame is curved. The fix isn't a smarter model; it's a dumber pre-step: flatten the image first, do the inpainting in a world the model understands, then bend it back.

That's the whole point of Fisheye Undistort, the lead node in the QuackPhuc/ComfyUI-FisheyeTransform pack. It converts a fisheye image into a rectilinear one before you inpaint, and its sibling Fisheye Redistort restores the distortion after. Use the pair together and the inpainted object keeps the same lens geometry as everything around it, instead of looking photoshopped onto a screenshot.

How it works

Pure geometry, no ML. The node builds a radial remap: for every pixel it measures the distance from the image center, applies the inverse barrel term r * (1 + kΒ·rΒ²) with k = -strength * 0.3, and resamples the pixels with cv2.remap using Lanczos interpolation. Negative k pushes the barrel bulge outward - that's the "undistort." It runs per-frame on batched tensors, so a whole clip works in one pass.

The inputs that matter

  • strength (FLOAT, 0.0–3.0, default 1.0) - how much distortion to remove. Start at 1.0 and nudge until straight lines are straight. Korean street cams typically sit around 0.8–1.2; heavy GoPro fisheye can want more.
  • zoom (FLOAT, 0.5–2.0, default 1.0) - output zoom. This is the one that fixes the classic side effect: undistorting stretches the edges and can show black corners or stretched detail, so you zoom in to crop past the bad zone. If the edges look wonky, raise this.
  • image (IMAGE) and optional mask (MASK) - if you pass a mask, it gets warped with the same transform, so your inpaint region stays glued to the scene through the whole round-trip. Worth doing for anything precise.

Outputs: image (IMAGE), mask (MASK), and - the important one - params (FISHEYE_PARAMS), a small bundle carrying the strength, zoom and shape you used. Wire it into Fisheye Redistort later; without it, the round-trip can't be reversed.

The workflow

fisheye image β†’ Fisheye Undistort β†’ inpaint β†’ Fisheye Redistort ← params

Undistort first, inpaint the flattened frame, then Redistort with the saved params to put the curve back.

Install and troubleshooting

ComfyUI Manager: search ComfyUI-FisheyeTransform, install, restart. Or manually:

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

Then restart. Nothing heavy here - no model downloads, no requirements beyond numpy, torch and OpenCV, all already present in a stock ComfyUI install.

Common trip-ups: edges look stretched after undistort β†’ raise zoom rather than lowering strength; lines still curve at the frame edge β†’ bump strength a little; black slivers at corners β†’ zoom up. And don't chase perfection - undistortion trades the curved-but-true edges for a slightly stretched middle, and Redistort is designed to hand that trade-off back. If the final result still looks off after the pair, it's usually a mismatch between the strength you flattened with and what you feed the inpaint - the params output keeps those in lockstep, so use it.

Categoryimage/transform

Inputs (4)

NameTypeDefaultDescription
imageIMAGEβ€”
strengthFLOAT1.000–3β€”
zoomFLOAT1.000.5–2β€”
maskoptMASKβ€”

Outputs (3)

NameTypeDescription
imageIMAGEβ€”
maskMASKβ€”
paramsFISHEYE_PARAMSβ€”