Lens distortion correction: taking pictures of lines on a wall

I own a lens which has no lensfun profile (yet). I’m new to the calibration game so I read a bit and tried some things. My first try was a building with glass facade and the results with hugin are actually OK. I found out, however, that it seems to be crucial that one of the lines is very much at the top of the image. Therefore, some of the focal lengths result in a bit weird looking corrections…

But I thought, why do I need to go outside (it is also raining right now…) when I have a whiteboard. I painted some parallel lines on there and tried the same thing - but this time the acquired parameters made the images of the building facade look really weird. The lines were corrected very well though.
My gut feeling is, that the lines are not perfectly straight. However, I also have a printer :wink:

Thus the question is now: is it okay to do the shots for the distortion corrections using printed out paper, stuck on a wall? Is there any drawback when doing these kind of images using a small focus distance?
I only read that “they may not be 8m away”…
I understand that for the chromatic aberration you need the objects farther away.

1 Like

With vignetting correction you can take correction samples for every reported focus distance your lens gives you. For example 0.4m, 1m, 3m, 6m, 8m, 16m, 25m and infinity.

That doesn’t work for distortion or tca correction in Lensfun, and that is a drawback. Therefore you should take samples 10m away so that it works for most pictures you take.

But if you are a macro photographer, then you should create a distortion correction profile for a short distance.

A workaround would be to create two profiles with two different lens names you manually can choose between. Don’t know if it would be possible to create an automation of that in the lens correction module.

1 Like

But for the distortion correction: what is the technical reason to use 10m distance? Does the focus distance also influences the distortion? Do on those small focus distances the local variations of the lines play an increased role and lead to bad optimization?


Ah I see, so the idea is to have the correction in the range of the focus distance usually used.
Okay now it makes sense, thanks :slight_smile:

“ConsequentIy images should be taken at a distance of at least 25 feet (8 meters) so the correction will be accurate for architectural subjects.”

I read this footnote from Lens calibration for Lensfun

If you cannot get a picture of a building in your vicinity, don’t worry. Most lenses don’t need the full 8 metres of distance. What really matters are the long straight lines. But avoid anything closer than one metre.

Some lenses have a really big difference in the distortion when focused close or far away. For example my Canon EF 35-105/3.5-4.5. I created profile for 8 m away. If I take macro with it and apply lens correction it looks like a smiley at the corners.

You will notice yourself your optimal focus distance. The best thing is that you always can create a new profile.

Interesting! The lens I’m about to profile is a Canon EF 28-80 3.5-5.6 USM, which is from about the same era as the 35-105.
Interestingly, applying the distortion correction I measured at around 5m to the image I did at 1m distance gives an ok-ish result, while the other way around looks odd on the 5m image. I also did another round of images with printed out lines - but it turned out to be hard to get the paper straight on the whiteboard… But I haven’t started the hugin process on them.

I hope for some decent weather tomorrow and will try to get some more images of buildings!

If you also take some vignetting samples, make sure the ones you take for infinity is focused on something really far away like the moon, clouds or airplanes in the sky. Else the corrected images may be overcorrected and the corners will be brighter than everything else.


That must be what happened when the Olympus 14-150mm 1:4-5.6 II ED was profiled - it’s noticeable sometimes.

To add another question here: I made new images today from around 10m distance and profiled them in hugin. Out of curiosity I plotted the radial distortion (I hope I got the equation and also the plot right, see the title of the plot - I used what I found here: Lens correction model - PanoTools.org Wiki). What I find interesting is, that for the 80mm I get something really different than for 76mm. Does this indicate an error? I also read that it might be a good idea to switch to only optimizing the b parameter for larger focal lengths.

edit: I re-did the 80mm image in hugin, and now the curve looks different:

However, starting from 45mm, it seems a bit fuzzy… Maybe I redo those as well and also only with the b parameter in the optimization

I learn something new today. This explains why when I use lens correction people close to the camera sometimes get egg-shaped heads while the horizon straightens beautifully.

For what it’s worth, I’ve created several Lensfun LCPs (Lens Correction Profiles) to correct for geometric distortion using this technique:

I keep an old version of Hugin handy (from 2012, I think) as the later versions use a different method for plotting the control lines (of course, one could always adapt the technique instead).

The results seem fine regardless of the focal distance — although, as a significant point of note, the lenses I’ve created profiles for are all wide-angle primes (35mm and below). Just for reference, they’re also created using a crop-sensor camera (Fuji X).

That’s funny: I saw the link to this video on Torsten Bronger’s website, but could not watch it because it says “you need a vimeo account”. But I can watch the video when it is embedded. :person_shrugging:

as the later versions use a different method for plotting the control lines (of course, one could always adapt the technique instead).

The version I used (2022.0.0) has a switch to disable the connection lines.
I only had several crashes when I switched from the control point tab into the optimize tab.

I use this method. At least it is faster.

1 Like