Can I completely remove lens distortion from any image?

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?

Answer

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)

Attribution
Source : Link , Question Author : Inflight , Answer Author : user287001

Leave a Comment