๐ Barrel Distortion
Give Your Image Lens Character โ or Undo the Barrel Bend Your Phone Added
- image
- IMAGE
Barrel Distortion is the lens effect where straight lines bow outward like the sides of a barrel - and its cousin, pincushion distortion, bows them inward. You'll want this node for two opposite jobs: either adding that slight wide-angle wobble to a too-clinical render, or fixing a real photo that already has it baked in from a phone's ultra-wide lens. Distortion is one of those "AI images don't have it unless you add it" tells, so a touch of it can actually make a synthetic image read more like it came out of a real camera.
It lives in the pack's Deformation category, which also has Fisheye, Ripple, Spherize and Pinch. Barrel is the subtle member of that family - fisheye is the show-off.
How it works
The math is the standard polynomial lens model: for each output pixel, the node computes a normalized radius from the distortion center, then remaps the image with cv2.remap using radial coefficients k1, k2, k3 (the classic BrownโConrady coefficients, minus the tangential terms). Positive k1 pushes pixels outward - barrel. Negative k1 pulls them inward - pincushion.
It uses bilinear interpolation and BORDER_REFLECT, so edges don't go black and the effect stays smooth. Because it's a pure remap, it doesn't resample quality into the image the way a blur would; the result stays sharp.
The inputs that matter
- k1 (โ1 to 1, default 0.2) - the primary coefficient. Positive barrels, negative pinches. This is the only one 90% of people ever touch.
- k2 / k3 (default 0) - higher-order corrections. For correcting real lens distortion you may want a small k2 to clean up the residual curve; for adding character, leave them at 0.
- center_x / center_y (default 0.5) - where the distortion pivots from. Shift it off-center for an off-axis lens look.
- scale (0.1โ2, default 1) - compensates for the empty space barrel distortion leaves at the corners; bump it past 1 when you push
k1hard.
Output is the warped IMAGE, ready to feed a Preview or Save node.
Installing it
From ComfyUI-Image-Effects (Orion4D). Use ComfyUI Manager โ search "Image Effects", or:
cd ComfyUI/custom_nodes
git clone https://github.com/orion4d/ComfyUI-Image-Effects
cd ComfyUI-Image-Effects
pip install -r requirements.txt
Restart ComfyUI and grab it under Add Node โ Image Effects. Nothing extra to download - the pack's dependencies are NumPy, OpenCV, Pillow and SciPy.
Gotchas
The usual pack rules apply: it only processes the first image in a batch, and it's CPU NumPy, so a 4K remap takes a moment (still usually under a second). The real trap here is subtle: after a strong barrel correction the image gets stretched toward the corners, so if you're fixing a photo, do it before any crop. And if your goal is "make it look like a real wide-angle shot," pair a mild positive k1 with the Fisheye node's higher field-of-view - barrel alone reads as a geometric trick, not a lens.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | โ | |
| k1 | FLOAT | 0.20-1โ1 | โ |
| k2 | FLOAT | 0.00-1โ1 | โ |
| k3 | FLOAT | 0.00-1โ1 | โ |
| center_xopt | FLOAT | 0.500โ1 | โ |
| center_yopt | FLOAT | 0.500โ1 | โ |
| scaleopt | FLOAT | 1.00.1โ2 | โ |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | โ |