Lens Correction not fixing Vignetting

Hi All,

First post here. Longtime Darktable user.

I’m having trouble fixing vignetting with the Lens Correction module in Darktable 4.4.1.

Older images, with the same lens, processed with Darktable 4.2.1 were fixed just fine with “corrections done: all” reported by the module. New images processed with 4.4.1 report “corrections done: distortion & TCA”.

My installation of Darktable was compiled from source via git. I am using Ubuntu 22.04.2. Lensfun is at 0.3.2-6. OpenCL is in use.

Thank you for any help you can provide.

-Todd

I’m a little confused about the messages you’re getting, because I never see anything like them.

However, I am on dt 4.4.1 and I loaded an image that I know has visible vignetting. I turned on the Lens Correction module, and the vignetting was visibly corrected. As I said, there were no messages informing me of that.

Could you supply a sample image as you have not mentioned the camera and lens and that may be where the problem lies. I know some lens I have to select manually and I had also had some lens not included in the lens correcting library.

image
The messages appear here near the bottom of the expanded module. And depending on the lens it changes from all, to distortion only or in the case shown here distortion & TCA

1 Like

Hi,

Sample Image Attached.

“This work is licensed under a Creative Commons Attribution 4.0 International License”

SAMPLE.NEF.xmp (12.0 KB)
SAMPLE.NEF (26.6 MB)

Camera: Nikon Z5
Lens: Nikkor Z 85mm f/1.8 S

This camera / lens combination was properly corrected for vignetting in Darktable 4.2.1

Also… An older xmp will report all corrections done but if the xmp is deleted and the raw file imported again vignetting can no longer be fixed.

Thanks again.

-Todd

1 Like

Thanks for the image Todd. This is one for the developers to comment on and they may suggest a bug report.

Hi Todd, thanks for finding out. Checked the lensfun database and indeed there should be vignette correction for that lens and i can reproduce the issue here.

Could you please open an issue at darktable github with

  1. rawfile provided
  2. lensfun version
  3. EDIT: could you also provide the “working” xmp file?
    Will take care of it.
2 Likes

I was able to recreate the issue. After some investigation I discover the root cause. In the module, the setting for distance to module is 0.01m. If you change it to 5.7 it correctly fixes the vignetting.

The value in darktable (in image information) for the focus distance is 0.01m
exiftool reports the Focus distance as 6.84mm
darktable uses exiv2 and exiv2 is showing two values:

Exif.NikonLd4.FocusDistance                  Byte        1  0.01 m
Exif.NikonLd4.FocusDistance                  Byte        1  6.68 m
Exif.Photo.SubjectDistanceRange              Short       1  Unknown

It seems like there are two identical tags with different values per exiv2 or I’m looking at the wrong tags.

dt uses this Ld4 tag for the focus distance (darktable/src/common/exif.cc at 57f0f678163ebee323c342c336514033c41442c2 · darktable-org/darktable · GitHub)

4 Likes

I just found the same underlying problem. Seems to be an exiv2 problem. @g-man - will you open a github issue? Likely @kmilos will know more about this …

Another idea about the focus distance reported wrongly. Todd, did you by any chance use the nikon raw developer tool (don’t remember the name) on this image? I vaguely remember that writing dubious data to the raw file …

Sorry for not beeing Todd, but it seems I also have this tag twice according to exiv2 in photos from my Z50. And I can guarantee no Nikon software touched them.

Edit:

It seems depending on whether the FTZ adapter is used, either one or the other tag is used.

Wow… Nice to wake up to all this active discussion.

I can confirm that no Nikon software touched the NEF/XMP. The FTZ adapter was not in play with this native Z lens.

I’m 8 hours away from being able to report this bug at github. Will do after the day job gets out of the way of my real work.

Thank you all.

1 Like

I would start an issue in Exiv2 github first. It is not clear why they report two values and how to tell them apart other than picking the largest (which might not be correct).

The duplication is actually reported by exiftool as well, and exiv2 returns both known fields: Nikon Tags

Perhaps only the second one is valid? I (and exiv2) have no way of telling this, just makes all the known data available…

P.S. Deduplication has already been fixed in 0.28.0 so no need for a new bug report, but in the meantime it can be accessed as Exif.NikonLd4.0x004f if darktable wants to use only this second value, or we need to detect FTZ and use either first or second value as @apostel338 suggests (like it is done for detecting the lens model already)?

Very good, thanks. For the picture I played with for OP, it says, “corrections done: all”.

You learn something new every day.

1 Like

On all my native Z-Mount lenses the focus distance is reported as 0.01m.
My older F-Mount lenses with the FTZ adapter seem to have the correct focus distance.

So as of now I have to manually adjust the focus distance for vignetting control.

Windows11 and current dt build is 4.5.0+150~gd04c5a7fd5

Edit: lensfun is up to date

Thank you for your input.

Can you describe how you are manually editing the focus distance? Is this in Darktable directly or are you using another tool? My workaround of late is to use a circular mask in another Exposure instance but it is a cumbersome hack.

in the lens correction module I go to the distance to subject and just select a number and see what looks best.
I can’t really create a preset because of aperture and focal length change.

In my latest build there is now the additional option to manually adjust vignetting within the lens correction module. Very handy…

1 Like

Oh my. Of course. I should have looked closer.

Thank you.