Let's say I have the following image: Image from some street camera

I want to completely remove lens distortion here, hence all straight lines of the real world must be straight at the image too. I'm trying to use filter "Lens Distortion", but whatever combination of parameters I use, there are curved lines: Image with lens distortion correction

Is it possible to completely remove lens distortion?


Theoretically lens distortion can be reversed if the distortion is one to one i.e. it doesn't mix to any point light from several points of undistorted image. Of course some resolution loss can occur when the image is resampled. Somewhere new pixels are interpolated to stretch an area and elsewhere an area can be squeezed to smaller number of pixels.

To be exact one must also tell what kind of imaging is considered to be right. I see you want to map straight lines to straight lines. The ancient lensless camera obscura worked and still works that way when the imaging surface is a plane.

To correct the lens distortion you should have a program which can do lens distortion profile based corrections. Then you should have also the lens profile and the aperture and focus settings used in this photo. For ex. Photoshop's CameraRaw knows hundreds of cameras and lenses.

Theoretically known straight lines around the image could help clever software to find a good guess of the needed correction, but that's a math problem and I must skip that theory. If you use generic distortion correcting filters you of course do the same - you try to get some straight lines back.

I guess you haven't the needed lens distortion data nor Photoshop. I guess you have already thoroughly tested and seen that GIMP's generic lens distortion compensating filter doesn't the job.

I tried PTLens correction filtering program. It knows many popular lenses, but it also has some generic filters with wide adjustment ranges. It's generic fisheye distortion corrector made this:

enter image description here

Surely not exact, but maybe useful. I guess it stretches the image horizontally. PTLens has a free 10 photo trial.

Another attempt was made in Affinity Photo. Its generic (=none special type specific) Lens Distortion filter made this:

enter image description here

Again: Not exact, but maybe even a little better than PTLens's.

ADD: Quite the same result as in Affinity Photo was available in Krita. There it was G'MIC filter pack's filter Distort Lens with negative distortion. G'MIC is freeware and it's also available for GIMP.

ADD2 Freeware image editor PhotoDemon seems to have very good generic lens distortion corrector. It has more controls than the previous shown in my answer. It gave this result.

enter image description here

The program runs in Windows and it's portable (=no installation needed)


I will not discuss in depth any technique, because you have already some good answers. I want to talk about something else.

All straight lines of the real world must be straight at the image too.

Nop. That is an illusion.

Stand in the middle of the longest hall in your house, or, if it is safe in the middle of a small street.

If you look to one side all lines will converge to that side, and if you look to the other side, the lines will converge to the other side.

But how can this be possible if you did not see the lines break at any point?

enter image description here

The answer is you are seeing a curved line with a smooth transition between.

enter image description here

The illusion is that as your field of view is limited, and as your brain assumes the lines are straight you see them as straight.

But with a camera, a lens with a wider field of view than your eye, or some software you can actually see that curvature.

enter image description here

Yes, there are some lenses that have more distortion than others. There are lenses that "correct" this distortions actually bending the image, and you also can do using the proper software.

But you are not "correcting" the curves, you are switching from one Illusion to other. See the other answers to do that.


Almost, but the more you try, the more pincushion distortion you will require. With extreme fisheye distortion, I sometimes find it useful to move the Main control all the way to the left, then work with the Edge and Zoom controls.


enter image description here

Another possibility is to do it manually using the Warp distort tool set to a large radius, and 1px spacing. Then you can work on the obvious lines with curves.


enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.