# How to add lens distortion to an AI image

Source: https://passreal.com/how-to/add-lens-distortion

Real lens distortion is radial: zero at the optical centre and growing with distance, bending straight lines near the edges. Barrel distortion bows lines outward, pincushion pulls them inward. Add it with a lens correction filter or a radial remap, keep the coefficient tiny, crop the empty corners, and avoid the strong fisheye look that reads as an effect.

## Why bother with distortion

Every real lens bends the image a little. Straight lines near the border curve
outward or inward depending on the design, and the bend increases smoothly with
distance from the centre. Software in modern cameras and phones corrects much of
it, but not all, and a trained eye still picks up the residue on architecture.

A generated image has no lens. Its straight lines are mathematically straight,
unless the model itself drew a wobbly one. Adding a faint radial bend is one
way to give geometry some of a lens's character. It is a styling choice, not a
cure for anything, and it works best on pictures that contain long straight
edges.

## The maths in one paragraph

Distortion is usually modelled by scaling each point by a polynomial of its
distance from the centre. If the radius is r, the new radius is r times one plus
k times r squared, with k a small coefficient. Negative k gives barrel, positive
gives pincushion. Nothing happens at r equal to zero, which is why the centre
stays still. Higher-order terms refine the curve, but one coefficient is plenty
for a subtle effect.

## In GIMP

Open Filters, Distorts, Lens Distortion. The Main slider controls the radial
term. Values of roughly five to ten in either direction are already clearly
visible on a large image, so start lower than you expect and zoom in on a
straight edge. Leave Edge, Zoom and the brighten setting alone at first. After
applying, crop to remove transparent corners.

## In Photoshop

Use Filter, Lens Correction, then the Custom tab. The Remove Distortion slider
works in both directions: a negative value pushes toward barrel and a positive
value pulls toward pincushion on most versions, though the sign convention
varies, so check the preview. Turn on edge handling that crops or extends the
border so you do not end up with empty corners.

## In Python

OpenCV can remap points with a distortion model, and a short NumPy script does
the same with a polynomial of the radius. The workflow is: build a grid of
output coordinates, normalise them to the frame centre, compute the source
coordinates with your coefficient, and sample the image with bilinear or
bicubic interpolation. Choose a high-quality interpolation, because a weak one
softens the whole frame.

## Pitfalls

- Too much. A visible bend is a fisheye effect, which reads as a creative
  choice and not as an optical flaw.
- Resampling softness. Distortion resamples every pixel, so do it before you
  add grain and before the final export. Grain applied first would be warped
  along with everything else.
- Mismatch with metadata. If you claim a telephoto focal length in EXIF, heavy
  barrel distortion contradicts it.
- Faces. Edge faces stretch noticeably under strong distortion. Keep subjects
  near the centre.

## Where it fits in a full workflow

Geometry first, then colour fringing, then grain, then compression and metadata.
That order mirrors a real camera: optics, sensor, processing, file.

PassReal covers the later stages. It strips C2PA, IPTC digital source type, XMP
and PNG text chunks, applies grain and radial chromatic aberration that is zero
at the centre, low-pass filters the spectrum and writes a JPEG with real-camera
EXIF. It does not add geometric distortion, and it does not remove SynthID or
any pixel-level watermark.

## Checking your result

Print a grid in your head: find the longest straight edge nearest a border, such as a door frame or a skyline, and hold a ruler against the screen. A faint curve that you only notice with the ruler is the right amount. If you see the curve without it, undo and halve the coefficient. Also compare against a real photograph taken at the focal length you claim, because wide phone lenses and portrait lenses distort in opposite ways. Finally, remember that software correction in modern cameras flattens most of this, so restraint is more realistic than strength.

## Try it

Distort your image lightly, then process three images free at PassReal to finish
the sensor and file stages.

## Questions

### Barrel or pincushion?

Wide lenses on phones and compacts tend toward barrel distortion, while telephoto lenses tend toward pincushion. Choose the one that suits the focal length you claim in metadata.

### How strong should it be?

Barely visible. Modern cameras correct most distortion in software, so what remains is subtle. A visible bend is a sign of an edit or of a deliberate wide-angle look.

### Does distortion affect AI detection?

It alters geometry, not the sensor statistics or the metadata. We make no claim that it changes a detector's result.

### Is lens distortion the same as chromatic aberration?

No. Distortion bends geometry, while lateral chromatic aberration shifts colour channels slightly apart toward the edge. Both are radial, and both are zero at the centre.

### Does PassReal add lens distortion?

It applies radial chromatic aberration, not geometric distortion. Add distortion yourself before processing if you need it.

Try it: https://passreal.com/app (three images free)
