Darktable possibly gets DNG embedded lens correction

There is current darktable work on adding lens correction based on embedded metadata in DNG files supporting the WarpRectilinear and FixVignetteRadial opcodes.

I already tested a great lot of available files and so far all seems very good.

To proceed and make sure the code is good we would like to field-test many more images.

Testing for correctness means: distortion and image size&crop should be the same for

  1. out of camera darktable developed DNG images using the “embedded metadata” mode compared with
  2. out-of-camera jpegs (preferred) or
  3. adobe converted above raw (1) to tiff or jpeg.

Testing any adobe converted raws to dng (instead of the out-of-camera-dngs) from other cameras might be interesting for the individual but not relevant for evaluations as there are so many ways to “spoil the party here”.

What can you do here?


  1. provide pairs of out-of-camera DNG plus jpeg so i or others can test either here in the forum or by mail
  2. compile dt yourself if you know how to include a certain pr (you need https://github.com/darktable-org/darktable/pull/12880 here)

Especially i am interested in leica fotos and how they provide lens data depending on the different lenses.


I will later provide some drone pictures from my DJI Mavic.

Do you mean the “Perspective Control” introduced by Leica? I think this was only introduced after the rangefinder model M10 was launched and therefore only the models that came onto the market after have the perspective control, e.g. M10-M, M10-P and M11.

No, I mean lens correction as done with lensman but using parameters the camera provides. Don’t need Q2 samples btw.

DJI_0417.DNG (23.2 MB)

I could offer DNGs from a Ricoh GR and GR III, and Pixel phones. Would these help?

I guess so. Please only pairs (DNG plus JPEG)

I tried your sample (only scene-referred default, but legacy white balance ”as shot”, plus lens correction, and the DJI Mavic Pro seems to be supported in general:

 rawprepare temperature highlights demosaic lens exposure colorin sigmoid colorout finalscale gamma (11)
   926.8526 [dt_imageio_export] [export] imgid 5, 3992x2992 --> 3992x2992 (scale 1.000000). upscale=no, hq=no

Here are some observations:

  • The result size is slightly different: 4000x3000 (original) vs/ 3992x2992 (darktable).
  • The white balance seems much more uniform in the original jpg, while in the darktable version the center seems slightly purple-tinted while the surrounding seems green-shifted.

Here’s the result jpeg:

Unfortunately, the DJI mini 3 pro is not yet supported as this would require opcode 9 (GainMap) in opcode list 3. @hannoschwalm, do you see a chance to support opcode 9 in opcode list 3 as well, as it is already supported in opcode list 2? I understand that this is not a simple copy&paste, as it is before/after demosaic, but hopefully it becomes at least a little bit easier …

Please, please, only raw&jpeg pairs.

The drone image is a first example why discussing the lens correction is so difficult. The dng file just has no information about lens warping so no point in analysing.

About gain map in op list 3. Simply no from my side …

That Drone image size is suspiciously like the DNG created by open camera and they are a bit strange…

Sure, the fitting raw+jpeg pair is two posts above. I maybe misunderstood your 2nd option

as a call for testing, which I did with @Peter’s raw+jpeg pair and my own (which do not work as explained). If this was not meant, then sorry for the noise.

I compiled dt with your PR, and tested it with images from my OnePlus 10 mobile phone. I have self added the corrections in lensfun for geometry. When I open an image from the phone, the drop down is grayed out, and only lensfun correction is available.
Is there an issue with the DNG file, or I failed in building the version?

Here is a pair of DNG and JPG from the wide angel lens, where the distortion is the largest.
IMG20221022161314.dng (24.3 MB)

Sorry, i didn’t recognize the image shown is the out-of-camera jpeg :slight_smile: No noise :slight_smile:

The dng file misses lens & vignette correction.

Right. That’s due to the default crop exif data found in the raw so i think the dt values are correct. Also - there is no warp correction included in the dng

Ricoh GR:
GR033017.DNG (13.4 MB)
GR033017.JPEG (6.0 MB)

Ricoh GR III:
R0009937.DNG (29.5 MB)
R0009937.JPG (13.6 MB)

Pixel 4a:
PXL_20220910_144908296.dng (9.0 MB)
PXL_20220910_144908296.jpg (3.5 MB)

Pixel 6:
PXL_20220911_063903400.dng (10.1 MB)
IMG_20220911_063903400.jpg (3.2 MB)

Pentax Q7:
IMGP5574.dng (19.5 MB)
IMGP5574.jpg (2.0 MB)

Is this the same code that tries to process embedded lens corrections for other ‘normal’ raw types ? Or is the DNG code a special case ?

It’s basically the same code. We also assume here, that camera makers know how to correct the lens :slight_smile:

Thanks Bastian, some files have embedded warp corrections (G6) some have dummy parameters, some have none.

But: no file failing the algo :slight_smile:

1 Like