I was editing some photos taken with my new camera the other day, when I noticed something being off – the distortion correction of the embedded JPEG (corrected in-camera) and my edit using the lensfun-powered Lens Correction module didn’t match. That made me dive deeper into checking what’s up and sure enough, the lensfun correction gives the center of the photo (taken at 35mm) a slight barrel distortion. It’s not much, but noticeable, especially back-to-back.
I’ve read that DT should be able to read image EXIF and use the coefficients, but that doesn’t seem to be the case… what could be wrong? I looked at the EXIF data of the RAW file and found these coefficients:
I tried replacing the lensfun data with the coefficients I found but it looked horrible. However, reversing the order of coefficient I got from the RAW file made a very small improvement compared to what is in the lensfun database.
What are my options to get good distortion correction - take the calibration shots and compute the correction myself? (I can’t install Hugin Lens Calibration GUI on Windows - I can’t find it, I may need to do that on Linux)
Or perhaps do something with the extracted data from the RAWs?
The lensfun and Nikon coefficients aren’t interchangeable, they use different distortion models. That reversed Nikon coefficients seemed to work in lensfun is happenstance.
The Nikon coefficients seem to use the Adobe model, but there’s a fourth number needed to make that work and I can’t find it in the metadata. It may be that the number is assumable, but I’m not a math person and polynomials didn’t sink in in high school.
Making lensfun distortion inputs isn’t that hard, involves taking a few photos with a line running through them (buildings are good sources of such) , and there instructions to use the available software to make the numbers. IIRC, the instructions don’t use a line through the center of the image, so that might be why the current lensfun coefficients miss a center-specific distortion.
So is taking photos with a line through the center enough to produce a good correction? Also, is any perspective distortion (standing quite low relative to the lines on the building) any problem? I can’t quite find a place where I’d shoot level
A commercial building with glass windows and frame works pretty good. You want two complete straight lines going edge to edge in the frame. One line as close to the top as possible and one in the center (edit: actually 1/3 of the way per the lensfun website). They will evaluate and tell you if you need a better picture.
Yeah, I read somewhere on this forum that it’s difficult to find a uniform target (overcast sky is not always uniform - perhaps fog would work well) and putting something in front of the lens has a risk of creating artificial vignetting due to the light going through the material at an angle, so the correction overestimates the actual vignetting of the lens.
I believe a daytime fog that’s relatively dense would be the best bet
I’ve found a building where the wall consists of dense horizontal line pattern that will cover the image from top to bottom, edge-to-edge, so that should be the best one
I bought the new cannon rf 45mm 1.2, so I was taking some images today. It was very sunny, so 1.2 pictures at max speed of my camera. Let’s see if they are useful.
So I took the images, but the line detection algorithm in Lens Calibrate GUI struggled immensely to identify what (to me) looked like clearly defined lines - for some images it was impossible for it to find a single green line no matter what parameters I set.
Alternatively, I tried manually creating some lines in Panorama Stitcher through the advanced menu by defining control points and then optimizing the a, b, c parameters, which also didn’t give me the best results, as all but one photo had a slight pincushion distortion in the center compared to in-camera corrected JPEGs (perhaps a flaw in methods?)
Anyone got some specific examples of what kinds of buildings or textures work with the Lens Calibrate? (I can’t really share my photos for privacy reasons)
I’m struggling for the 70mm shot with a lot of pincushion distortion. The best I can achieve is this:
more vignetting and color - SOOC JPEG
less vignetting - my correction
Pay attention the the corners, there’s the most difference
Is this any acceptable or should I improve it further?
(yes it is a close-up shot, but I didn’t want to use my calibration shot, the distortion is similar anyways)
https://vimeo.com/51999287
I’ve followed this tutorial closely, but this is the best I can get to by fine-tuning the result a bit
Well, I tried the ./lens_calibrate.py distortion script, but all it does is export the RAWs into TIFs, that’s it:
(.venv) vente@vente-GR8:~/Desktop/lens_calibrate-master$ ./lens_calibrate.py distortion
/home/vente/Desktop/lens_calibrate-master/./lens_calibrate.py:677: SyntaxWarning: invalid escape sequence '\s'
b"(^P5\s(?:\s*#.*[\r\n])*"
/home/vente/Desktop/lens_calibrate-master/./lens_calibrate.py:678: SyntaxWarning: invalid escape sequence '\d'
b"(\d+)\s(?:\s*#.*[\r\n])*"
/home/vente/Desktop/lens_calibrate-master/./lens_calibrate.py:679: SyntaxWarning: invalid escape sequence '\d'
b"(\d+)\s(?:\s*#.*[\r\n])*"
/home/vente/Desktop/lens_calibrate-master/./lens_calibrate.py:680: SyntaxWarning: invalid escape sequence '\d'
b"(\d+)\s(?:\s*#.*[\r\n]\s)*)", buf).groups()
/home/vente/Desktop/lens_calibrate-master/./lens_calibrate.py:50: DeprecationWarning: Please import `leastsq` from the `scipy.optimize` namespace; the `scipy.optimize.minpack` namespace is deprecated and will be removed in SciPy 2.0.0.
from scipy.optimize.minpack import leastsq
Running distortion corrections ...
Converting distortion/DSC_3372.NEF to distortion/exported/DSC_3372.tif ...
Converting distortion/DSC_3374.NEF to distortion/exported/DSC_3374.tif ...
Converting distortion/DSC_3376.NEF to distortion/exported/DSC_3376.tif ...
OK
Converting distortion/DSC_3370.NEF to distortion/exported/DSC_3370.tif ...
OK
Converting distortion/DSC_3377.NEF to distortion/exported/DSC_3377.tif ...
OK
OK
OK
(.venv) vente@vente-GR8:~/Desktop/lens_calibrate-master$
After generating the lensfun.xml all coefficients are zero