Distortion Correction in Darktable

A couple of months ago I received some truly helpful advice about getting started with darktable and about correcting lens distortion. My questions about distortion corrections then were about lenses not in the Lensfun database. Now, with thanks in advance, I have a question about distortion correction for a lens that is in the database: Pentax Q Standard 01 Prime.

Below is an image that is corrected, best I can tell: with the lens selected and the power-button icon turned on, yet the barrel distortion is obviously not corrected. Perhaps I have not managed successfully turn on the distortion correction. Otherwise, the only thing I can think of is that maybe the distortion correction Lensfun has was based on an image taken with the original Pentax Q, which had a (slightly) smaller sensor and that therefore the correction somehow didn’t take into account the distortion closer to the edges of the larger sensor, but looking at this image, this seems unlikely to me, so I’m lost.

What does lens correction say?
image

For example, for my Lumix compact, there is no CA data, so even though all corrections are selected, only distortion and vignetting are actually performed:
image

1 Like

Thanks for teh response, kofa. Let me go back and look at what the Lensfun correction for the lens says. It always starts with “lens not found” until I double click on it, and I admit to some frustration because once I alter the correction parameters (see below) I can’t seem to return to default or to find the lens profile the software started with: Pentax Q Standard 01.

In the meantime, through experimentation, I seem to have arrived at a fix below, though I can’t seem to fine tune it or create a style to be batch applied, which I’d like to do (though I know it might be imperfect when the aperture changes across images). Also, I’m not sure how choosing “Distort” seems to be the correction; al too much trial and error for my taste and would rather understand how it all works:

Now, I’m convinced that the software just does not pick the lens up in the Lensfun database (though Lensfun lists it as supported.) I was misreading the EXIF data report of the lens as confirmation that the distortion correction was found in Lensfun.

On the manual side, below is another bit of successful experimentation, this time making more sense, except that in the Corrections Done line it still says: None. Not sure if I care if this is a fix at least if I can create a Style for it to apply in batch.

Make sure to update the Lensfun database on your computer. On Linux the command is lensfun-update-data.

In both screen shots, the selected lens is “Generic, …”. I’m not sure there is a correction for such a lens.
Try clicking on the downwards arrow next to the line with the “Generic, …”. That should open a list of available lenses, where you can select the one you actually used (if it is in the database, of course).

Lensfun/Exiv2/Exiftool can have difficulties recognising the actual lens used for various reasons, one being that the lens ID codes aren’t standardised between lens makers. So often the program has to make an educated guess about the lens used. For older or full manual lenses, it’s possible there’s no lens information in the metadata…

Thanks. Comments below.

In both screen shots, the selected lens is “Generic, …”. I’m not sure there is a correction for such a lens.

There is, which is the only way I was able t make the correction.

Try clicking on the downwards arrow next to the line with the “Generic, …”. That should open a list of available lenses, where you can select the one you actually used (if it is in the database, of course).

It does, I did, and there are only three lenses, all generic. The fisheye is the only one that includes any correction to the distortion (which is unsurprising because the lens is a fisheye to get its field of view at that small size).

Lensfun/Exiv2/Exiftool can have difficulties recognising the actual lens used for various reasons, one being that the lens ID codes aren’t standardised between lens makers. So often the program has to make an educated guess about the lens used. For older or full manual lenses, it’s possible there’s no lens information in the metadata…

The Lensfun cite lists the exact lens by name and includes distortion correction checked (but not the other two corrections).

Well, that’s interesting. I assumed that updating darktable meant that Lensfun was ordinarily updated. Any idea what the command might be for Windows?

Lensfun has its own database. Darktable uses the library, but (AFAIK) does not ship a database.

if the wrong lens is picked up one can also create a .exiv2 file:

Pentax Q7 is defined as having a crop factor of 4.6 in the lensfun database. The 01 Standard Prime lens distortion is only defined for crop factor 5.53, and that’s why you don’t see it: it’s not a valid/matching combo. You’ll have to profile it yourself (or wait until someone else does it) when mounted on the Q7.

1 Like

Pentax Q7 is defined as having a crop factor of 4.6 in the lensfun database . The 01 Standard Prime lens distortion is only defined for crop factor 5.53, and that’s why you don’t see it: it’s not a valid/matching combo. You’ll have to profile it yourself (or wait until someone else does it) when mounted on the Q7.

Well, that makes sense. Actually, my camera is a Q-S1, but it also has the larger sensor as compared to the original Q, so the mismatch you describe is still an issue. (In my experimentation, I chose Q7 as the closest darktable option.) I’ll send Lensfun samples from all of the lenses worth correcting, the Standard 01 as well as the three higher quality zoom lenses. Thanks.

3 Likes

This camera is not in the darktable database AFAICT, please upload a DNG sample (and a PEF if the camera can output it) to RPU. You’ll also need to request for it to be added to the lensfun database separately. WIP for lensfun.

This camera is not in the darktable database AFAICT, please upload a DNG sample (and a PEF if the camera can output it) to RPU . You’ll also need to request for it to be added to the lensfun database separately. WIP for lensfun .

Thanks, and I just posted a native DNG file to RPU (the camera will not produce a PEF file) as well as filled out request on Github for darktable camera support; also added my support for request that lensfun add support.

1 Like

Separately, an interesting thing happened when viewing a DNG file from the Pentax Q-S1 taken with Standard 01 Prime. The default Windows image viewer automatically corrected the distortion I’m trying to find a way to correct withing darktable. That was a surprise. Any explanation (beyond the obvious that Microsoft has a broader database for corrections than darktable)? Thanks again.

Thanks, piratenpanda, but darktable is picking up the lens perfectly, but won’t correct the distortion in it.

What you see in Windows viewers is the embedded JPEG thumbnail/preview that has already been processed in camera.

Again that makes perfect sense, because I’ve tried the DNG file in Photopea and it doesn’t correct the distortion either.